mirror of
				https://github.com/taigrr/nats.docs
				synced 2025-01-18 04:03:23 -08:00 
			
		
		
		
	
		
			
				
	
	
		
			437 lines
		
	
	
		
			13 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			437 lines
		
	
	
		
			13 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
| {% extends template.self %}
 | |
| 
 | |
| {% block head %}
 | |
| {{ super() }}
 | |
| <link rel="stylesheet" href="https://cdn.materialdesignicons.com/3.6.95/css/materialdesignicons.min.css">
 | |
| {% endblock %}
 | |
| 
 | |
| {% block body %}
 | |
| {{ super() }}
 | |
| <!-- Viz Support -->
 | |
| <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/viz.js/2.1.2/viz.js"> </script>
 | |
| <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/viz.js/2.1.2/lite.render.js"> </script>
 | |
| 
 | |
| <!-- Site code -->
 | |
| <script>
 | |
|     function flash(elem, text, speed) {
 | |
|         if (!elem) {
 | |
|             return;
 | |
|         }
 | |
|         var s = elem.style;
 | |
|         elem.textContent = text;
 | |
|         s.display = 'block';
 | |
|         s.opacity = 1;
 | |
|         (function fade() {
 | |
|             (s.opacity -= .1) < .1 ? s.display = "none" : setTimeout(fade, speed)
 | |
|         })();
 | |
|     }
 | |
| 
 | |
|     function copyToClipboard(text, el) {
 | |
|         var copyTest = document.queryCommandSupported('copy');
 | |
|         var elOriginalText = el.getAttribute('data-original-title');
 | |
| 
 | |
|         if (copyTest === true) {
 | |
|             var copyTextArea = document.createElement("textarea");
 | |
|             copyTextArea.value = text;
 | |
|             document.body.appendChild(copyTextArea);
 | |
|             copyTextArea.select();
 | |
|             try {
 | |
|                 var successful = document.execCommand('copy');
 | |
|                 var msg = successful ? 'Copied!' : 'Whoops, not copied!';
 | |
|                 var parent = el.parentNode.parentNode;
 | |
|                 var msgElem = parent.querySelector(".copy-msg");
 | |
|                 flash(msgElem, msg, 100);
 | |
|             } catch (err) {
 | |
|                 console.log('Oops, unable to copy', err);
 | |
|             }
 | |
|             document.body.removeChild(copyTextArea);
 | |
|             el.setAttribute('data-original-title', elOriginalText);
 | |
|         } else {
 | |
|             // Fallback if browser doesn't support .execCommand('copy')
 | |
|             window.prompt("Copy to clipboard: Ctrl+C or Command+C, Enter", text);
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     function processGraphVizSections(elements) {
 | |
|         var elements = document.querySelectorAll("[data-viz]");
 | |
|         var viz = new Viz();
 | |
|         Array.prototype.forEach.call(elements, function (x) {
 | |
|             var engine = x.getAttribute("data-viz");
 | |
|             var image = viz.renderImageElement(x.innerText, {
 | |
|                 format: "png",
 | |
|                 engine: engine
 | |
|             }).then(function (element) {
 | |
|                 x.parentNode.insertBefore(element, x);
 | |
|             });
 | |
|         });
 | |
| 
 | |
| 
 | |
|     };
 | |
| 
 | |
|     function updateLanguageParameter(value) {
 | |
|         const param = "lang";
 | |
| 
 | |
|         if (window.location.href.indexOf("?") >= 0) {
 | |
|             const regExp = new RegExp(param + "(.+?)(&|$)", "g");
 | |
|             const newUrl = window.location.href.replace(regExp, param + "=" + encodeURIComponent(value) + "$2");
 | |
|             window.history.pushState("", "", newUrl);
 | |
|         } else {
 | |
|             const newUrl = window.location.href + "?" + param + "=" + encodeURIComponent(value);
 | |
|             window.history.pushState("", "", newUrl);
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     function getLanguageParameter() {
 | |
|         var match = RegExp('[?&]lang=([^&]*)').exec(window.location.search);
 | |
|         return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
 | |
|     }
 | |
| 
 | |
|     function docReady() {
 | |
|         window.gitbook.events.bind("page.change", function () {
 | |
|             pageChanged();
 | |
|         });
 | |
| 
 | |
|         var searchInput = document.querySelector('#book-search-input input');
 | |
| 
 | |
|         if (searchInput) {
 | |
|             searchInput.addEventListener('keyup', function(event) {
 | |
|                 if (event.keyCode === 13) {
 | |
|                     event.target.blur();
 | |
|                 }
 | |
|             });
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     function pageChanged() {
 | |
|         var logos = document.querySelectorAll(".nats");
 | |
|         if (logos && logos.length == 0) {
 | |
|             gitbook.toolbar.createButton({
 | |
|                 icon: 'nats',
 | |
|                 label: 'NATS Home Page',
 | |
|                 position: 'right',
 | |
|                 onClick: function () {
 | |
|                     var win = window.open("https://nats.io/", '_blank');
 | |
|                     win.focus();
 | |
|                 }
 | |
|             });
 | |
|         }
 | |
| 
 | |
|         document.querySelectorAll('.js-copy').forEach(elem => {
 | |
|             elem.addEventListener("click", function () {
 | |
|                 var el = this;
 | |
|                 var parent = this.parentNode.parentNode;
 | |
|                 var code = parent.querySelector('code');
 | |
|                 var text = code.textContent || code.innerText;
 | |
|                 copyToClipboard(text, el);
 | |
|             })
 | |
|         });
 | |
| 
 | |
|         document.querySelectorAll('.api-lang').forEach(elem => {
 | |
|             elem.addEventListener("click", function () {
 | |
|                 var curLang = sessionStorage.getItem('nats-api-language');
 | |
|                 var lang = this.getAttribute('data-language');
 | |
| 
 | |
|                 // Stop the infinite loop
 | |
|                 if (curLang == lang) {
 | |
|                     return;
 | |
|                 }
 | |
| 
 | |
|                 sessionStorage.setItem('nats-api-language', lang); // So we only do this 1x
 | |
| 
 | |
|                 updateLanguageParameter(lang)
 | |
| 
 | |
|                 document.querySelectorAll('.api-lang[data-language=' + lang + ']').forEach(elem => {
 | |
|                     elem.click();
 | |
|                 });
 | |
|             })
 | |
|         });
 | |
| 
 | |
|         if (sessionStorage) {
 | |
|             var curLang = sessionStorage.getItem('nats-api-language');
 | |
|             var queryLang = getLanguageParameter();
 | |
|             var lang = curLang;
 | |
| 
 | |
|             if (queryLang) { // query takes precedent
 | |
|                 lang = queryLang
 | |
|             }
 | |
| 
 | |
|             if (lang) {
 | |
|                 document.querySelectorAll('.api-lang[data-language=' + lang + ']').forEach(elem => {
 | |
|                     elem.click();
 | |
|                 });
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         setTimeout(function () {
 | |
|             processGraphVizSections();
 | |
|         }, 1);
 | |
|     }
 | |
| 
 | |
| 
 | |
|     if (document.readyState != 'loading') docReady();
 | |
|     else if (document.addEventListener) document.addEventListener('DOMContentLoaded', docReady);
 | |
|     else document.attachEvent('onreadystatechange', function () {
 | |
|         if (document.readyState == 'complete') docReady();
 | |
|     });
 | |
| </script>
 | |
| 
 | |
| <!-- Github Buttons -->
 | |
| <script async defer src="https://buttons.github.io/buttons.js"></script>
 | |
| 
 | |
| <!-- Styles -->
 | |
| <style>
 | |
|     .nats {
 | |
|         display: inline-block;
 | |
|         width: 16px;
 | |
|         height: 16px;
 | |
|         background: url(https://nats.io/img/nats-icon-color.svg);
 | |
|         background-size: 16px 16px;
 | |
|         background-repeat: no-repeat;
 | |
|     }
 | |
| 
 | |
|     div.graphviz {
 | |
|         background: transparent;
 | |
|         border: 0;
 | |
|         padding-top: 15px;
 | |
|         padding-right: 15px;
 | |
|         padding-bottom: 25px;
 | |
|         padding-left: 15px;
 | |
|         text-align: center;
 | |
|     }
 | |
| 
 | |
|     code[data-viz] {
 | |
|         display: none;
 | |
|     }
 | |
| 
 | |
|     .tab-wrap {
 | |
|         transition: 0.3s box-shadow ease;
 | |
|         border-radius: 6px;
 | |
|         max-width: 100%;
 | |
|         display: flex;
 | |
|         flex-wrap: wrap;
 | |
|         position: relative;
 | |
|         list-style: none;
 | |
|         background-color: #fff;
 | |
|         margin: 20px 0;
 | |
|         /* box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);*/
 | |
|     }
 | |
| 
 | |
|     .tab-wrap:hover {
 | |
|         box-shadow: 0 12px 23px rgba(0, 0, 0, 0.23), 0 10px 10px rgba(0, 0, 0, 0.19);
 | |
|     }
 | |
| 
 | |
|     .tab {
 | |
|         display: none;
 | |
|     }
 | |
| 
 | |
|     /* Using scss these would be generated, we have to manually create enough for all tabs, start with 8 */
 | |
|     .tab:checked:nth-of-type(1)~.tab__content:nth-of-type(1) {
 | |
|         opacity: 1;
 | |
|         transition: 0.5s opacity ease-in, 0.8s -webkit-transform ease;
 | |
|         transition: 0.5s opacity ease-in, 0.8s transform ease;
 | |
|         transition: 0.5s opacity ease-in, 0.8s transform ease, 0.8s -webkit-transform ease;
 | |
|         position: relative;
 | |
|         top: 0;
 | |
|         z-index: 100;
 | |
|         -webkit-transform: translateY(0px);
 | |
|         transform: translateY(0px);
 | |
|         text-shadow: 0 0 0;
 | |
|     }
 | |
| 
 | |
|     .tab:checked:nth-of-type(2)~.tab__content:nth-of-type(2) {
 | |
|         opacity: 1;
 | |
|         transition: 0.5s opacity ease-in, 0.8s -webkit-transform ease;
 | |
|         transition: 0.5s opacity ease-in, 0.8s transform ease;
 | |
|         transition: 0.5s opacity ease-in, 0.8s transform ease, 0.8s -webkit-transform ease;
 | |
|         position: relative;
 | |
|         top: 0;
 | |
|         z-index: 100;
 | |
|         -webkit-transform: translateY(0px);
 | |
|         transform: translateY(0px);
 | |
|         text-shadow: 0 0 0;
 | |
|     }
 | |
| 
 | |
|     .tab:checked:nth-of-type(3)~.tab__content:nth-of-type(3) {
 | |
|         opacity: 1;
 | |
|         transition: 0.5s opacity ease-in, 0.8s -webkit-transform ease;
 | |
|         transition: 0.5s opacity ease-in, 0.8s transform ease;
 | |
|         transition: 0.5s opacity ease-in, 0.8s transform ease, 0.8s -webkit-transform ease;
 | |
|         position: relative;
 | |
|         top: 0;
 | |
|         z-index: 100;
 | |
|         -webkit-transform: translateY(0px);
 | |
|         transform: translateY(0px);
 | |
|         text-shadow: 0 0 0;
 | |
|     }
 | |
| 
 | |
|     .tab:checked:nth-of-type(4)~.tab__content:nth-of-type(4) {
 | |
|         opacity: 1;
 | |
|         transition: 0.5s opacity ease-in, 0.8s -webkit-transform ease;
 | |
|         transition: 0.5s opacity ease-in, 0.8s transform ease;
 | |
|         transition: 0.5s opacity ease-in, 0.8s transform ease, 0.8s -webkit-transform ease;
 | |
|         position: relative;
 | |
|         top: 0;
 | |
|         z-index: 100;
 | |
|         -webkit-transform: translateY(0px);
 | |
|         transform: translateY(0px);
 | |
|         text-shadow: 0 0 0;
 | |
|     }
 | |
| 
 | |
|     .tab:checked:nth-of-type(5)~.tab__content:nth-of-type(5) {
 | |
|         opacity: 1;
 | |
|         transition: 0.5s opacity ease-in, 0.8s -webkit-transform ease;
 | |
|         transition: 0.5s opacity ease-in, 0.8s transform ease;
 | |
|         transition: 0.5s opacity ease-in, 0.8s transform ease, 0.8s -webkit-transform ease;
 | |
|         position: relative;
 | |
|         top: 0;
 | |
|         z-index: 100;
 | |
|         -webkit-transform: translateY(0px);
 | |
|         transform: translateY(0px);
 | |
|         text-shadow: 0 0 0;
 | |
|     }
 | |
| 
 | |
|     .tab:checked:nth-of-type(6)~.tab__content:nth-of-type(6) {
 | |
|         opacity: 1;
 | |
|         transition: 0.5s opacity ease-in, 0.8s -webkit-transform ease;
 | |
|         transition: 0.5s opacity ease-in, 0.8s transform ease;
 | |
|         transition: 0.5s opacity ease-in, 0.8s transform ease, 0.8s -webkit-transform ease;
 | |
|         position: relative;
 | |
|         top: 0;
 | |
|         z-index: 100;
 | |
|         -webkit-transform: translateY(0px);
 | |
|         transform: translateY(0px);
 | |
|         text-shadow: 0 0 0;
 | |
|     }
 | |
| 
 | |
|     .tab:checked:nth-of-type(7)~.tab__content:nth-of-type(7) {
 | |
|         opacity: 1;
 | |
|         transition: 0.5s opacity ease-in, 0.8s -webkit-transform ease;
 | |
|         transition: 0.5s opacity ease-in, 0.8s transform ease;
 | |
|         transition: 0.5s opacity ease-in, 0.8s transform ease, 0.8s -webkit-transform ease;
 | |
|         position: relative;
 | |
|         top: 0;
 | |
|         z-index: 100;
 | |
|         -webkit-transform: translateY(0px);
 | |
|         transform: translateY(0px);
 | |
|         text-shadow: 0 0 0;
 | |
|     }
 | |
| 
 | |
|     .tab:checked:nth-of-type(8)~.tab__content:nth-of-type(8) {
 | |
|         opacity: 1;
 | |
|         transition: 0.5s opacity ease-in, 0.8s -webkit-transform ease;
 | |
|         transition: 0.5s opacity ease-in, 0.8s transform ease;
 | |
|         transition: 0.5s opacity ease-in, 0.8s transform ease, 0.8s -webkit-transform ease;
 | |
|         position: relative;
 | |
|         top: 0;
 | |
|         z-index: 100;
 | |
|         -webkit-transform: translateY(0px);
 | |
|         transform: translateY(0px);
 | |
|         text-shadow: 0 0 0;
 | |
|     }
 | |
| 
 | |
|     .tab:first-of-type:not(:last-of-type)+label {
 | |
|         border-top-right-radius: 0;
 | |
|         border-bottom-right-radius: 0;
 | |
|     }
 | |
| 
 | |
|     .tab:not(:first-of-type):not(:last-of-type)+label {
 | |
|         border-radius: 0;
 | |
|     }
 | |
| 
 | |
|     .tab:last-of-type:not(:first-of-type)+label {
 | |
|         border-top-left-radius: 0;
 | |
|         border-bottom-left-radius: 0;
 | |
|     }
 | |
| 
 | |
|     .tab:checked+label {
 | |
|         background-color: #fff;
 | |
|         box-shadow: 0 -1px 0 #fff inset;
 | |
|         cursor: default;
 | |
|         font-weight: bold;
 | |
|         border: 1px solid #ddd;
 | |
|         border-bottom-color: transparent;
 | |
|     }
 | |
| 
 | |
|     .tab:checked+label:hover {
 | |
|         box-shadow: 0 -1px 0 #fff inset;
 | |
|         background-color: #fff;
 | |
|     }
 | |
| 
 | |
|     .tab+label {
 | |
|         box-shadow: 0 -1px 0 #eee inset;
 | |
|         border-radius: 6px 6px 0 0;
 | |
|         cursor: pointer;
 | |
|         display: block;
 | |
|         text-decoration: none;
 | |
|         color: #27aae1;
 | |
|         flex-grow: 3;
 | |
|         text-align: center;
 | |
|         -webkit-user-select: none;
 | |
|         -moz-user-select: none;
 | |
|         -ms-user-select: none;
 | |
|         user-select: none;
 | |
|         text-align: center;
 | |
|         transition: 0.3s background-color ease, 0.3s box-shadow ease;
 | |
|         height: 50px;
 | |
|         box-sizing: border-box;
 | |
|         padding: 15px;
 | |
|     }
 | |
| 
 | |
|     .tab+label:hover {
 | |
|         background-color: #f9f9f9;
 | |
|         box-shadow: 0 1px 0 #f4f4f4 inset;
 | |
|     }
 | |
| 
 | |
|     .tab__content {
 | |
|         padding: 2px 2px;
 | |
|         background-color: transparent;
 | |
|         position: absolute;
 | |
|         width: 100%;
 | |
|         z-index: -1;
 | |
|         opacity: 0;
 | |
|         left: 0;
 | |
|         -webkit-transform: translateY(-3px);
 | |
|         transform: translateY(-3px);
 | |
|         border-radius: 6px;
 | |
|     }
 | |
| 
 | |
|     .tab__content pre {
 | |
|         margin-bottom: 0px !important;
 | |
|     }
 | |
| 
 | |
|     .toolbar-icons {
 | |
|         display: inline-block;
 | |
|         position: relative;
 | |
|         padding-left: 4px;
 | |
|     }
 | |
| 
 | |
|     a.toolbar-icons {
 | |
|         text-decoration: none;
 | |
|     }
 | |
| 
 | |
|     .toolbar-icons .mdi {
 | |
|         color: #4183c4;
 | |
|     }
 | |
| 
 | |
|     .copy-msg {
 | |
|         color: #4183c4;
 | |
|     }
 | |
| 
 | |
|     .pull-right {
 | |
|         float: right !important;
 | |
|     }
 | |
| 
 | |
|     .pull-left {
 | |
|         float: left !important;
 | |
|     }
 | |
| </style>
 | |
| <!-- Global site tag (gtag.js) - Google Analytics -->
 | |
| <script async src="https://www.googletagmanager.com/gtag/js?id=UA-111730698-1"></script>
 | |
| <script>
 | |
|  window.dataLayer = window.dataLayer || [];
 | |
|  function gtag(){dataLayer.push(arguments);}
 | |
|  gtag('js', new Date());
 | |
| 
 | |
|  gtag('config', 'UA-111730698-1');
 | |
| </script>
 | |
| {% endblock %} |