mirror of
https://github.com/taigrr/nats.docs
synced 2025-01-18 04:03:23 -08:00
wip
This commit is contained in:
parent
ec0cd3dcab
commit
28dfe4b752
@ -7,7 +7,16 @@
|
||||
* [Clients](nats_server/clients.md)
|
||||
* [Flags](nats_server/flags.md)
|
||||
* [Configuration File](nats_server/configuration.md)
|
||||
* [Authentication](nats_server/authentication.md)
|
||||
* [Authorization](nats_server/authorization.md)
|
||||
* [Clustering](nats_server/clustering.md)
|
||||
* [TLS Security](nats_server/tls.md)
|
||||
* [Logging](nats_server/logging.md)
|
||||
* [Monitoring](nats_server/monitoring.md)
|
||||
* [Statistics](nats_server/natstop.md)
|
||||
* [NATS Top Tutorial](nats_server/nats_top_tutorial.md)
|
||||
* [Signals](nats_server/signals.md)
|
||||
* [Window Service](nats_server/windows_srv.md)
|
||||
* [Upgrading a Cluster](nats_server/upgrading.md)
|
||||
* [Developing with NATS](developer/README.md)
|
||||
* [Connecting](developer/connecting.md)
|
||||
|
3
docs/.gitignore
vendored
3
docs/.gitignore
vendored
@ -1 +1,4 @@
|
||||
_book/
|
||||
|
||||
.vscode
|
||||
node_modules
|
11
docs/building_the_book.md
Normal file
11
docs/building_the_book.md
Normal file
@ -0,0 +1,11 @@
|
||||
# Building the Book
|
||||
|
||||
The build uses https://github.com/Bandwidth/gitbook-plugin-include-html to include html directly for code examples as well as the prism plugin to handle code highlighting. CSS for code highlighting seems to get mucked up sometimes if you don't use the default them, this is something to work on in the future.
|
||||
|
||||
Icons for dev examples are from https://cdn.materialdesignicons.com/3.6.95/.
|
||||
|
||||
To build the examples
|
||||
|
||||
```bash
|
||||
% go run tools/examplecompiler/main.go -o developer/examples -r tools/examplecompiler/example_repos.json -t tools/examplecompiler/example_template.tmp
|
||||
```
|
1904
docs/developer/connecting.html
Normal file
1904
docs/developer/connecting.html
Normal file
File diff suppressed because it is too large
Load Diff
115
docs/developer/examples/connect_default.html
Normal file
115
docs/developer/examples/connect_default.html
Normal file
@ -0,0 +1,115 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="connect_default_go" name="connect_default" class="tab" checked>
|
||||
|
||||
<label for="connect_default_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_default_java" name="connect_default" class="tab">
|
||||
|
||||
<label for="connect_default_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_default_js" name="connect_default" class="tab">
|
||||
|
||||
<label for="connect_default_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_default_py" name="connect_default" class="tab">
|
||||
|
||||
<label for="connect_default_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_default_ruby" name="connect_default" class="tab">
|
||||
|
||||
<label for="connect_default_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_default_ts" name="connect_default" class="tab">
|
||||
|
||||
<label for="connect_default_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_default_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/connect_default/main.go#L10-19"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">nc, err := nats.Connect(nats.DefaultURL)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_default_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/ConnectToDefaultServer.java#L10-16"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Connection nc = Nats.connect();
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_default_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/connection_samples.js#L22-33"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let nc = NATS.connect();
|
||||
nc.on('connect', (c) => {
|
||||
// Do something with the connection
|
||||
doSomething();
|
||||
// When done close it
|
||||
nc.close();
|
||||
});
|
||||
nc.on('error', (err) => {
|
||||
failed(err);
|
||||
});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_default_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/connect_default.py#L5-13"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">nc = NATS()
|
||||
await nc.connect()
|
||||
|
||||
# Do something with the connection
|
||||
|
||||
await nc.close()
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_default_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/connect_default.rb#L1-10"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby">require 'nats/client'
|
||||
|
||||
NATS.start do |nc|
|
||||
# Do something with the connection
|
||||
|
||||
# Close the connection
|
||||
nc.close
|
||||
end
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_default_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/connection_samples.ts#L16-34"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">// will throw an exception if connection fails
|
||||
let nc = await connect();
|
||||
// Do something with the connection
|
||||
|
||||
// When done close it
|
||||
nc.close();
|
||||
|
||||
|
||||
// alternatively, you can use the Promise pattern
|
||||
let nc1: Client;
|
||||
connect()
|
||||
.then((c) => {
|
||||
nc1 = c;
|
||||
// Do something with the connection
|
||||
nc1.close();
|
||||
});
|
||||
// add a .catch/.finally
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
129
docs/developer/examples/connect_multiple.html
Normal file
129
docs/developer/examples/connect_multiple.html
Normal file
@ -0,0 +1,129 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="connect_multiple_go" name="connect_multiple" class="tab" checked>
|
||||
|
||||
<label for="connect_multiple_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_multiple_java" name="connect_multiple" class="tab">
|
||||
|
||||
<label for="connect_multiple_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_multiple_js" name="connect_multiple" class="tab">
|
||||
|
||||
<label for="connect_multiple_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_multiple_py" name="connect_multiple" class="tab">
|
||||
|
||||
<label for="connect_multiple_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_multiple_ruby" name="connect_multiple" class="tab">
|
||||
|
||||
<label for="connect_multiple_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_multiple_ts" name="connect_multiple" class="tab">
|
||||
|
||||
<label for="connect_multiple_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_multiple_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/connect_multiple/main.go#L11-25"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">servers := []string{"nats://localhost:1222",
|
||||
"nats://localhost:1223",
|
||||
"nats://localhost:1224",
|
||||
}
|
||||
|
||||
nc, err := nats.Connect(strings.Join(servers, ","))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_multiple_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/ConnectToMultipleServers.java#L11-22"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Options options = new Options.Builder().
|
||||
server("nats://localhost:1222").
|
||||
server("nats://localhost:1223").
|
||||
server("nats://localhost:1224").
|
||||
build();
|
||||
Connection nc = Nats.connect(options);
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_multiple_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/connection_samples.js#L67-84"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let nc = NATS.connect({
|
||||
servers: [
|
||||
"nats://demo.nats.io:4222",
|
||||
"nats://localhost:4222"
|
||||
]}
|
||||
);
|
||||
|
||||
nc.on('connect', (c) => {
|
||||
// Do something with the connection
|
||||
doSomething();
|
||||
// When done close it
|
||||
nc.close();
|
||||
});
|
||||
nc.on('error', (err) => {
|
||||
failed(err);
|
||||
});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_multiple_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/connect_multiple.py#L5-17"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">nc = NATS()
|
||||
await nc.connect(servers=[
|
||||
"nats://127.0.0.1:1222",
|
||||
"nats://127.0.0.1:1223",
|
||||
"nats://127.0.0.1:1224"
|
||||
])
|
||||
|
||||
# Do something with the connection
|
||||
|
||||
await nc.close()
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_multiple_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/connect_multiple.rb#L1-10"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby">require 'nats/client'
|
||||
|
||||
NATS.start(servers: ["nats://127.0.0.1:1222", "nats://127.0.0.1:1223", "nats://127.0.0.1:1224"]) do |nc|
|
||||
# Do something with the connection
|
||||
|
||||
# Close the connection
|
||||
nc.close
|
||||
end
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_multiple_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/connection_samples.ts#L53-65"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">// will throw an exception if connection fails
|
||||
let nc = await connect({
|
||||
servers: [
|
||||
"nats://demo.nats.io:4222",
|
||||
"nats://localhost:4222"
|
||||
]
|
||||
});
|
||||
// Do something with the connection
|
||||
|
||||
// When done close it
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
109
docs/developer/examples/connect_name.html
Normal file
109
docs/developer/examples/connect_name.html
Normal file
@ -0,0 +1,109 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="connect_name_go" name="connect_name" class="tab" checked>
|
||||
|
||||
<label for="connect_name_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_name_java" name="connect_name" class="tab">
|
||||
|
||||
<label for="connect_name_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_name_js" name="connect_name" class="tab">
|
||||
|
||||
<label for="connect_name_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_name_py" name="connect_name" class="tab">
|
||||
|
||||
<label for="connect_name_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_name_ruby" name="connect_name" class="tab">
|
||||
|
||||
<label for="connect_name_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_name_ts" name="connect_name" class="tab">
|
||||
|
||||
<label for="connect_name_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_name_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/connect_name/main.go#L10-20"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">// Set a connection name
|
||||
nc, err := nats.Connect("demo.nats.io", nats.Name("my-connection"))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_name_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/ConnectName.java#L11-21"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Options options = new Options.Builder().
|
||||
server("nats://demo.nats.io:4222").
|
||||
connectionName("my-connection"). // Set a connection name
|
||||
build();
|
||||
Connection nc = Nats.connect(options);
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_name_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/options_samples.js#L73-79"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let nc = NATS.connect({
|
||||
url: "nats://demo.nats.io:4222",
|
||||
name: "my-connection"
|
||||
});
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_name_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/connect_name.py#L6-13"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">nc = NATS()
|
||||
|
||||
await nc.connect(servers=["nats://demo.nats.io:4222"], name="my-connection")
|
||||
|
||||
# Do something with the connection.
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_name_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/connect_name.rb#L1-15"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby">require 'nats/client'
|
||||
|
||||
NATS.start(servers:["nats://demo.nats.io:4222"], name: "my-connection") do |nc|
|
||||
nc.on_reconnect do
|
||||
puts "Got reconnected to #{nc.connected_server}"
|
||||
end
|
||||
|
||||
nc.on_disconnect do |reason|
|
||||
puts "Got disconnected! #{reason}"
|
||||
end
|
||||
|
||||
nc.close
|
||||
end
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_name_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/options_samples.ts#L55-63"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">// will throw an exception if connection fails
|
||||
let nc = await connect({
|
||||
url: "nats://demo.nats.io:4222",
|
||||
name: "my-connection"
|
||||
});
|
||||
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
102
docs/developer/examples/connect_options.html
Normal file
102
docs/developer/examples/connect_options.html
Normal file
@ -0,0 +1,102 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="connect_options_go" name="connect_options" class="tab" checked>
|
||||
|
||||
<label for="connect_options_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_options_java" name="connect_options" class="tab">
|
||||
|
||||
<label for="connect_options_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_options_js" name="connect_options" class="tab">
|
||||
|
||||
<label for="connect_options_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_options_py" name="connect_options" class="tab">
|
||||
|
||||
<label for="connect_options_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_options_ruby" name="connect_options" class="tab">
|
||||
|
||||
<label for="connect_options_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_options_ts" name="connect_options" class="tab">
|
||||
|
||||
<label for="connect_options_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_options_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/connect_options/main.go#L11-20"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">nc, err := nats.Connect(nats.DefaultURL, nats.Timeout(10*time.Second))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_options_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/ConnectWithOptions.java#L13-23"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Options options = new Options.Builder().
|
||||
server("nats://demo.nats.io:4222").
|
||||
connectionTimeout(Duration.ofSeconds(10)). // Set timeout
|
||||
build();
|
||||
Connection nc = Nats.connect(options);
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_options_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/options_samples.js#L121-123"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">// connection timeout is not supported on node-nats
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_options_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/connect_options.py#L5-13"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">nc = NATS()
|
||||
await nc.connect(connect_timeout=2)
|
||||
|
||||
# Do something with the connection
|
||||
|
||||
await nc.close()
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_options_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/connect_options.rb#L1-14"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby"># There is currently no connect timeout as part of the Ruby NATS client API, but you can use a timer to mimic it.
|
||||
require 'nats/client'
|
||||
|
||||
timer = EM.add_timer(5) do
|
||||
NATS.connect do |nc|
|
||||
# Do something with the connection
|
||||
|
||||
# Close the connection
|
||||
nc.close
|
||||
end
|
||||
end
|
||||
EM.cancel_timer(timer)
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_options_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/options_samples.ts#L89-95"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let nc = await connect({
|
||||
url: "nats://demo.nats.io:4222",
|
||||
timeout: 1000
|
||||
});
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
112
docs/developer/examples/connect_pedantic.html
Normal file
112
docs/developer/examples/connect_pedantic.html
Normal file
@ -0,0 +1,112 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="connect_pedantic_go" name="connect_pedantic" class="tab" checked>
|
||||
|
||||
<label for="connect_pedantic_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_pedantic_java" name="connect_pedantic" class="tab">
|
||||
|
||||
<label for="connect_pedantic_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_pedantic_js" name="connect_pedantic" class="tab">
|
||||
|
||||
<label for="connect_pedantic_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_pedantic_py" name="connect_pedantic" class="tab">
|
||||
|
||||
<label for="connect_pedantic_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_pedantic_ruby" name="connect_pedantic" class="tab">
|
||||
|
||||
<label for="connect_pedantic_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_pedantic_ts" name="connect_pedantic" class="tab">
|
||||
|
||||
<label for="connect_pedantic_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_pedantic_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/connect_pedantic/main.go#L10-23"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">opts := nats.GetDefaultOptions()
|
||||
opts.Url = "demo.nats.io"
|
||||
// Turn on Pedantic
|
||||
opts.Pedantic = true
|
||||
nc, err := opts.Connect()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_pedantic_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/ConnectPedantic.java#L11-21"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Options options = new Options.Builder().
|
||||
server("nats://demo.nats.io:4222").
|
||||
pedantic(). // Turn on pedantic
|
||||
build();
|
||||
Connection nc = Nats.connect(options);
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_pedantic_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/options_samples.js#L39-45"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let nc = NATS.connect({
|
||||
url: "nats://demo.nats.io:4222",
|
||||
pedantic: true
|
||||
});
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_pedantic_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/connect_pedantic.py#L6-13"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">nc = NATS()
|
||||
|
||||
await nc.connect(servers=["nats://demo.nats.io:4222"], pedantic=True)
|
||||
|
||||
# Do something with the connection.
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_pedantic_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/connect_pedantic.rb#L1-15"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby">require 'nats/client'
|
||||
|
||||
NATS.start(pedantic: true) do |nc|
|
||||
nc.on_reconnect do
|
||||
puts "Got reconnected to #{nc.connected_server}"
|
||||
end
|
||||
|
||||
nc.on_disconnect do |reason|
|
||||
puts "Got disconnected! #{reason}"
|
||||
end
|
||||
|
||||
nc.close
|
||||
end
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_pedantic_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/options_samples.ts#L29-37"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">// will throw an exception if connection fails
|
||||
let nc = await connect({
|
||||
url: "nats://demo.nats.io:4222",
|
||||
pedantic: true
|
||||
});
|
||||
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
144
docs/developer/examples/connect_status.html
Normal file
144
docs/developer/examples/connect_status.html
Normal file
@ -0,0 +1,144 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="connect_status_go" name="connect_status" class="tab" checked>
|
||||
|
||||
<label for="connect_status_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_status_java" name="connect_status" class="tab">
|
||||
|
||||
<label for="connect_status_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_status_js" name="connect_status" class="tab">
|
||||
|
||||
<label for="connect_status_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_status_py" name="connect_status" class="tab">
|
||||
|
||||
<label for="connect_status_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_status_ruby" name="connect_status" class="tab">
|
||||
|
||||
<label for="connect_status_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_status_ts" name="connect_status" class="tab">
|
||||
|
||||
<label for="connect_status_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_status_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/connect_status/main.go#L10-33"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">nc, err := nats.Connect("demo.nats.io")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
getStatusTxt := func(nc *nats.Conn) string {
|
||||
switch nc.Status() {
|
||||
case nats.CONNECTED:
|
||||
return "Connected"
|
||||
case nats.CLOSED:
|
||||
return "Closed"
|
||||
default:
|
||||
return "Other"
|
||||
}
|
||||
}
|
||||
log.Printf("The connection is %v\n", getStatusTxt(nc))
|
||||
|
||||
nc.Close()
|
||||
|
||||
log.Printf("The connection is %v\n", getStatusTxt(nc))
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_status_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/GetConnectionStatus.java#L10-18"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Connection nc = Nats.connect("nats://demo.nats.io:4222");
|
||||
|
||||
System.out.println("The Connection is: " + nc.getStatus());
|
||||
|
||||
nc.close();
|
||||
|
||||
System.out.println("The Connection is: " + nc.getStatus());
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_status_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/event_samples.js#L99-113"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let nc = NATS.connect("nats://demo.nats.io:4222");
|
||||
|
||||
// on node you *must* register an error listener. If not registered
|
||||
// the library emits an 'error' event, the node process will exit.
|
||||
nc.on('error', (err) => {
|
||||
t.log('client got an error:', err);
|
||||
});
|
||||
|
||||
if(nc.closed) {
|
||||
t.log('client is closed');
|
||||
} else {
|
||||
t.log('client is not closed');
|
||||
}
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_status_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/connect_status.py#L6-27"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">nc = NATS()
|
||||
|
||||
await nc.connect(
|
||||
servers=["nats://demo.nats.io:4222"],
|
||||
)
|
||||
|
||||
# Do something with the connection.
|
||||
|
||||
print("The connection is connected?", nc.is_connected)
|
||||
|
||||
while True:
|
||||
if nc.is_reconnecting:
|
||||
print("Reconnecting to NATS...")
|
||||
break
|
||||
await asyncio.sleep(1)
|
||||
|
||||
await nc.close()
|
||||
|
||||
print("The connection is closed?", nc.is_closed)
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_status_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/connect_status.rb#L3-21"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby">NATS.start(max_reconnect_attempts: 2) do |nc|
|
||||
puts "Connect is connected?: #{nc.connected?}"
|
||||
|
||||
timer = EM.add_periodic_timer(1) do
|
||||
if nc.closing?
|
||||
puts "Connection closed..."
|
||||
EM.cancel_timer(timer)
|
||||
NATS.stop
|
||||
end
|
||||
|
||||
if nc.reconnecting?
|
||||
puts "Reconnecting to NATS..."
|
||||
next
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_status_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/event_samples.ts#L62-68"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">if(nc.isClosed()) {
|
||||
t.log('the client is closed');
|
||||
} else {
|
||||
t.log('the client is running');
|
||||
}
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
213
docs/developer/examples/connect_tls.html
Normal file
213
docs/developer/examples/connect_tls.html
Normal file
@ -0,0 +1,213 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="connect_tls_go" name="connect_tls" class="tab" checked>
|
||||
|
||||
<label for="connect_tls_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_tls_java" name="connect_tls" class="tab">
|
||||
|
||||
<label for="connect_tls_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_tls_js" name="connect_tls" class="tab">
|
||||
|
||||
<label for="connect_tls_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_tls_py" name="connect_tls" class="tab">
|
||||
|
||||
<label for="connect_tls_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_tls_ruby" name="connect_tls" class="tab">
|
||||
|
||||
<label for="connect_tls_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_tls_ts" name="connect_tls" class="tab">
|
||||
|
||||
<label for="connect_tls_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_tls_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/connect_tls/main.go#L10-21"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">nc, err := nats.Connect("localhost",
|
||||
nats.ClientCert("resources/certs/cert.pem", "resources/certs/key.pem"),
|
||||
nats.RootCAs("resources/certs/ca.pem"))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_tls_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/ConnectTLS.java#L18-81"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">class SSLUtils {
|
||||
public static String KEYSTORE_PATH = "src/main/resources/keystore.jks";
|
||||
public static String TRUSTSTORE_PATH = "src/main/resources/cacerts";
|
||||
public static String STORE_PASSWORD = "password";
|
||||
public static String KEY_PASSWORD = "password";
|
||||
public static String ALGORITHM = "SunX509";
|
||||
|
||||
public static KeyStore loadKeystore(String path) throws Exception {
|
||||
KeyStore store = KeyStore.getInstance("JKS");
|
||||
BufferedInputStream in = new BufferedInputStream(new FileInputStream(path));
|
||||
|
||||
try {
|
||||
store.load(in, STORE_PASSWORD.toCharArray());
|
||||
} finally {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
|
||||
return store;
|
||||
}
|
||||
|
||||
public static KeyManager[] createTestKeyManagers() throws Exception {
|
||||
KeyStore store = loadKeystore(KEYSTORE_PATH);
|
||||
KeyManagerFactory factory = KeyManagerFactory.getInstance(ALGORITHM);
|
||||
factory.init(store, KEY_PASSWORD.toCharArray());
|
||||
return factory.getKeyManagers();
|
||||
}
|
||||
|
||||
public static TrustManager[] createTestTrustManagers() throws Exception {
|
||||
KeyStore store = loadKeystore(TRUSTSTORE_PATH);
|
||||
TrustManagerFactory factory = TrustManagerFactory.getInstance(ALGORITHM);
|
||||
factory.init(store);
|
||||
return factory.getTrustManagers();
|
||||
}
|
||||
|
||||
public static SSLContext createSSLContext() throws Exception {
|
||||
SSLContext ctx = SSLContext.getInstance(Options.DEFAULT_SSL_PROTOCOL);
|
||||
ctx.init(createTestKeyManagers(), createTestTrustManagers(), new SecureRandom());
|
||||
return ctx;
|
||||
}
|
||||
}
|
||||
|
||||
public class ConnectTLS {
|
||||
public static void main(String[] args) {
|
||||
|
||||
try {
|
||||
SSLContext ctx = SSLUtils.createSSLContext();
|
||||
Options options = new Options.Builder().
|
||||
server("nats://localhost:4222").
|
||||
sslContext(ctx). // Set the SSL context
|
||||
build();
|
||||
Connection nc = Nats.connect(options);
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
nc.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_tls_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/tls_samples.js#L44-56"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let caCert = fs.readFileSync(caCertPath);
|
||||
let clientCert = fs.readFileSync(clientCertPath);
|
||||
let clientKey = fs.readFileSync(clientKeyPath);
|
||||
let nc = NATS.connect({
|
||||
url: url,
|
||||
tls: {
|
||||
ca: [caCert],
|
||||
key: [clientKey],
|
||||
cert: [clientCert]
|
||||
}
|
||||
});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_tls_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/connect_tls.py#L7-20"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">nc = NATS()
|
||||
|
||||
ssl_ctx = ssl.create_default_context(purpose=ssl.Purpose.SERVER_AUTH)
|
||||
ssl_ctx.load_verify_locations('ca.pem')
|
||||
ssl_ctx.load_cert_chain(certfile='client-cert.pem',
|
||||
keyfile='client-key.pem')
|
||||
await nc.connect(io_loop=loop, tls=ssl_ctx)
|
||||
|
||||
await nc.connect(servers=["nats://demo.nats.io:4222"], tls=ssl_ctx)
|
||||
|
||||
# Do something with the connection.
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_tls_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/connect_tls.rb#L3-51"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby">EM.run do
|
||||
|
||||
options = {
|
||||
:servers => [
|
||||
'nats://localhost:4222',
|
||||
],
|
||||
:tls => {
|
||||
:private_key_file => './spec/configs/certs/key.pem',
|
||||
:cert_chain_file => './spec/configs/certs/server.pem'
|
||||
}
|
||||
}
|
||||
|
||||
NATS.connect(options) do |nc|
|
||||
puts "#{Time.now.to_f} - Connected to NATS at #{nc.connected_server}"
|
||||
|
||||
nc.subscribe("hello") do |msg|
|
||||
puts "#{Time.now.to_f} - Received: #{msg}"
|
||||
end
|
||||
|
||||
nc.flush do
|
||||
nc.publish("hello", "world")
|
||||
end
|
||||
|
||||
EM.add_periodic_timer(0.1) do
|
||||
next unless nc.connected?
|
||||
nc.publish("hello", "hello")
|
||||
end
|
||||
|
||||
# Set default callbacks
|
||||
nc.on_error do |e|
|
||||
puts "#{Time.now.to_f } - Error: #{e}"
|
||||
end
|
||||
|
||||
nc.on_disconnect do |reason|
|
||||
puts "#{Time.now.to_f} - Disconnected: #{reason}"
|
||||
end
|
||||
|
||||
nc.on_reconnect do |nc|
|
||||
puts "#{Time.now.to_f} - Reconnected to NATS server at #{nc.connected_server}"
|
||||
end
|
||||
|
||||
nc.on_close do
|
||||
puts "#{Time.now.to_f} - Connection to NATS closed"
|
||||
EM.stop
|
||||
end
|
||||
end
|
||||
end
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_tls_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/tls_samples.ts#L40-52"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let caCert = readFileSync(caCertPath);
|
||||
let clientCert = readFileSync(clientCertPath);
|
||||
let clientKey = readFileSync(clientKeyPath);
|
||||
let nc = await connect({
|
||||
url: url,
|
||||
tls: {
|
||||
ca: [caCert],
|
||||
key: [clientKey],
|
||||
cert: [clientCert]
|
||||
}
|
||||
});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
191
docs/developer/examples/connect_tls_url.html
Normal file
191
docs/developer/examples/connect_tls_url.html
Normal file
@ -0,0 +1,191 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="connect_tls_url_go" name="connect_tls_url" class="tab" checked>
|
||||
|
||||
<label for="connect_tls_url_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_tls_url_java" name="connect_tls_url" class="tab">
|
||||
|
||||
<label for="connect_tls_url_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_tls_url_js" name="connect_tls_url" class="tab">
|
||||
|
||||
<label for="connect_tls_url_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_tls_url_py" name="connect_tls_url" class="tab">
|
||||
|
||||
<label for="connect_tls_url_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_tls_url_ruby" name="connect_tls_url" class="tab">
|
||||
|
||||
<label for="connect_tls_url_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_tls_url_ts" name="connect_tls_url" class="tab">
|
||||
|
||||
<label for="connect_tls_url_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_tls_url_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/connect_tls_url/main.go#L10-21"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">nc, err := nats.Connect("localhost",
|
||||
nats.Secure(),
|
||||
nats.RootCAs("resources/certs/ca.pem")) // May need this if server is using self-signed certificate
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_tls_url_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/ConnectTLSURL.java#L18-80"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">class SSLUtils2 {
|
||||
public static String KEYSTORE_PATH = "src/main/resources/keystore.jks";
|
||||
public static String TRUSTSTORE_PATH = "src/main/resources/cacerts";
|
||||
public static String STORE_PASSWORD = "password";
|
||||
public static String KEY_PASSWORD = "password";
|
||||
public static String ALGORITHM = "SunX509";
|
||||
|
||||
public static KeyStore loadKeystore(String path) throws Exception {
|
||||
KeyStore store = KeyStore.getInstance("JKS");
|
||||
BufferedInputStream in = new BufferedInputStream(new FileInputStream(path));
|
||||
|
||||
try {
|
||||
store.load(in, STORE_PASSWORD.toCharArray());
|
||||
} finally {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
|
||||
return store;
|
||||
}
|
||||
|
||||
public static KeyManager[] createTestKeyManagers() throws Exception {
|
||||
KeyStore store = loadKeystore(KEYSTORE_PATH);
|
||||
KeyManagerFactory factory = KeyManagerFactory.getInstance(ALGORITHM);
|
||||
factory.init(store, KEY_PASSWORD.toCharArray());
|
||||
return factory.getKeyManagers();
|
||||
}
|
||||
|
||||
public static TrustManager[] createTestTrustManagers() throws Exception {
|
||||
KeyStore store = loadKeystore(TRUSTSTORE_PATH);
|
||||
TrustManagerFactory factory = TrustManagerFactory.getInstance(ALGORITHM);
|
||||
factory.init(store);
|
||||
return factory.getTrustManagers();
|
||||
}
|
||||
|
||||
public static SSLContext createSSLContext() throws Exception {
|
||||
SSLContext ctx = SSLContext.getInstance(Options.DEFAULT_SSL_PROTOCOL);
|
||||
ctx.init(createTestKeyManagers(), createTestTrustManagers(), new SecureRandom());
|
||||
return ctx;
|
||||
}
|
||||
}
|
||||
|
||||
public class ConnectTLSURL {
|
||||
public static void main(String[] args) {
|
||||
|
||||
try {
|
||||
SSLContext.setDefault(SSLUtils2.createSSLContext()); // Set the default context
|
||||
Options options = new Options.Builder().
|
||||
server("tls://localhost:4222"). // Use the TLS protocol
|
||||
build();
|
||||
Connection nc = Nats.connect(options);
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
nc.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_tls_url_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/tls_samples.js#L26-31"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let nc = NATS.connect({
|
||||
url: "tls://demo.nats.io:4443",
|
||||
tls: true
|
||||
});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_tls_url_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/connect_tls_url.py#L1-37"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">import asyncio
|
||||
import ssl
|
||||
import certifi
|
||||
from nats.aio.client import Client as NATS
|
||||
from nats.aio.errors import ErrTimeout
|
||||
|
||||
async def run(loop):
|
||||
nc = NATS()
|
||||
|
||||
# If using Python 3.7 in OS X and getting SSL errors, run first:
|
||||
#
|
||||
# /Applications/Python\ 3.7/Install\ Certificates.command
|
||||
#
|
||||
# Setting the tls as the scheme will use same defaults as `ssl.create_default_context()`
|
||||
#
|
||||
await nc.connect("tls://demo.nats.io:4443", loop=loop)
|
||||
|
||||
async def message_handler(msg):
|
||||
subject = msg.subject
|
||||
reply = msg.reply
|
||||
data = msg.data.decode()
|
||||
print("Received a message on '{subject} {reply}': {data}".format(
|
||||
subject=subject, reply=reply, data=data))
|
||||
|
||||
# Simple publisher and async subscriber via coroutine.
|
||||
sid = await nc.subscribe("foo", cb=message_handler)
|
||||
await nc.flush()
|
||||
|
||||
# Stop receiving after 2 messages.
|
||||
await nc.auto_unsubscribe(sid, 2)
|
||||
await nc.publish("foo", b'Hello')
|
||||
await nc.publish("foo", b'World')
|
||||
await nc.publish("foo", b'!!!!!')
|
||||
await asyncio.sleep(1, loop=loop)
|
||||
await nc.close()
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_tls_url_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/connect_tls_url.rb#L3-19"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby">EM.run do
|
||||
|
||||
# In order to use TLS with the Ruby NATS client, use the :tls option
|
||||
# when customizing the connection with an empty block.
|
||||
options = {
|
||||
:servers => [
|
||||
'nats://demo.nats.io:4443',
|
||||
],
|
||||
:tls => {}
|
||||
}
|
||||
|
||||
NATS.connect(options) do |nc|
|
||||
puts :connected
|
||||
end
|
||||
end
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_tls_url_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/tls_samples.ts#L26-33"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">// will throw an exception if connection fails
|
||||
let nc = await connect({
|
||||
url: "tls://demo.nats.io:4443"
|
||||
});
|
||||
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
89
docs/developer/examples/connect_token.html
Normal file
89
docs/developer/examples/connect_token.html
Normal file
@ -0,0 +1,89 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="connect_token_go" name="connect_token" class="tab" checked>
|
||||
|
||||
<label for="connect_token_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_token_java" name="connect_token" class="tab">
|
||||
|
||||
<label for="connect_token_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_token_js" name="connect_token" class="tab">
|
||||
|
||||
<label for="connect_token_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_token_py" name="connect_token" class="tab">
|
||||
|
||||
<label for="connect_token_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_token_ruby" name="connect_token" class="tab">
|
||||
|
||||
<label for="connect_token_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_token_ts" name="connect_token" class="tab">
|
||||
|
||||
<label for="connect_token_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_token_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/connect_token/main.go#L10-20"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">// Set a token
|
||||
nc, err := nats.Connect("localhost", nats.Token("mytoken"))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_token_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/ConnectToken.java#L11-21"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Options options = new Options.Builder().
|
||||
server("nats://localhost:4222").
|
||||
token("mytoken"). // Set a token
|
||||
build();
|
||||
Connection nc = Nats.connect(options);
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_token_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/auth_examples.js#L81-83"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let nc = NATS.connect({url: `nats://127.0.0.1:${port}`, token: "mytoken!"});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_token_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/connect_token.py#L6-13"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">nc = NATS()
|
||||
|
||||
await nc.connect(servers=["nats://mytoken@demo.nats.io:4222"])
|
||||
|
||||
# Do something with the connection.
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_token_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/connect_token.rb#L3-7"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby">NATS.start(token: "deadbeef") do |nc|
|
||||
puts "Connected using token"
|
||||
end
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_token_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/auth_examples.ts#L58-60"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let nc = await connect({url: server.nats, token: "mytoken"});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
87
docs/developer/examples/connect_token_url.html
Normal file
87
docs/developer/examples/connect_token_url.html
Normal file
@ -0,0 +1,87 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="connect_token_url_go" name="connect_token_url" class="tab" checked>
|
||||
|
||||
<label for="connect_token_url_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_token_url_java" name="connect_token_url" class="tab">
|
||||
|
||||
<label for="connect_token_url_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_token_url_js" name="connect_token_url" class="tab">
|
||||
|
||||
<label for="connect_token_url_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_token_url_py" name="connect_token_url" class="tab">
|
||||
|
||||
<label for="connect_token_url_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_token_url_ruby" name="connect_token_url" class="tab">
|
||||
|
||||
<label for="connect_token_url_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_token_url_ts" name="connect_token_url" class="tab">
|
||||
|
||||
<label for="connect_token_url_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_token_url_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/connect_token_url/main.go#L10-20"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">// Token in URL
|
||||
nc, err := nats.Connect("mytoken@localhost")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_token_url_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/ConnectTokenURL.java#L10-16"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Connection nc = Nats.connect("nats://mytoken@localhost:4222");//Token in URL
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_token_url_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/auth_examples.js#L63-66"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let url = `nats://mytoken!@127.0.0.1:${port}`;
|
||||
let nc = NATS.connect({url: url});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_token_url_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/connect_token_url.py#L6-13"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">nc = NATS()
|
||||
|
||||
await nc.connect(servers=["nats://mytoken@demo.nats.io:4222"])
|
||||
|
||||
# Do something with the connection.
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_token_url_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/connect_token_url.rb#L3-7"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby">NATS.start("deadbeef@127.0.0.1:4222") do |nc|
|
||||
puts "Connected using token!"
|
||||
end
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_token_url_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/auth_examples.ts#L47-50"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let url = `nats://:mytoken!@127.0.0.1:${port}`;
|
||||
let nc = await connect({url: url});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
108
docs/developer/examples/connect_url.html
Normal file
108
docs/developer/examples/connect_url.html
Normal file
@ -0,0 +1,108 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="connect_url_go" name="connect_url" class="tab" checked>
|
||||
|
||||
<label for="connect_url_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_url_java" name="connect_url" class="tab">
|
||||
|
||||
<label for="connect_url_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_url_js" name="connect_url" class="tab">
|
||||
|
||||
<label for="connect_url_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_url_py" name="connect_url" class="tab">
|
||||
|
||||
<label for="connect_url_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_url_ruby" name="connect_url" class="tab">
|
||||
|
||||
<label for="connect_url_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_url_ts" name="connect_url" class="tab">
|
||||
|
||||
<label for="connect_url_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_url_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/connect_url/main.go#L10-23"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">// If connecting to the default port, the URL can be simplified
|
||||
// to just the hostname/IP.
|
||||
// That is, the connect below is equivalent to:
|
||||
// nats.Connect("nats://demo.nats.io:4222")
|
||||
nc, err := nats.Connect("demo.nats.io")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_url_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/ConnectToServerURL.java#L10-16"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Connection nc = Nats.connect("nats://demo.nats.io:4222");
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_url_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/connection_samples.js#L45-56"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let nc = NATS.connect("nats://demo.nats.io:4222");
|
||||
nc.on('connect', (c) => {
|
||||
// Do something with the connection
|
||||
doSomething();
|
||||
// When done close it
|
||||
nc.close();
|
||||
});
|
||||
nc.on('error', (err) => {
|
||||
failed(err);
|
||||
});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_url_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/connect_url.py#L5-13"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">nc = NATS()
|
||||
await nc.connect(servers=["nats://demo.nats.io:4222"])
|
||||
|
||||
# Do something with the connection
|
||||
|
||||
await nc.close()
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_url_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/connect_url.rb#L1-10"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby">require 'nats/client'
|
||||
|
||||
NATS.start(servers: ["nats://demo.nats.io:4222"]) do |nc|
|
||||
# Do something with the connection
|
||||
|
||||
# Close the connection
|
||||
nc.close
|
||||
end
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_url_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/connection_samples.ts#L40-47"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">// will throw an exception if connection fails
|
||||
let nc = await connect("nats://demo.nats.io:4222");
|
||||
// Do something with the connection
|
||||
|
||||
// Close the connection
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
103
docs/developer/examples/connect_userpass.html
Normal file
103
docs/developer/examples/connect_userpass.html
Normal file
@ -0,0 +1,103 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="connect_userpass_go" name="connect_userpass" class="tab" checked>
|
||||
|
||||
<label for="connect_userpass_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_userpass_java" name="connect_userpass" class="tab">
|
||||
|
||||
<label for="connect_userpass_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_userpass_js" name="connect_userpass" class="tab">
|
||||
|
||||
<label for="connect_userpass_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_userpass_py" name="connect_userpass" class="tab">
|
||||
|
||||
<label for="connect_userpass_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_userpass_ruby" name="connect_userpass" class="tab">
|
||||
|
||||
<label for="connect_userpass_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_userpass_ts" name="connect_userpass" class="tab">
|
||||
|
||||
<label for="connect_userpass_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_userpass_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/connect_userpass/main.go#L10-20"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">// Set a user and plain text password
|
||||
nc, err := nats.Connect("localhost", nats.UserInfo("myname", "password"))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_userpass_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/ConnectUserPassword.java#L11-21"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Options options = new Options.Builder().
|
||||
server("nats://localhost:4222").
|
||||
userInfo("myname","password"). // Set a user and plain text password
|
||||
build();
|
||||
Connection nc = Nats.connect(options);
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_userpass_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/auth_examples.js#L19-21"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let nc = NATS.connect({url: server.nats, user: "myname", pass: "password"});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_userpass_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/connect_userpass.py#L6-13"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">nc = NATS()
|
||||
|
||||
await nc.connect(servers=["nats://myname:password@demo.nats.io:4222"])
|
||||
|
||||
# Do something with the connection.
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_userpass_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/connect_userpass.rb#L1-19"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby">require 'nats/client'
|
||||
|
||||
NATS.start(servers:["nats://myname:password@127.0.0.1:4222"], name: "my-connection") do |nc|
|
||||
nc.on_error do |e|
|
||||
puts "Error: #{e}"
|
||||
end
|
||||
|
||||
nc.on_reconnect do
|
||||
puts "Got reconnected to #{nc.connected_server}"
|
||||
end
|
||||
|
||||
nc.on_disconnect do |reason|
|
||||
puts "Got disconnected! #{reason}"
|
||||
end
|
||||
|
||||
nc.close
|
||||
end
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_userpass_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/auth_examples.ts#L21-23"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let nc = await connect({url: server.nats, user: "myname", pass: "password"});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
101
docs/developer/examples/connect_userpass_url.html
Normal file
101
docs/developer/examples/connect_userpass_url.html
Normal file
@ -0,0 +1,101 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="connect_userpass_url_go" name="connect_userpass_url" class="tab" checked>
|
||||
|
||||
<label for="connect_userpass_url_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_userpass_url_java" name="connect_userpass_url" class="tab">
|
||||
|
||||
<label for="connect_userpass_url_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_userpass_url_js" name="connect_userpass_url" class="tab">
|
||||
|
||||
<label for="connect_userpass_url_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_userpass_url_py" name="connect_userpass_url" class="tab">
|
||||
|
||||
<label for="connect_userpass_url_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_userpass_url_ruby" name="connect_userpass_url" class="tab">
|
||||
|
||||
<label for="connect_userpass_url_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_userpass_url_ts" name="connect_userpass_url" class="tab">
|
||||
|
||||
<label for="connect_userpass_url_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_userpass_url_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/connect_userpass_url/main.go#L10-20"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">// Set a user and plain text password
|
||||
nc, err := nats.Connect("myname:password@localhost")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_userpass_url_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/ConnectUserPasswordURL.java#L10-16"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Connection nc = Nats.connect("nats://myname:password@localhost:4222");
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_userpass_url_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/auth_examples.js#L40-43"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let url = `nats://myname:password@127.0.0.1:${port}`;
|
||||
let nc = NATS.connect(url);
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_userpass_url_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/connect_userpass_url.py#L6-13"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">nc = NATS()
|
||||
|
||||
await nc.connect(servers=["nats://myname:password@demo.nats.io:4222"])
|
||||
|
||||
# Do something with the connection.
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_userpass_url_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/connect_userpass_url.rb#L1-19"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby">require 'nats/client'
|
||||
|
||||
NATS.start(servers:["nats://myname:password@127.0.0.1:4222"], name: "my-connection") do |nc|
|
||||
nc.on_error do |e|
|
||||
puts "Error: #{e}"
|
||||
end
|
||||
|
||||
nc.on_reconnect do
|
||||
puts "Got reconnected to #{nc.connected_server}"
|
||||
end
|
||||
|
||||
nc.on_disconnect do |reason|
|
||||
puts "Got disconnected! #{reason}"
|
||||
end
|
||||
|
||||
nc.close
|
||||
end
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_userpass_url_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/auth_examples.ts#L34-37"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let url = `nats://myname:password@127.0.0.1:${port}`;
|
||||
let nc = await connect({url: url});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
112
docs/developer/examples/connect_verbose.html
Normal file
112
docs/developer/examples/connect_verbose.html
Normal file
@ -0,0 +1,112 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="connect_verbose_go" name="connect_verbose" class="tab" checked>
|
||||
|
||||
<label for="connect_verbose_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_verbose_java" name="connect_verbose" class="tab">
|
||||
|
||||
<label for="connect_verbose_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_verbose_js" name="connect_verbose" class="tab">
|
||||
|
||||
<label for="connect_verbose_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_verbose_py" name="connect_verbose" class="tab">
|
||||
|
||||
<label for="connect_verbose_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_verbose_ruby" name="connect_verbose" class="tab">
|
||||
|
||||
<label for="connect_verbose_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="connect_verbose_ts" name="connect_verbose" class="tab">
|
||||
|
||||
<label for="connect_verbose_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_verbose_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/connect_verbose/main.go#L10-23"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">opts := nats.GetDefaultOptions()
|
||||
opts.Url = "demo.nats.io"
|
||||
// Turn on Verbose
|
||||
opts.Verbose = true
|
||||
nc, err := opts.Connect()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_verbose_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/ConnectVerbose.java#L11-21"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Options options = new Options.Builder().
|
||||
server("nats://demo.nats.io:4222").
|
||||
verbose(). // Turn on verbose
|
||||
build();
|
||||
Connection nc = Nats.connect(options);
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_verbose_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/options_samples.js#L56-62"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let nc = NATS.connect({
|
||||
url: "nats://demo.nats.io:4222",
|
||||
verbose: true
|
||||
});
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_verbose_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/connect_verbose.py#L6-13"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">nc = NATS()
|
||||
|
||||
await nc.connect(servers=["nats://demo.nats.io:4222"], verbose=True)
|
||||
|
||||
# Do something with the connection.
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_verbose_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/connect_verbose.rb#L1-15"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby">require 'nats/client'
|
||||
|
||||
NATS.start(verbose: true) do |nc|
|
||||
nc.on_reconnect do
|
||||
puts "Got reconnected to #{nc.connected_server}"
|
||||
end
|
||||
|
||||
nc.on_disconnect do |reason|
|
||||
puts "Got disconnected! #{reason}"
|
||||
end
|
||||
|
||||
nc.close
|
||||
end
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connect_verbose_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/options_samples.ts#L42-50"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">// will throw an exception if connection fails
|
||||
let nc = await connect({
|
||||
url: "nats://demo.nats.io:4222",
|
||||
verbose: true
|
||||
});
|
||||
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
178
docs/developer/examples/connection_listener.html
Normal file
178
docs/developer/examples/connection_listener.html
Normal file
@ -0,0 +1,178 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="connection_listener_go" name="connection_listener" class="tab" checked>
|
||||
|
||||
<label for="connection_listener_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="connection_listener_java" name="connection_listener" class="tab">
|
||||
|
||||
<label for="connection_listener_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="connection_listener_js" name="connection_listener" class="tab">
|
||||
|
||||
<label for="connection_listener_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="connection_listener_py" name="connection_listener" class="tab">
|
||||
|
||||
<label for="connection_listener_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="connection_listener_ruby" name="connection_listener" class="tab">
|
||||
|
||||
<label for="connection_listener_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="connection_listener_ts" name="connection_listener" class="tab">
|
||||
|
||||
<label for="connection_listener_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connection_listener_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/notapplicable.txt#L5-14"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">// There is not a single listener for connection events in the NATS Go Client.
|
||||
// Instead, you can set individual event handlers using:
|
||||
|
||||
DisconnectHandler(cb ConnHandler)
|
||||
ReconnectHandler(cb ConnHandler)
|
||||
ClosedHandler(cb ConnHandler)
|
||||
DiscoveredServersHandler(cb ConnHandler)
|
||||
ErrorHandler(cb ErrHandler)
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connection_listener_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/SetConnectionListener.java#L8-33"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">class MyConnectionListener implements ConnectionListener {
|
||||
public void connectionEvent(Connection natsConnection, Events event) {
|
||||
System.out.println("Connection event - "+event);
|
||||
}
|
||||
}
|
||||
|
||||
public class SetConnectionListener {
|
||||
public static void main(String[] args) {
|
||||
|
||||
try {
|
||||
Options options = new Options.Builder().
|
||||
server("nats://demo.nats.io:4222").
|
||||
connectionListener(new MyConnectionListener()). // Set the listener
|
||||
build();
|
||||
Connection nc = Nats.connect(options);
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
nc.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connection_listener_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/event_samples.js#L11-41"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let nc = NATS.connect("nats://demo.nats.io:4222");
|
||||
|
||||
nc.on('error', (err) => {
|
||||
t.log('error', err);
|
||||
});
|
||||
|
||||
nc.on('connect', () => {
|
||||
t.log('client connected');
|
||||
});
|
||||
|
||||
nc.on('disconnect', () => {
|
||||
t.log('client disconnected');
|
||||
});
|
||||
|
||||
nc.on('reconnecting', () => {
|
||||
t.log('client reconnecting');
|
||||
});
|
||||
|
||||
nc.on('reconnect', () => {
|
||||
t.log('client reconnected');
|
||||
});
|
||||
|
||||
nc.on('close', () => {
|
||||
t.log('client closed');
|
||||
});
|
||||
|
||||
nc.on('permission_error', (err) => {
|
||||
t.log('permission_error', err);
|
||||
});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connection_listener_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/notapplicable.txt#L17-42"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python"># Asyncio NATS client can be defined a number of event callbacks
|
||||
async def disconnected_cb():
|
||||
print("Got disconnected!")
|
||||
|
||||
async def reconnected_cb():
|
||||
# See who we are connected to on reconnect.
|
||||
print("Got reconnected to {url}".format(url=nc.connected_url.netloc))
|
||||
|
||||
async def error_cb(e):
|
||||
print("There was an error: {}".format(e))
|
||||
|
||||
async def closed_cb():
|
||||
print("Connection is closed")
|
||||
|
||||
# Setup callbacks to be notified on disconnects and reconnects
|
||||
options["disconnected_cb"] = disconnected_cb
|
||||
options["reconnected_cb"] = reconnected_cb
|
||||
|
||||
# Setup callbacks to be notified when there is an error
|
||||
# or connection is closed.
|
||||
options["error_cb"] = error_cb
|
||||
options["closed_cb"] = closed_cb
|
||||
|
||||
await nc.connect(**options)
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connection_listener_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/notapplicable.txt#L29-44"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby"># There is not a single listener for connection events in the Ruby NATS Client.
|
||||
# Instead, you can set individual event handlers using:
|
||||
|
||||
NATS.on_disconnect do
|
||||
end
|
||||
|
||||
NATS.on_reconnect do
|
||||
end
|
||||
|
||||
NATS.on_close do
|
||||
end
|
||||
|
||||
NATS.on_error do
|
||||
end
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="connection_listener_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/event_samples.ts#L7-27"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">// connect will happen once - the first connect
|
||||
nc.on('connect', (nc) => {
|
||||
// nc is the connection that connected
|
||||
t.log('client connected');
|
||||
});
|
||||
|
||||
nc.on('disconnect', (url) => {
|
||||
// nc is the connection that reconnected
|
||||
t.log('disconnected from', url);
|
||||
});
|
||||
|
||||
nc.on('reconnecting', (url) => {
|
||||
t.log('reconnecting to', url);
|
||||
});
|
||||
|
||||
nc.on('reconnect', (nc, url) => {
|
||||
// nc is the connection that reconnected
|
||||
t.log('reconnected to', url);
|
||||
});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
79
docs/developer/examples/control_2k.html
Normal file
79
docs/developer/examples/control_2k.html
Normal file
@ -0,0 +1,79 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="control_2k_go" name="control_2k" class="tab" checked>
|
||||
|
||||
<label for="control_2k_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="control_2k_java" name="control_2k" class="tab">
|
||||
|
||||
<label for="control_2k_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="control_2k_js" name="control_2k" class="tab">
|
||||
|
||||
<label for="control_2k_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="control_2k_py" name="control_2k" class="tab">
|
||||
|
||||
<label for="control_2k_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="control_2k_ruby" name="control_2k" class="tab">
|
||||
|
||||
<label for="control_2k_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="control_2k_ts" name="control_2k" class="tab">
|
||||
|
||||
<label for="control_2k_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="control_2k_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/notapplicable.txt#L1-3"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">// This does not apply to the NATS Go Client
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="control_2k_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/ConnectControl2k.java#L11-21"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Options options = new Options.Builder().
|
||||
server("nats://demo.nats.io:4222").
|
||||
maxControlLine(2 * 1024). // Set the max control line to 2k
|
||||
build();
|
||||
Connection nc = Nats.connect(options);
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="control_2k_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/options_samples.js#L90-97"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">// set this option before creating a connection
|
||||
NATS.MAX_CONTROL_LINE_SIZE = 1024*2;
|
||||
let nc = NATS.connect({
|
||||
url: "nats://demo.nats.io:4222"
|
||||
});
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="control_2k_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/notapplicable.txt#L5-7"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python"># Asyncio NATS client does not allow custom control lines
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="control_2k_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/notapplicable.txt#L5-7"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby"># There is no need to customize this in the Ruby NATS client.
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="control_2k_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/options_samples.ts#L68-70"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">// control line size is not configurable on ts-nats
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
185
docs/developer/examples/drain_conn.html
Normal file
185
docs/developer/examples/drain_conn.html
Normal file
@ -0,0 +1,185 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="drain_conn_go" name="drain_conn" class="tab" checked>
|
||||
|
||||
<label for="drain_conn_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="drain_conn_java" name="drain_conn" class="tab">
|
||||
|
||||
<label for="drain_conn_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="drain_conn_py" name="drain_conn" class="tab">
|
||||
|
||||
<label for="drain_conn_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="drain_conn_ruby" name="drain_conn" class="tab">
|
||||
|
||||
<label for="drain_conn_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="drain_conn_ts" name="drain_conn" class="tab">
|
||||
|
||||
<label for="drain_conn_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="drain_conn_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/drain_conn/main.go#L12-61"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">wg := sync.WaitGroup{}
|
||||
wg.Add(1)
|
||||
|
||||
errCh := make(chan error, 1)
|
||||
|
||||
// To simulate a timeout, you would set the DrainTimeout()
|
||||
// to a value less than the time spent in the message callback,
|
||||
// so say: nats.DrainTimeout(10*time.Millisecond).
|
||||
|
||||
nc, err := nats.Connect("demo.nats.io",
|
||||
nats.DrainTimeout(10*time.Second),
|
||||
nats.ErrorHandler(func(_ *nats.Conn, _ *nats.Subscription, err error) {
|
||||
errCh <- err
|
||||
}),
|
||||
nats.ClosedHandler(func(_ *nats.Conn) {
|
||||
wg.Done()
|
||||
}))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Subscribe, but add some delay while processing.
|
||||
if _, err := nc.Subscribe("foo", func(_ *nats.Msg) {
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
}); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Publish a message
|
||||
if err := nc.Publish("foo", []byte("hello")); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Drain the connection, which will close it when done.
|
||||
if err := nc.Drain(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Wait for the connection to be closed.
|
||||
wg.Wait()
|
||||
|
||||
// Check if there was an error
|
||||
select {
|
||||
case e := <-errCh:
|
||||
log.Fatal(e)
|
||||
default:
|
||||
}
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="drain_conn_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/DrainConn.java#L16-40"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Connection nc = Nats.connect("nats://demo.nats.io:4222");
|
||||
|
||||
// Use a latch to wait for a message to arrive
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
|
||||
// Create a dispatcher and inline message handler
|
||||
Dispatcher d = nc.createDispatcher((msg) -> {
|
||||
String str = new String(msg.getData(), StandardCharsets.UTF_8);
|
||||
System.out.println(str);
|
||||
latch.countDown();
|
||||
});
|
||||
|
||||
// Subscribe
|
||||
d.subscribe("updates");
|
||||
|
||||
// Wait for a message to come in
|
||||
latch.await();
|
||||
|
||||
// Drain the connection, which will close it
|
||||
CompletableFuture<Boolean> drained = nc.drain(Duration.ofSeconds(10));
|
||||
|
||||
// Wait for the drain to complete
|
||||
drained.get();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="drain_conn_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/drain_conn.py#L1-34"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">import asyncio
|
||||
from nats.aio.client import Client as NATS
|
||||
|
||||
async def example(loop):
|
||||
nc = NATS()
|
||||
|
||||
await nc.connect("nats://127.0.0.1:4222", loop=loop)
|
||||
|
||||
async def handler(msg):
|
||||
print("[Received] ", msg)
|
||||
await nc.publish(msg.reply, b'I can help')
|
||||
|
||||
# Can check whether client is in draining state
|
||||
if nc.is_draining:
|
||||
print("Connection is draining")
|
||||
|
||||
await nc.subscribe("help", "workers", cb=handler)
|
||||
await nc.flush()
|
||||
|
||||
requests = []
|
||||
for i in range(0, 10):
|
||||
request = nc.request("help", b'help!', timeout=1)
|
||||
requests.append(request)
|
||||
|
||||
# Wait for all the responses
|
||||
responses = []
|
||||
responses = await asyncio.gather(*requests)
|
||||
|
||||
# Gracefully close the connection.
|
||||
await nc.drain()
|
||||
|
||||
print("Received {} responses".format(len(responses)))
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="drain_conn_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/drain_conn.rb#L3-26"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby">NATS.start(drain_timeout: 1) do |nc|
|
||||
NATS.subscribe('foo', queue: "workers") do |msg, reply, sub|
|
||||
nc.publish(reply, "ACK:#{msg}")
|
||||
end
|
||||
|
||||
NATS.subscribe('bar', queue: "workers") do |msg, reply, sub|
|
||||
nc.publish(reply, "ACK:#{msg}")
|
||||
end
|
||||
|
||||
NATS.subscribe('quux', queue: "workers") do |msg, reply, sub|
|
||||
nc.publish(reply, "ACK:#{msg}")
|
||||
end
|
||||
|
||||
EM.add_timer(2) do
|
||||
next if NATS.draining?
|
||||
|
||||
# Drain gracefully closes the connection.
|
||||
NATS.drain do
|
||||
puts "Done draining. Connection is closed."
|
||||
end
|
||||
end
|
||||
end
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="drain_conn_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/connection_samples.ts#L73-83"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let sub = await nc.subscribe('updates', (err, msg) => {
|
||||
t.log('worker got message', msg.data);
|
||||
}, {queue: "workers"});
|
||||
// [end drain_sub]
|
||||
nc.flush();
|
||||
|
||||
await nc.drain();
|
||||
// client must close when the connection drain resolves
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
166
docs/developer/examples/drain_sub.html
Normal file
166
docs/developer/examples/drain_sub.html
Normal file
@ -0,0 +1,166 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="drain_sub_go" name="drain_sub" class="tab" checked>
|
||||
|
||||
<label for="drain_sub_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="drain_sub_java" name="drain_sub" class="tab">
|
||||
|
||||
<label for="drain_sub_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="drain_sub_js" name="drain_sub" class="tab">
|
||||
|
||||
<label for="drain_sub_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="drain_sub_py" name="drain_sub" class="tab">
|
||||
|
||||
<label for="drain_sub_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="drain_sub_ruby" name="drain_sub" class="tab">
|
||||
|
||||
<label for="drain_sub_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="drain_sub_ts" name="drain_sub" class="tab">
|
||||
|
||||
<label for="drain_sub_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="drain_sub_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/drain_sub/main.go#L13-67"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">
|
||||
nc, err := nats.Connect("demo.nats.io")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
done := sync.WaitGroup{}
|
||||
done.Add(1)
|
||||
|
||||
count := 0
|
||||
errCh := make(chan error, 1)
|
||||
|
||||
msgAfterDrain := "not this one"
|
||||
|
||||
// This callback will process each message slowly
|
||||
sub, err := nc.Subscribe("updates", func(m *nats.Msg) {
|
||||
if string(m.Data) == msgAfterDrain {
|
||||
errCh <- fmt.Errorf("Should not have received this message")
|
||||
return
|
||||
}
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
count++
|
||||
if count == 2 {
|
||||
done.Done()
|
||||
}
|
||||
})
|
||||
|
||||
// Send 2 messages
|
||||
for i := 0; i < 2; i++ {
|
||||
nc.Publish("updates", []byte("hello"))
|
||||
}
|
||||
|
||||
// Call Drain on the subscription. It unsubscribes but
|
||||
// wait for all pending messages to be processed.
|
||||
if err := sub.Drain(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Send one more message, this message should not be received
|
||||
nc.Publish("updates", []byte(msgAfterDrain))
|
||||
|
||||
// Wait for the subscription to have processed the 2 messages.
|
||||
done.Wait()
|
||||
|
||||
// Now check that the 3rd message was not received
|
||||
select {
|
||||
case e := <-errCh:
|
||||
log.Fatal(e)
|
||||
case <-time.After(200 * time.Millisecond):
|
||||
// OK!
|
||||
}
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="drain_sub_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/DrainSub.java#L16-43"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Connection nc = Nats.connect("nats://demo.nats.io:4222");
|
||||
|
||||
// Use a latch to wait for a message to arrive
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
|
||||
// Create a dispatcher and inline message handler
|
||||
Dispatcher d = nc.createDispatcher((msg) -> {
|
||||
String str = new String(msg.getData(), StandardCharsets.UTF_8);
|
||||
System.out.println(str);
|
||||
latch.countDown();
|
||||
});
|
||||
|
||||
// Subscribe
|
||||
d.subscribe("updates");
|
||||
|
||||
// Wait for a message to come in
|
||||
latch.await();
|
||||
|
||||
// Messages that have arrived will be processed
|
||||
CompletableFuture<Boolean> drained = d.drain(Duration.ofSeconds(10));
|
||||
|
||||
// Wait for the drain to complete
|
||||
drained.get();
|
||||
|
||||
// Close the connection
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="drain_sub_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/subscriber_samples.js#L232-234"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">// Drain subscription is not supported.
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="drain_sub_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/drain_sub.py#L1-24"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">import asyncio
|
||||
from nats.aio.client import Client as NATS
|
||||
|
||||
async def example(loop):
|
||||
nc = NATS()
|
||||
|
||||
await nc.connect("nats://127.0.0.1:4222", loop=loop)
|
||||
|
||||
async def handler(msg):
|
||||
print("[Received] ", msg)
|
||||
await nc.publish(msg.reply, b'I can help')
|
||||
|
||||
# Can check whether client is in draining state
|
||||
if nc.is_draining:
|
||||
print("Connection is draining")
|
||||
|
||||
sid = await nc.subscribe("help", "workers", cb=handler)
|
||||
await nc.flush()
|
||||
|
||||
# Gracefully unsubscribe the subscription
|
||||
await nc.drain(sid)
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="drain_sub_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/notapplicable.txt#L9-11"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby"># There is currently no API to drain a single subscription, the whole connection can be drained though via NATS.drain
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="drain_sub_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/subscriber_samples.ts#L208-212"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let sub = await nc.subscribe('updates', (err, msg) => {
|
||||
t.log('worker got message', msg.data);
|
||||
}, {queue: "workers"});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
139
docs/developer/examples/error_listener.html
Normal file
139
docs/developer/examples/error_listener.html
Normal file
@ -0,0 +1,139 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="error_listener_go" name="error_listener" class="tab" checked>
|
||||
|
||||
<label for="error_listener_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="error_listener_java" name="error_listener" class="tab">
|
||||
|
||||
<label for="error_listener_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="error_listener_js" name="error_listener" class="tab">
|
||||
|
||||
<label for="error_listener_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="error_listener_py" name="error_listener" class="tab">
|
||||
|
||||
<label for="error_listener_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="error_listener_ruby" name="error_listener" class="tab">
|
||||
|
||||
<label for="error_listener_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="error_listener_ts" name="error_listener" class="tab">
|
||||
|
||||
<label for="error_listener_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="error_listener_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/error_listener/main.go#L10-23"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">// Set the callback that will be invoked when an asynchronous error occurs.
|
||||
nc, err := nats.Connect("demo.nats.io",
|
||||
nats.ErrorHandler(func(nc *nats.Conn, sub *nats.Subscription, err error) {
|
||||
log.Printf("Error: %v", err)
|
||||
}))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="error_listener_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/SetErrorListener.java#L9-43"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">class MyErrorListener implements ErrorListener {
|
||||
public void errorOccurred(Connection conn, String error)
|
||||
{
|
||||
System.out.println("The server notificed the client with: "+error);
|
||||
}
|
||||
|
||||
public void exceptionOccurred(Connection conn, Exception exp) {
|
||||
System.out.println("The connection handled an exception: "+exp.getLocalizedMessage());
|
||||
}
|
||||
|
||||
public void slowConsumerDetected(Connection conn, Consumer consumer) {
|
||||
System.out.println("A slow consumer was detected.");
|
||||
}
|
||||
}
|
||||
|
||||
public class SetErrorListener {
|
||||
public static void main(String[] args) {
|
||||
|
||||
try {
|
||||
Options options = new Options.Builder().
|
||||
server("nats://demo.nats.io:4222").
|
||||
errorListener(new MyErrorListener()). // Set the listener
|
||||
build();
|
||||
Connection nc = Nats.connect(options);
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
nc.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="error_listener_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/event_samples.js#L76-84"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let nc = NATS.connect("nats://demo.nats.io:4222");
|
||||
|
||||
// on node you *must* register an error listener. If not registered
|
||||
// the library emits an 'error' event, the node process will exit.
|
||||
nc.on('error', (err) => {
|
||||
t.log('client got an error:', err);
|
||||
});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="error_listener_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/error_listener.py#L6-20"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">nc = NATS()
|
||||
|
||||
async def error_cb(e):
|
||||
print("Error: ", e)
|
||||
|
||||
await nc.connect(
|
||||
servers=["nats://demo.nats.io:4222"],
|
||||
reconnect_time_wait=10,
|
||||
error_cb=error_cb,
|
||||
)
|
||||
|
||||
# Do something with the connection.
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="error_listener_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/error_listener.rb#L1-11"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby">require 'nats/client'
|
||||
|
||||
NATS.start(servers:["nats://demo.nats.io:4222"]) do |nc|
|
||||
nc.on_error do |e|
|
||||
puts "Error: #{e}"
|
||||
end
|
||||
|
||||
nc.close
|
||||
end
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="error_listener_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/event_samples.ts#L48-54"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">// on node you *must* register an error listener. If not registered
|
||||
// the library emits an 'error' event, the node process will exit.
|
||||
nc.on('error', (err) => {
|
||||
t.log('client got an out of band error:', err);
|
||||
});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
132
docs/developer/examples/flush.html
Normal file
132
docs/developer/examples/flush.html
Normal file
@ -0,0 +1,132 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="flush_go" name="flush" class="tab" checked>
|
||||
|
||||
<label for="flush_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="flush_java" name="flush" class="tab">
|
||||
|
||||
<label for="flush_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="flush_js" name="flush" class="tab">
|
||||
|
||||
<label for="flush_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="flush_py" name="flush" class="tab">
|
||||
|
||||
<label for="flush_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="flush_ruby" name="flush" class="tab">
|
||||
|
||||
<label for="flush_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="flush_ts" name="flush" class="tab">
|
||||
|
||||
<label for="flush_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="flush_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/flush/main.go#L11-26"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">nc, err := nats.Connect("demo.nats.io")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
if err := nc.Publish("updates", []byte("All is Well")); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
// Sends a PING and wait for a PONG from the server, up to the given timeout.
|
||||
// This gives guarantee that the server has processed above message.
|
||||
if err := nc.FlushTimeout(time.Second); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="flush_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/Flush.java#L13-20"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Connection nc = Nats.connect("nats://demo.nats.io:4222");
|
||||
|
||||
nc.publish("updates", "All is Well".getBytes(StandardCharsets.UTF_8));
|
||||
nc.flush(Duration.ofSeconds(1)); // Flush the message queue
|
||||
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="flush_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/publisher_samples.js#L93-103"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let nc = NATS.connect({url: "nats://demo.nats.io:4222"});
|
||||
let start = Date.now();
|
||||
nc.flush(() => {
|
||||
t.log('round trip completed in', Date.now() - start, 'ms');
|
||||
});
|
||||
|
||||
nc.publish('foo');
|
||||
// function in flush is optional
|
||||
nc.flush();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="flush_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/flush.py#L6-17"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">nc = NATS()
|
||||
|
||||
await nc.connect(servers=["nats://demo.nats.io:4222"])
|
||||
|
||||
await nc.publish("updates", b'All is Well')
|
||||
|
||||
# Sends a PING and wait for a PONG from the server, up to the given timeout.
|
||||
# This gives guarantee that the server has processed above message.
|
||||
await nc.flush(timeout=1)
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="flush_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/flush.rb#L1-18"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby">require 'nats/client'
|
||||
require 'fiber'
|
||||
|
||||
NATS.start(servers:["nats://127.0.0.1:4222"]) do |nc|
|
||||
nc.subscribe("updates") do |msg|
|
||||
puts msg
|
||||
end
|
||||
|
||||
nc.publish("updates", "All is Well")
|
||||
|
||||
nc.flush do
|
||||
# Sends a PING and wait for a PONG from the server, up to the given timeout.
|
||||
# This gives guarantee that the server has processed above message at this point.
|
||||
end
|
||||
end
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="flush_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/publisher_samples.ts#L90-108"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let nc = await connect({
|
||||
url: "nats://demo.nats.io:4222"
|
||||
});
|
||||
|
||||
// you can use flush to trigger a function in your
|
||||
// application once the round-trip to the server finishes
|
||||
let start = Date.now();
|
||||
nc.flush(() => {
|
||||
t.log('round trip completed in', Date.now() - start, 'ms');
|
||||
});
|
||||
|
||||
nc.publish('foo');
|
||||
|
||||
// another way, simply wait for the promise to resolve
|
||||
await nc.flush();
|
||||
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
115
docs/developer/examples/max_payload.html
Normal file
115
docs/developer/examples/max_payload.html
Normal file
@ -0,0 +1,115 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="max_payload_go" name="max_payload" class="tab" checked>
|
||||
|
||||
<label for="max_payload_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="max_payload_java" name="max_payload" class="tab">
|
||||
|
||||
<label for="max_payload_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="max_payload_js" name="max_payload" class="tab">
|
||||
|
||||
<label for="max_payload_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="max_payload_py" name="max_payload" class="tab">
|
||||
|
||||
<label for="max_payload_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="max_payload_ruby" name="max_payload" class="tab">
|
||||
|
||||
<label for="max_payload_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="max_payload_ts" name="max_payload" class="tab">
|
||||
|
||||
<label for="max_payload_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="max_payload_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/max_payload/main.go#L10-22"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">nc, err := nats.Connect("demo.nats.io")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
mp := nc.MaxPayload()
|
||||
log.Printf("Maximum payload is %v bytes", mp)
|
||||
|
||||
// Do something with the max payload
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="max_payload_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/GetMaxPayload.java#L10-17"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Connection nc = Nats.connect("nats://demo.nats.io:4222");
|
||||
|
||||
long max = nc.getMaxPayload();
|
||||
// Do something with the max payload
|
||||
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="max_payload_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/event_samples.js#L128-139"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let nc = NATS.connect("nats://demo.nats.io:4222");
|
||||
|
||||
// on node you *must* register an error listener. If not registered
|
||||
// the library emits an 'error' event, the node process will exit.
|
||||
nc.on('error', (err) => {
|
||||
t.log('client got an error:', err);
|
||||
});
|
||||
nc.on('connect', () => {
|
||||
t.log(nc.info.max_payload);
|
||||
});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="max_payload_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/max_payload.py#L6-15"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">nc = NATS()
|
||||
|
||||
await nc.connect(servers=["nats://demo.nats.io:4222"])
|
||||
|
||||
print("Maximum payload is %d bytes" % nc.max_payload)
|
||||
|
||||
# Do something with the max payload.
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="max_payload_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/max_payload.rb#L1-16"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby">require 'nats/client'
|
||||
|
||||
NATS.start(max_outstanding_pings: 5) do |nc|
|
||||
nc.on_reconnect do
|
||||
puts "Got reconnected to #{nc.connected_server}"
|
||||
end
|
||||
|
||||
nc.on_disconnect do |reason|
|
||||
puts "Got disconnected! #{reason}"
|
||||
end
|
||||
|
||||
# Do something with the max_payload
|
||||
puts "Maximum Payload is #{nc.server_info[:max_payload]} bytes"
|
||||
end
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="max_payload_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/event_samples.ts#L76-83"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">// connect will happen once - the first connect
|
||||
nc.on('connect', (nc: Client, url: string, options: ServerInfo) => {
|
||||
// nc is the connection that connected
|
||||
t.log('client connected to', url);
|
||||
t.log('max_payload', options.max_payload);
|
||||
});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
105
docs/developer/examples/no_echo.html
Normal file
105
docs/developer/examples/no_echo.html
Normal file
@ -0,0 +1,105 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="no_echo_go" name="no_echo" class="tab" checked>
|
||||
|
||||
<label for="no_echo_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="no_echo_java" name="no_echo" class="tab">
|
||||
|
||||
<label for="no_echo_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="no_echo_js" name="no_echo" class="tab">
|
||||
|
||||
<label for="no_echo_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="no_echo_py" name="no_echo" class="tab">
|
||||
|
||||
<label for="no_echo_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="no_echo_ruby" name="no_echo" class="tab">
|
||||
|
||||
<label for="no_echo_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="no_echo_ts" name="no_echo" class="tab">
|
||||
|
||||
<label for="no_echo_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="no_echo_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/no_echo/main.go#L10-20"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">// Turn off echo
|
||||
nc, err := nats.Connect("demo.nats.io", nats.NoEcho())
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="no_echo_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/ConnectNoEcho.java#L11-21"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Options options = new Options.Builder().
|
||||
server("nats://demo.nats.io:4222").
|
||||
noEcho(). // Turn off echo
|
||||
build();
|
||||
Connection nc = Nats.connect(options);
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="no_echo_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/subscriber_samples.js#L239-241"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">// no_echo is not supported.
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="no_echo_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/no_echo.py#L5-27"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">ncA = NATS()
|
||||
ncB = NATS()
|
||||
|
||||
await ncA.connect(no_echo=True)
|
||||
await ncB.connect()
|
||||
|
||||
async def handler(msg):
|
||||
# Messages sent by `ncA' will not be received.
|
||||
print("[Received] ", msg)
|
||||
|
||||
await ncA.subscribe("greetings", cb=handler)
|
||||
await ncA.flush()
|
||||
await ncA.publish("greetings", b'Hello World!')
|
||||
await ncB.publish("greetings", b'Hello World!')
|
||||
|
||||
# Do something with the connection
|
||||
|
||||
await asyncio.sleep(1)
|
||||
await ncA.drain()
|
||||
await ncB.drain()
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="no_echo_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/no_echo.rb#L3-7"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby">NATS.start("nats://demo.nats.io:4222", no_echo: true) do |nc|
|
||||
# ...
|
||||
end
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="no_echo_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/subscriber_samples.ts#L222-225"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let nc = await connect({
|
||||
url: "nats://demo.nats.io:4222", noEcho: true});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
111
docs/developer/examples/ping_20s.html
Normal file
111
docs/developer/examples/ping_20s.html
Normal file
@ -0,0 +1,111 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="ping_20s_go" name="ping_20s" class="tab" checked>
|
||||
|
||||
<label for="ping_20s_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="ping_20s_java" name="ping_20s" class="tab">
|
||||
|
||||
<label for="ping_20s_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="ping_20s_js" name="ping_20s" class="tab">
|
||||
|
||||
<label for="ping_20s_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="ping_20s_py" name="ping_20s" class="tab">
|
||||
|
||||
<label for="ping_20s_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="ping_20s_ruby" name="ping_20s" class="tab">
|
||||
|
||||
<label for="ping_20s_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="ping_20s_ts" name="ping_20s" class="tab">
|
||||
|
||||
<label for="ping_20s_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="ping_20s_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/ping_20s/main.go#L11-21"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">// Set Ping Interval to 20 seconds
|
||||
nc, err := nats.Connect("demo.nats.io", nats.PingInterval(20*time.Second))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="ping_20s_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/ConnectPingTwenty.java#L13-23"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Options options = new Options.Builder().
|
||||
server("nats://demo.nats.io:4222").
|
||||
pingInterval(Duration.ofSeconds(20)). // Set Ping Interval
|
||||
build();
|
||||
Connection nc = Nats.connect(options);
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="ping_20s_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/options_samples.js#L7-12"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let nc = NATS.connect({
|
||||
pingInterval: 20*1000, //20s
|
||||
url: "nats://demo.nats.io:4222"
|
||||
});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="ping_20s_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/ping_20s.py#L6-17"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">nc = NATS()
|
||||
|
||||
await nc.connect(
|
||||
servers=["nats://demo.nats.io:4222"],
|
||||
# Set Ping Interval to 20 seconds
|
||||
ping_interval=20,
|
||||
)
|
||||
|
||||
# Do something with the connection.
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="ping_20s_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/ping_20s.rb#L1-15"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby">require 'nats/client'
|
||||
|
||||
NATS.start(ping_interval: 20) do |nc|
|
||||
nc.on_reconnect do
|
||||
puts "Got reconnected to #{nc.connected_server}"
|
||||
end
|
||||
|
||||
nc.on_disconnect do |reason|
|
||||
puts "Got disconnected! #{reason}"
|
||||
end
|
||||
|
||||
# Do something with the connection
|
||||
end
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="ping_20s_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/options_samples.ts#L5-12"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">// will throw an exception if connection fails
|
||||
let nc = await connect({
|
||||
pingInterval: 20*2000, //20s
|
||||
url: "nats://demo.nats.io:4222"
|
||||
});
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
118
docs/developer/examples/ping_5.html
Normal file
118
docs/developer/examples/ping_5.html
Normal file
@ -0,0 +1,118 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="ping_5_go" name="ping_5" class="tab" checked>
|
||||
|
||||
<label for="ping_5_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="ping_5_java" name="ping_5" class="tab">
|
||||
|
||||
<label for="ping_5_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="ping_5_js" name="ping_5" class="tab">
|
||||
|
||||
<label for="ping_5_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="ping_5_py" name="ping_5" class="tab">
|
||||
|
||||
<label for="ping_5_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="ping_5_ruby" name="ping_5" class="tab">
|
||||
|
||||
<label for="ping_5_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="ping_5_ts" name="ping_5" class="tab">
|
||||
|
||||
<label for="ping_5_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="ping_5_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/ping_5/main.go#L10-25"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">opts := nats.GetDefaultOptions()
|
||||
opts.Url = "demo.nats.io"
|
||||
// Set maximum number of PINGs out without getting a PONG back
|
||||
// before the connection will be disconnected as a stale connection.
|
||||
opts.MaxPingsOut = 5
|
||||
|
||||
nc, err := opts.Connect()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="ping_5_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/ConnectMaxPingFive.java#L11-21"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Options options = new Options.Builder().
|
||||
server("nats://demo.nats.io:4222").
|
||||
maxPingsOut(5). // Set max pings in flight
|
||||
build();
|
||||
Connection nc = Nats.connect(options);
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="ping_5_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/options_samples.js#L23-28"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let nc = NATS.connect({
|
||||
maxPingOut: 5,
|
||||
url: "nats://demo.nats.io:4222"
|
||||
});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="ping_5_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/ping_5.py#L6-19"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">nc = NATS()
|
||||
|
||||
await nc.connect(
|
||||
servers=["nats://demo.nats.io:4222"],
|
||||
# Set maximum number of PINGs out without getting a PONG back
|
||||
# before the connection will be disconnected as a stale connection.
|
||||
max_outstanding_pings=5,
|
||||
ping_interval=1,
|
||||
)
|
||||
|
||||
# Do something with the connection.
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="ping_5_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/ping_5s.rb#L1-15"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby">require 'nats/client'
|
||||
|
||||
NATS.start(max_outstanding_pings: 5) do |nc|
|
||||
nc.on_reconnect do
|
||||
puts "Got reconnected to #{nc.connected_server}"
|
||||
end
|
||||
|
||||
nc.on_disconnect do |reason|
|
||||
puts "Got disconnected! #{reason}"
|
||||
end
|
||||
|
||||
# Do something with the connection
|
||||
end
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="ping_5_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/options_samples.ts#L17-24"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">// will throw an exception if connection fails
|
||||
let nc = await connect({
|
||||
maxPingOut: 5,
|
||||
url: "nats://demo.nats.io:4222"
|
||||
});
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
101
docs/developer/examples/publish_bytes.html
Normal file
101
docs/developer/examples/publish_bytes.html
Normal file
@ -0,0 +1,101 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="publish_bytes_go" name="publish_bytes" class="tab" checked>
|
||||
|
||||
<label for="publish_bytes_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="publish_bytes_java" name="publish_bytes" class="tab">
|
||||
|
||||
<label for="publish_bytes_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="publish_bytes_js" name="publish_bytes" class="tab">
|
||||
|
||||
<label for="publish_bytes_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="publish_bytes_py" name="publish_bytes" class="tab">
|
||||
|
||||
<label for="publish_bytes_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="publish_bytes_ruby" name="publish_bytes" class="tab">
|
||||
|
||||
<label for="publish_bytes_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="publish_bytes_ts" name="publish_bytes" class="tab">
|
||||
|
||||
<label for="publish_bytes_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="publish_bytes_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/publish_bytes/main.go#L10-22"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">nc, err := nats.Connect("demo.nats.io")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
if err := nc.Publish("updates", []byte("All is Well")); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
// Make sure the message goes through before we close
|
||||
nc.Flush()
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="publish_bytes_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/PublishBytes.java#L13-21"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Connection nc = Nats.connect("nats://demo.nats.io:4222");
|
||||
|
||||
nc.publish("updates", "All is Well".getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
// Make sure the message goes through before we close
|
||||
nc.flush(Duration.ZERO);
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="publish_bytes_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/publisher_samples.js#L8-13"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let nc = NATS.connect({url: "nats://demo.nats.io:4222", preserveBuffers: true});
|
||||
let buf = Buffer.allocUnsafe(12);
|
||||
buf.fill("All is well");
|
||||
nc.publish('updates', buf);
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="publish_bytes_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/publish_bytes.py#L6-13"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">nc = NATS()
|
||||
|
||||
await nc.connect(servers=["nats://demo.nats.io:4222"])
|
||||
|
||||
await nc.publish("updates", b'All is Well')
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="publish_bytes_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/publish_bytes.rb#L1-7"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby">require 'nats/client'
|
||||
|
||||
NATS.start(servers:["nats://127.0.0.1:4222"]) do |nc|
|
||||
nc.publish("updates", "All is Well")
|
||||
end
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="publish_bytes_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/publisher_samples.ts#L6-15"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let nc = await connect({
|
||||
url: "nats://demo.nats.io:4222",
|
||||
payload: Payload.BINARY
|
||||
});
|
||||
|
||||
let buf = Buffer.allocUnsafe(12);
|
||||
buf.fill("All is Well");
|
||||
nc.publish('updates', buf);
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
134
docs/developer/examples/publish_json.html
Normal file
134
docs/developer/examples/publish_json.html
Normal file
@ -0,0 +1,134 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="publish_json_go" name="publish_json" class="tab" checked>
|
||||
|
||||
<label for="publish_json_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="publish_json_java" name="publish_json" class="tab">
|
||||
|
||||
<label for="publish_json_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="publish_json_js" name="publish_json" class="tab">
|
||||
|
||||
<label for="publish_json_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="publish_json_py" name="publish_json" class="tab">
|
||||
|
||||
<label for="publish_json_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="publish_json_ruby" name="publish_json" class="tab">
|
||||
|
||||
<label for="publish_json_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="publish_json_ts" name="publish_json" class="tab">
|
||||
|
||||
<label for="publish_json_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="publish_json_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/publish_json/main.go#L10-34"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">nc, err := nats.Connect("demo.nats.io")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
ec, err := nats.NewEncodedConn(nc, nats.JSON_ENCODER)
|
||||
if err != nil {
|
||||
nc.Close()
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer ec.Close()
|
||||
|
||||
// Define the object
|
||||
type stock struct {
|
||||
Symbol string
|
||||
Price int
|
||||
}
|
||||
|
||||
// Publish the message
|
||||
if err := ec.Publish("updates", &stock{Symbol: "GOOG", Price: 1200}); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
// Make sure the message goes through before we close
|
||||
ec.Flush()
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="publish_json_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/PublishJSON.java#L12-44"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">class StockForJsonPub {
|
||||
public String symbol;
|
||||
public float price;
|
||||
}
|
||||
|
||||
public class PublishJSON {
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
Connection nc = Nats.connect("nats://demo.nats.io:4222");
|
||||
|
||||
// Create the data object
|
||||
StockForJsonPub stk = new StockForJsonPub();
|
||||
stk.symbol="GOOG";
|
||||
stk.price=1200;
|
||||
|
||||
// use Gson to encode the object to JSON
|
||||
GsonBuilder builder = new GsonBuilder();
|
||||
Gson gson = builder.create();
|
||||
String json = gson.toJson(stk);
|
||||
|
||||
// Publish the message
|
||||
nc.publish("updates", json.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
// Make sure the message goes through before we close
|
||||
nc.flush(Duration.ZERO);
|
||||
nc.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="publish_json_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/publisher_samples.js#L25-28"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let nc = NATS.connect({url: "nats://demo.nats.io:4222", json: true});
|
||||
nc.publish('updates', {ticker: 'GOOG', price: 1200});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="publish_json_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/publish_json.py#L7-14"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">nc = NATS()
|
||||
|
||||
await nc.connect(servers=["nats://demo.nats.io:4222"])
|
||||
|
||||
await nc.publish("updates", json.dumps({"symbol": "GOOG", "price": 1200 }).encode())
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="publish_json_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/publish_json.rb#L1-8"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby">require 'nats/client'
|
||||
require 'json'
|
||||
|
||||
NATS.start(servers:["nats://127.0.0.1:4222"]) do |nc|
|
||||
nc.publish("updates", {"symbol": "GOOG", "price": 1200}.to_json)
|
||||
end
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="publish_json_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/publisher_samples.ts#L22-29"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let nc = await connect({
|
||||
url: "nats://demo.nats.io:4222",
|
||||
payload: Payload.JSON
|
||||
});
|
||||
|
||||
nc.publish('updates', {ticker: 'GOOG', price: 1200});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
186
docs/developer/examples/publish_with_reply.html
Normal file
186
docs/developer/examples/publish_with_reply.html
Normal file
@ -0,0 +1,186 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="publish_with_reply_go" name="publish_with_reply" class="tab" checked>
|
||||
|
||||
<label for="publish_with_reply_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="publish_with_reply_java" name="publish_with_reply" class="tab">
|
||||
|
||||
<label for="publish_with_reply_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="publish_with_reply_js" name="publish_with_reply" class="tab">
|
||||
|
||||
<label for="publish_with_reply_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="publish_with_reply_py" name="publish_with_reply" class="tab">
|
||||
|
||||
<label for="publish_with_reply_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="publish_with_reply_ruby" name="publish_with_reply" class="tab">
|
||||
|
||||
<label for="publish_with_reply_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="publish_with_reply_ts" name="publish_with_reply" class="tab">
|
||||
|
||||
<label for="publish_with_reply_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="publish_with_reply_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/publish_with_reply/main.go#L11-43"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">nc, err := nats.Connect("demo.nats.io")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
// Create a unique subject name
|
||||
uniqueReplyTo := nats.NewInbox()
|
||||
|
||||
// Listen for a single response
|
||||
sub, err := nc.SubscribeSync(uniqueReplyTo)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Send the request
|
||||
if err := nc.PublishRequest("time", uniqueReplyTo, nil); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Read the reply
|
||||
msg, err := sub.NextMsg(time.Second)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Use the response
|
||||
log.Printf("Reply: %s", msg.Data)
|
||||
|
||||
// Close the connection
|
||||
nc.Close()
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="publish_with_reply_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/PublishWithReply.java#L16-37"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Connection nc = Nats.connect("nats://demo.nats.io:4222");
|
||||
|
||||
// Create a unique subject name
|
||||
String uniqueReplyTo = NUID.nextGlobal();
|
||||
|
||||
// Listen for a single response
|
||||
Subscription sub = nc.subscribe(uniqueReplyTo);
|
||||
sub.unsubscribe(1);
|
||||
|
||||
// Send the request
|
||||
nc.publish("time", uniqueReplyTo, null);
|
||||
|
||||
// Read the reply
|
||||
Message msg = sub.nextMessage(Duration.ofSeconds(1));
|
||||
|
||||
// Use the response
|
||||
System.out.println(new String(msg.getData(), StandardCharsets.UTF_8));
|
||||
|
||||
// Close the connection
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="publish_with_reply_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/publisher_samples.js#L41-57"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">// set up a subscription to process the request
|
||||
nc.subscribe('time', (msg, reply) => {
|
||||
if(reply) {
|
||||
nc.publish(reply, new Date().toLocaleTimeString());
|
||||
}
|
||||
});
|
||||
|
||||
// create a subscription subject that the responding send replies to
|
||||
let inbox = NATS.createInbox();
|
||||
nc.subscribe(inbox, {max: 1}, (msg) => {
|
||||
t.log('the time is', msg);
|
||||
nc.close();
|
||||
});
|
||||
|
||||
nc.publish('time', "", inbox);
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="publish_with_reply_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/publish_with_reply.py#L8-27"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">nc = NATS()
|
||||
|
||||
future = asyncio.Future()
|
||||
|
||||
async def sub(msg):
|
||||
nonlocal future
|
||||
future.set_result(msg)
|
||||
|
||||
await nc.connect(servers=["nats://demo.nats.io:4222"])
|
||||
await nc.subscribe("time", cb=sub)
|
||||
|
||||
unique_reply_to = new_inbox()
|
||||
await nc.publish_request("time", unique_reply_to, b'')
|
||||
|
||||
# Use the response
|
||||
msg = await asyncio.wait_for(future, 1)
|
||||
print("Reply:", msg)
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="publish_with_reply_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/publish_with_reply.rb#L1-22"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby">require 'nats/client'
|
||||
require 'fiber'
|
||||
|
||||
NATS.start(servers:["nats://127.0.0.1:4222"]) do |nc|
|
||||
Fiber.new do
|
||||
f = Fiber.current
|
||||
|
||||
nc.subscribe("time") do |msg, reply|
|
||||
f.resume msg
|
||||
end
|
||||
|
||||
nc.publish("time", 'example', NATS.create_inbox)
|
||||
|
||||
# Use the response
|
||||
msg = Fiber.yield
|
||||
puts "Reply: #{msg}"
|
||||
|
||||
end.resume
|
||||
end
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="publish_with_reply_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/publisher_samples.ts#L41-64"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">// set up a subscription to process the request
|
||||
await nc.subscribe('time', (err, msg) => {
|
||||
if (err) {
|
||||
// this example is running inside of a promise
|
||||
reject();
|
||||
return;
|
||||
}
|
||||
if (msg.reply) {
|
||||
nc.publish(msg.reply, new Date().toLocaleTimeString());
|
||||
}
|
||||
});
|
||||
|
||||
// create a subscription subject that the responding send replies to
|
||||
let inbox = createInbox();
|
||||
await nc.subscribe(inbox, (err, msg) => {
|
||||
t.log('the time is', msg.data);
|
||||
// this example is running inside of a promise
|
||||
nc.close();
|
||||
resolve();
|
||||
}, {max: 1});
|
||||
|
||||
nc.publish('time', "", inbox);
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
106
docs/developer/examples/reconnect_10s.html
Normal file
106
docs/developer/examples/reconnect_10s.html
Normal file
@ -0,0 +1,106 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="reconnect_10s_go" name="reconnect_10s" class="tab" checked>
|
||||
|
||||
<label for="reconnect_10s_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="reconnect_10s_java" name="reconnect_10s" class="tab">
|
||||
|
||||
<label for="reconnect_10s_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="reconnect_10s_js" name="reconnect_10s" class="tab">
|
||||
|
||||
<label for="reconnect_10s_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="reconnect_10s_py" name="reconnect_10s" class="tab">
|
||||
|
||||
<label for="reconnect_10s_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="reconnect_10s_ruby" name="reconnect_10s" class="tab">
|
||||
|
||||
<label for="reconnect_10s_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="reconnect_10s_ts" name="reconnect_10s" class="tab">
|
||||
|
||||
<label for="reconnect_10s_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="reconnect_10s_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/reconnect_10s/main.go#L11-21"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">// Set reconnect interval to 10 seconds
|
||||
nc, err := nats.Connect("demo.nats.io", nats.ReconnectWait(10*time.Second))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="reconnect_10s_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/ReconnectTenSeconds.java#L13-23"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Options options = new Options.Builder().
|
||||
server("nats://demo.nats.io:4222").
|
||||
reconnectWait(Duration.ofSeconds(10)). // Set Reconnect Wait
|
||||
build();
|
||||
Connection nc = Nats.connect(options);
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="reconnect_10s_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/reconnect_samples.js#L42-47"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let nc = NATS.connect({
|
||||
reconnectTimeWait: 10 * 1000, //10s
|
||||
servers: ["nats://demo.nats.io:4222"]
|
||||
});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="reconnect_10s_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/reconnect_10s.py#L5-16"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">nc = NATS()
|
||||
await nc.connect(
|
||||
servers=["nats://demo.nats.io:4222"],
|
||||
reconnect_time_wait=10,
|
||||
)
|
||||
|
||||
# Do something with the connection
|
||||
|
||||
await nc.close()
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="reconnect_10s_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/reconnect_10s.rb#L1-10"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby">require 'nats/client'
|
||||
|
||||
NATS.start(servers: ["nats://127.0.0.1:1222", "nats://127.0.0.1:1223", "nats://127.0.0.1:1224"], reconnect_time_wait: 10) do |nc|
|
||||
# Do something with the connection
|
||||
|
||||
# Close the connection
|
||||
nc.close
|
||||
end
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="reconnect_10s_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/reconnect_samples.ts#L33-40"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">// will throw an exception if connection fails
|
||||
let nc = await connect({
|
||||
reconnectTimeWait: 10*1000, //10s
|
||||
servers: ["nats://demo.nats.io:4222"]
|
||||
});
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
106
docs/developer/examples/reconnect_10x.html
Normal file
106
docs/developer/examples/reconnect_10x.html
Normal file
@ -0,0 +1,106 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="reconnect_10x_go" name="reconnect_10x" class="tab" checked>
|
||||
|
||||
<label for="reconnect_10x_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="reconnect_10x_java" name="reconnect_10x" class="tab">
|
||||
|
||||
<label for="reconnect_10x_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="reconnect_10x_js" name="reconnect_10x" class="tab">
|
||||
|
||||
<label for="reconnect_10x_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="reconnect_10x_py" name="reconnect_10x" class="tab">
|
||||
|
||||
<label for="reconnect_10x_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="reconnect_10x_ruby" name="reconnect_10x" class="tab">
|
||||
|
||||
<label for="reconnect_10x_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="reconnect_10x_ts" name="reconnect_10x" class="tab">
|
||||
|
||||
<label for="reconnect_10x_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="reconnect_10x_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/reconnect_10x/main.go#L10-20"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">// Set max reconnects attempts
|
||||
nc, err := nats.Connect("demo.nats.io", nats.MaxReconnects(10))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="reconnect_10x_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/ReconnectTenTimes.java#L11-21"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Options options = new Options.Builder().
|
||||
server("nats://demo.nats.io:4222").
|
||||
maxReconnects(10). // Set max reconnect attempts
|
||||
build();
|
||||
Connection nc = Nats.connect(options);
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="reconnect_10x_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/reconnect_samples.js#L58-63"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let nc = NATS.connect({
|
||||
maxReconnectAttempts: 10,
|
||||
servers: ["nats://demo.nats.io:4222"]
|
||||
});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="reconnect_10x_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/reconnect_10x.py#L5-16"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">nc = NATS()
|
||||
await nc.connect(
|
||||
servers=["nats://demo.nats.io:4222"],
|
||||
max_reconnect_attempts=10,
|
||||
)
|
||||
|
||||
# Do something with the connection
|
||||
|
||||
await nc.close()
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="reconnect_10x_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/reconnect_10x.rb#L1-10"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby">require 'nats/client'
|
||||
|
||||
NATS.start(servers: ["nats://127.0.0.1:1222", "nats://127.0.0.1:1223", "nats://127.0.0.1:1224"], max_reconnect_attempts: 10) do |nc|
|
||||
# Do something with the connection
|
||||
|
||||
# Close the connection
|
||||
nc.close
|
||||
end
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="reconnect_10x_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/reconnect_samples.ts#L45-52"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">// will throw an exception if connection fails
|
||||
let nc = await connect({
|
||||
maxReconnectAttempts: 10,
|
||||
servers: ["nats://demo.nats.io:4222"]
|
||||
});
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
82
docs/developer/examples/reconnect_5mb.html
Normal file
82
docs/developer/examples/reconnect_5mb.html
Normal file
@ -0,0 +1,82 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="reconnect_5mb_go" name="reconnect_5mb" class="tab" checked>
|
||||
|
||||
<label for="reconnect_5mb_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="reconnect_5mb_java" name="reconnect_5mb" class="tab">
|
||||
|
||||
<label for="reconnect_5mb_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="reconnect_5mb_js" name="reconnect_5mb" class="tab">
|
||||
|
||||
<label for="reconnect_5mb_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="reconnect_5mb_py" name="reconnect_5mb" class="tab">
|
||||
|
||||
<label for="reconnect_5mb_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="reconnect_5mb_ruby" name="reconnect_5mb" class="tab">
|
||||
|
||||
<label for="reconnect_5mb_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="reconnect_5mb_ts" name="reconnect_5mb" class="tab">
|
||||
|
||||
<label for="reconnect_5mb_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="reconnect_5mb_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/reconnect_5mb/main.go#L10-20"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">// Set reconnect buffer size in bytes (5 MB)
|
||||
nc, err := nats.Connect("demo.nats.io", nats.ReconnectBufSize(5*1024*1024))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="reconnect_5mb_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/ReconnectFiveMB.java#L11-21"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Options options = new Options.Builder().
|
||||
server("nats://demo.nats.io:4222").
|
||||
reconnectBufferSize(5 * 1024 * 1024). // Set buffer in bytes
|
||||
build();
|
||||
Connection nc = Nats.connect(options);
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="reconnect_5mb_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/reconnect_samples.js#L94-96"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">// Reconnect buffer size is not configurable on node-nats
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="reconnect_5mb_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/notapplicable.txt#L1-3"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python"># Asyncio NATS client currentply does not implement a reconnect buffer
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="reconnect_5mb_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/notapplicable.txt#L1-3"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby"># There is currently no reconnect pending buffer as part of the Ruby NATS client.
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="reconnect_5mb_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/reconnect_samples.ts#L76-78"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">// Reconnect buffer size is not configurable on ts-nats
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
142
docs/developer/examples/reconnect_event.html
Normal file
142
docs/developer/examples/reconnect_event.html
Normal file
@ -0,0 +1,142 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="reconnect_event_go" name="reconnect_event" class="tab" checked>
|
||||
|
||||
<label for="reconnect_event_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="reconnect_event_java" name="reconnect_event" class="tab">
|
||||
|
||||
<label for="reconnect_event_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="reconnect_event_js" name="reconnect_event" class="tab">
|
||||
|
||||
<label for="reconnect_event_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="reconnect_event_py" name="reconnect_event" class="tab">
|
||||
|
||||
<label for="reconnect_event_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="reconnect_event_ruby" name="reconnect_event" class="tab">
|
||||
|
||||
<label for="reconnect_event_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="reconnect_event_ts" name="reconnect_event" class="tab">
|
||||
|
||||
<label for="reconnect_event_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="reconnect_event_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/reconnect_event/main.go#L10-28"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">// Connection event handlers are invoked asynchronously
|
||||
// and the state of the connection may have changed when
|
||||
// the callback is invoked.
|
||||
nc, err := nats.Connect("demo.nats.io",
|
||||
nats.DisconnectHandler(func(nc *nats.Conn) {
|
||||
// handle disconnect event
|
||||
}),
|
||||
nats.ReconnectHandler(func(nc *nats.Conn) {
|
||||
// handle reconnect event
|
||||
}))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="reconnect_event_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/ReconnectEvents.java#L12-28"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Options options = new Options.Builder().
|
||||
server("nats://demo.nats.io:4222").
|
||||
connectionListener((conn, type) -> {
|
||||
if (type == Events.RECONNECTED) {
|
||||
// handle reconnected
|
||||
} else if (type == Events.DISCONNECTED) {
|
||||
// handle disconnected, wait for reconnect
|
||||
}
|
||||
}).
|
||||
build();
|
||||
Connection nc = Nats.connect(options);
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="reconnect_event_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/reconnect_samples.js#L74-83"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let nc = NATS.connect({
|
||||
maxReconnectAttempts: 10,
|
||||
servers: ["nats://demo.nats.io:4222"]
|
||||
});
|
||||
|
||||
nc.on('reconnect', (c) => {
|
||||
console.log('reconnected');
|
||||
});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="reconnect_event_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/reconnect_event.py#L6-25"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">nc = NATS()
|
||||
|
||||
async def disconnected_cb():
|
||||
print("Got disconnected!")
|
||||
|
||||
async def reconnected_cb():
|
||||
# See who we are connected to on reconnect.
|
||||
print("Got reconnected to {url}".format(url=nc.connected_url.netloc))
|
||||
|
||||
await nc.connect(
|
||||
servers=["nats://demo.nats.io:4222"],
|
||||
reconnect_time_wait=10,
|
||||
reconnected_cb=reconnected_cb,
|
||||
disconnected_cb=disconnected_cb,
|
||||
)
|
||||
|
||||
# Do something with the connection.
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="reconnect_event_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/reconnect_event.rb#L1-14"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby">require 'nats/client'
|
||||
|
||||
NATS.start(servers: ["nats://127.0.0.1:1222", "nats://127.0.0.1:1223", "nats://127.0.0.1:1224"]) do |nc|
|
||||
# Do something with the connection
|
||||
nc.on_reconnect do
|
||||
puts "Got reconnected to #{nc.connected_server}"
|
||||
end
|
||||
|
||||
nc.on_disconnect do |reason|
|
||||
puts "Got disconnected! #{reason}"
|
||||
end
|
||||
end
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="reconnect_event_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/reconnect_samples.ts#L57-70"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">// will throw an exception if connection fails
|
||||
let nc = await connect({
|
||||
maxReconnectAttempts: 10,
|
||||
servers: ["nats://demo.nats.io:4222"]
|
||||
});
|
||||
// first argument is the connection (same as nc in this case)
|
||||
// second argument is the url of the server where the client
|
||||
// connected
|
||||
nc.on('reconnect', (conn, server) => {
|
||||
console.log('reconnected to', server);
|
||||
});
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
118
docs/developer/examples/reconnect_no_random.html
Normal file
118
docs/developer/examples/reconnect_no_random.html
Normal file
@ -0,0 +1,118 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="reconnect_no_random_go" name="reconnect_no_random" class="tab" checked>
|
||||
|
||||
<label for="reconnect_no_random_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="reconnect_no_random_java" name="reconnect_no_random" class="tab">
|
||||
|
||||
<label for="reconnect_no_random_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="reconnect_no_random_js" name="reconnect_no_random" class="tab">
|
||||
|
||||
<label for="reconnect_no_random_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="reconnect_no_random_py" name="reconnect_no_random" class="tab">
|
||||
|
||||
<label for="reconnect_no_random_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="reconnect_no_random_ruby" name="reconnect_no_random" class="tab">
|
||||
|
||||
<label for="reconnect_no_random_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="reconnect_no_random_ts" name="reconnect_no_random" class="tab">
|
||||
|
||||
<label for="reconnect_no_random_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="reconnect_no_random_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/reconnect_no_random/main.go#L11-25"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">servers := []string{"nats://localhost:1222",
|
||||
"nats://localhost:1223",
|
||||
"nats://localhost:1224",
|
||||
}
|
||||
|
||||
nc, err := nats.Connect(strings.Join(servers, ","), nats.DontRandomize())
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="reconnect_no_random_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/ReconnectNoRandom.java#L11-21"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Options options = new Options.Builder().
|
||||
server("nats://demo.nats.io:4222").
|
||||
noRandomize(). // Disable reconnect shuffle
|
||||
build();
|
||||
Connection nc = Nats.connect(options);
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="reconnect_no_random_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/reconnect_samples.js#L6-13"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let nc = NATS.connect({
|
||||
noRandomize: false,
|
||||
servers: ["nats://127.0.0.1:4443",
|
||||
"nats://demo.nats.io:4222"
|
||||
]
|
||||
});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="reconnect_no_random_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/reconnect_no_random.py#L5-20"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">nc = NATS()
|
||||
await nc.connect(
|
||||
servers=[
|
||||
"nats://demo.nats.io:1222",
|
||||
"nats://demo.nats.io:1223",
|
||||
"nats://demo.nats.io:1224"
|
||||
],
|
||||
dont_randomize=True,
|
||||
)
|
||||
|
||||
# Do something with the connection
|
||||
|
||||
await nc.close()
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="reconnect_no_random_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/reconnect_no_random.rb#L1-10"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby">require 'nats/client'
|
||||
|
||||
NATS.start(servers: ["nats://127.0.0.1:1222", "nats://127.0.0.1:1223", "nats://127.0.0.1:1224"], dont_randomize_servers: true) do |nc|
|
||||
# Do something with the connection
|
||||
|
||||
# Close the connection
|
||||
nc.close
|
||||
end
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="reconnect_no_random_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/reconnect_samples.ts#L6-15"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">// will throw an exception if connection fails
|
||||
let nc = await connect({
|
||||
noRandomize: false,
|
||||
servers: ["nats://127.0.0.1:4443",
|
||||
"nats://demo.nats.io:4222"
|
||||
]
|
||||
});
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
110
docs/developer/examples/reconnect_none.html
Normal file
110
docs/developer/examples/reconnect_none.html
Normal file
@ -0,0 +1,110 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="reconnect_none_go" name="reconnect_none" class="tab" checked>
|
||||
|
||||
<label for="reconnect_none_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="reconnect_none_java" name="reconnect_none" class="tab">
|
||||
|
||||
<label for="reconnect_none_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="reconnect_none_js" name="reconnect_none" class="tab">
|
||||
|
||||
<label for="reconnect_none_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="reconnect_none_py" name="reconnect_none" class="tab">
|
||||
|
||||
<label for="reconnect_none_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="reconnect_none_ruby" name="reconnect_none" class="tab">
|
||||
|
||||
<label for="reconnect_none_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="reconnect_none_ts" name="reconnect_none" class="tab">
|
||||
|
||||
<label for="reconnect_none_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="reconnect_none_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/reconnect_none/main.go#L10-20"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">// Disable reconnect attempts
|
||||
nc, err := nats.Connect("demo.nats.io", nats.NoReconnect())
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="reconnect_none_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/ReconnectNone.java#L11-21"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Options options = new Options.Builder().
|
||||
server("nats://demo.nats.io:4222").
|
||||
noReconnect(). // Disable reconnect attempts
|
||||
build();
|
||||
Connection nc = Nats.connect(options);
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="reconnect_none_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/reconnect_samples.js#L25-30"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let nc = NATS.connect({
|
||||
reconnect: false,
|
||||
servers: ["nats://demo.nats.io:4222"]
|
||||
});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="reconnect_none_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/reconnect_none.py#L5-20"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">nc = NATS()
|
||||
await nc.connect(
|
||||
servers=[
|
||||
"nats://demo.nats.io:1222",
|
||||
"nats://demo.nats.io:1223",
|
||||
"nats://demo.nats.io:1224"
|
||||
],
|
||||
allow_reconnect=False,
|
||||
)
|
||||
|
||||
# Do something with the connection
|
||||
|
||||
await nc.close()
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="reconnect_none_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/reconnect_none.rb#L1-10"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby">require 'nats/client'
|
||||
|
||||
NATS.start(servers: ["nats://127.0.0.1:1222", "nats://127.0.0.1:1223", "nats://127.0.0.1:1224"], reconnect: false) do |nc|
|
||||
# Do something with the connection
|
||||
|
||||
# Close the connection
|
||||
nc.close
|
||||
end
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="reconnect_none_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/reconnect_samples.ts#L20-27"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">// will throw an exception if connection fails
|
||||
let nc = await connect({
|
||||
reconnect: false,
|
||||
servers: ["nats://demo.nats.io:4222"]
|
||||
});
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
125
docs/developer/examples/request_reply.html
Normal file
125
docs/developer/examples/request_reply.html
Normal file
@ -0,0 +1,125 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="request_reply_go" name="request_reply" class="tab" checked>
|
||||
|
||||
<label for="request_reply_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="request_reply_java" name="request_reply" class="tab">
|
||||
|
||||
<label for="request_reply_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="request_reply_js" name="request_reply" class="tab">
|
||||
|
||||
<label for="request_reply_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="request_reply_py" name="request_reply" class="tab">
|
||||
|
||||
<label for="request_reply_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="request_reply_ruby" name="request_reply" class="tab">
|
||||
|
||||
<label for="request_reply_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="request_reply_ts" name="request_reply" class="tab">
|
||||
|
||||
<label for="request_reply_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="request_reply_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/request_reply/main.go#L11-29"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">nc, err := nats.Connect("demo.nats.io")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
// Send the request
|
||||
msg, err := nc.Request("time", nil, time.Second)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Use the response
|
||||
log.Printf("Reply: %s", msg.Data)
|
||||
|
||||
// Close the connection
|
||||
nc.Close()
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="request_reply_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/RequestReply.java#L14-25"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Connection nc = Nats.connect("nats://demo.nats.io:4222");
|
||||
|
||||
// Send the request
|
||||
Message msg = nc.request("time", null, Duration.ofSeconds(1));
|
||||
|
||||
// Use the response
|
||||
System.out.println(new String(msg.getData(), StandardCharsets.UTF_8));
|
||||
|
||||
// Close the connection
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="request_reply_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/publisher_samples.js#L77-82"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">nc.requestOne('time', (msg) => {
|
||||
t.log('the time is', msg);
|
||||
nc.close();
|
||||
});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="request_reply_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/request_reply.py#L8-25"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">nc = NATS()
|
||||
|
||||
async def sub(msg):
|
||||
await nc.publish(msg.reply, b'response')
|
||||
|
||||
await nc.connect(servers=["nats://demo.nats.io:4222"])
|
||||
await nc.subscribe("time", cb=sub)
|
||||
|
||||
# Send the request
|
||||
try:
|
||||
msg = await nc.request("time", b'', timeout=1)
|
||||
# Use the response
|
||||
print("Reply:", msg)
|
||||
except asyncio.TimeoutError:
|
||||
print("Timed out waiting for response")
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="request_reply_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/request_reply.rb#L1-17"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby">require 'nats/client'
|
||||
require 'fiber'
|
||||
|
||||
NATS.start(servers:["nats://127.0.0.1:4222"]) do |nc|
|
||||
nc.subscribe("time") do |msg, reply|
|
||||
nc.publish(reply, "response")
|
||||
end
|
||||
|
||||
Fiber.new do
|
||||
# Use the response
|
||||
msg = nc.request("time", "")
|
||||
puts "Reply: #{msg}"
|
||||
end.resume
|
||||
end
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="request_reply_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/publisher_samples.ts#L81-85"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let msg = await nc.request('time', 1000);
|
||||
t.log('the time is', msg.data);
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
111
docs/developer/examples/servers_added.html
Normal file
111
docs/developer/examples/servers_added.html
Normal file
@ -0,0 +1,111 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="servers_added_go" name="servers_added" class="tab" checked>
|
||||
|
||||
<label for="servers_added_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="servers_added_java" name="servers_added" class="tab">
|
||||
|
||||
<label for="servers_added_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="servers_added_js" name="servers_added" class="tab">
|
||||
|
||||
<label for="servers_added_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="servers_added_py" name="servers_added" class="tab">
|
||||
|
||||
<label for="servers_added_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="servers_added_ruby" name="servers_added" class="tab">
|
||||
|
||||
<label for="servers_added_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="servers_added_ts" name="servers_added" class="tab">
|
||||
|
||||
<label for="servers_added_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="servers_added_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/servers_added/main.go#L10-25"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">// Be notified if a new server joins the cluster.
|
||||
// Print all the known servers and the only the ones that were discovered.
|
||||
nc, err := nats.Connect("demo.nats.io",
|
||||
nats.DiscoveredServersHandler(func(nc *nats.Conn) {
|
||||
log.Printf("Known servers: %v\n", nc.Servers())
|
||||
log.Printf("Discovered servers: %v\n", nc.DiscoveredServers())
|
||||
}))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="servers_added_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/ListenForNewServers.java#L8-37"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">class ServersAddedListener implements ConnectionListener {
|
||||
public void connectionEvent(Connection nc, Events event) {
|
||||
if (event == Events.DISCOVERED_SERVERS) {
|
||||
for (String server : nc.getServers()) {
|
||||
System.out.println("Known server: "+server);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ListenForNewServers {
|
||||
public static void main(String[] args) {
|
||||
|
||||
try {
|
||||
Options options = new Options.Builder().
|
||||
server("nats://demo.nats.io:4222").
|
||||
connectionListener(new ServersAddedListener()). // Set the listener
|
||||
build();
|
||||
Connection nc = Nats.connect(options);
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
nc.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="servers_added_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/event_samples.js#L56-61"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let nc = NATS.connect("nats://demo.nats.io:4222");
|
||||
nc.on('serversDiscovered', (urls) => {
|
||||
t.log('serversDiscovered', urls);
|
||||
});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="servers_added_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/notapplicable.txt#L13-15"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python"># Asyncio NATS client does not support discovered servers handler right now
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="servers_added_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/notapplicable.txt#L25-27"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby"># The Ruby NATS client does not support discovered servers handler right now
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="servers_added_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/event_samples.ts#L36-40"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">nc.on('serversChanged', (ce) => {
|
||||
t.log('servers changed\n', 'added: ',ce.added, 'removed:', ce.removed);
|
||||
});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
154
docs/developer/examples/slow_listener.html
Normal file
154
docs/developer/examples/slow_listener.html
Normal file
@ -0,0 +1,154 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="slow_listener_go" name="slow_listener" class="tab" checked>
|
||||
|
||||
<label for="slow_listener_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="slow_listener_java" name="slow_listener" class="tab">
|
||||
|
||||
<label for="slow_listener_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="slow_listener_js" name="slow_listener" class="tab">
|
||||
|
||||
<label for="slow_listener_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="slow_listener_py" name="slow_listener" class="tab">
|
||||
|
||||
<label for="slow_listener_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="slow_listener_ruby" name="slow_listener" class="tab">
|
||||
|
||||
<label for="slow_listener_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="slow_listener_ts" name="slow_listener" class="tab">
|
||||
|
||||
<label for="slow_listener_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="slow_listener_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/slow_listener/main.go#L10-27"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">// Set the callback that will be invoked when an asynchronous error occurs.
|
||||
nc, err := nats.Connect("demo.nats.io",
|
||||
nats.ErrorHandler(func(nc *nats.Conn, sub *nats.Subscription, err error) {
|
||||
if err == nats.ErrSlowConsumer {
|
||||
dropped, _ := sub.Dropped()
|
||||
log.Printf("Slow consumer on subject %s dropped %d messages\n",
|
||||
sub.Subject, dropped)
|
||||
}
|
||||
}))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="slow_listener_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/SlowConsumerListener.java#L9-43"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">class SlowConsumerReporter implements ErrorListener {
|
||||
public void errorOccurred(Connection conn, String error)
|
||||
{
|
||||
}
|
||||
|
||||
public void exceptionOccurred(Connection conn, Exception exp) {
|
||||
}
|
||||
|
||||
// Detect slow consumers
|
||||
public void slowConsumerDetected(Connection conn, Consumer consumer) {
|
||||
// Get the dropped count
|
||||
System.out.println("A slow consumer dropped messages: "+ consumer.getDroppedCount());
|
||||
}
|
||||
}
|
||||
|
||||
public class SlowConsumerListener {
|
||||
public static void main(String[] args) {
|
||||
|
||||
try {
|
||||
Options options = new Options.Builder().
|
||||
server("nats://demo.nats.io:4222").
|
||||
errorListener(new SlowConsumerReporter()). // Set the listener
|
||||
build();
|
||||
Connection nc = Nats.connect(options);
|
||||
|
||||
// Do something with the connection
|
||||
|
||||
nc.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="slow_listener_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/options_samples.js#L114-116"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">// slow consumer detection is not configurable on node-nats
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="slow_listener_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/slow_listener.py#L7-50"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">
|
||||
nc = NATS()
|
||||
|
||||
async def error_cb(e):
|
||||
if type(e) is nats.aio.errors.ErrSlowConsumer:
|
||||
print("Slow consumer error, unsubscribing from handling further messages...")
|
||||
await nc.unsubscribe(e.sid)
|
||||
|
||||
await nc.connect(
|
||||
servers=["nats://demo.nats.io:4222"],
|
||||
error_cb=error_cb,
|
||||
)
|
||||
|
||||
msgs = []
|
||||
future = asyncio.Future()
|
||||
async def cb(msg):
|
||||
nonlocal msgs
|
||||
nonlocal future
|
||||
print(msg)
|
||||
msgs.append(msg)
|
||||
|
||||
if len(msgs) == 3:
|
||||
# Head of line blocking on other messages caused
|
||||
# by single message proccesing taking long...
|
||||
await asyncio.sleep(1)
|
||||
|
||||
await nc.subscribe("updates", cb=cb, pending_msgs_limit=5)
|
||||
|
||||
for i in range(0, 10):
|
||||
await nc.publish("updates", "msg #{}".format(i).encode())
|
||||
await asyncio.sleep(0)
|
||||
|
||||
try:
|
||||
await asyncio.wait_for(future, 1)
|
||||
except asyncio.TimeoutError:
|
||||
pass
|
||||
|
||||
for msg in msgs:
|
||||
print("[Received]", msg)
|
||||
|
||||
await nc.close()
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="slow_listener_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/notapplicable.txt#L21-23"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby"># The Ruby NATS client currently does not have option to customize slow consumer limits per sub.
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="slow_listener_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/options_samples.ts#L82-84"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">// slow consumer detection is not configurable on ts-nats
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
121
docs/developer/examples/slow_pending_limits.html
Normal file
121
docs/developer/examples/slow_pending_limits.html
Normal file
@ -0,0 +1,121 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="slow_pending_limits_go" name="slow_pending_limits" class="tab" checked>
|
||||
|
||||
<label for="slow_pending_limits_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="slow_pending_limits_java" name="slow_pending_limits" class="tab">
|
||||
|
||||
<label for="slow_pending_limits_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="slow_pending_limits_js" name="slow_pending_limits" class="tab">
|
||||
|
||||
<label for="slow_pending_limits_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="slow_pending_limits_py" name="slow_pending_limits" class="tab">
|
||||
|
||||
<label for="slow_pending_limits_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="slow_pending_limits_ruby" name="slow_pending_limits" class="tab">
|
||||
|
||||
<label for="slow_pending_limits_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="slow_pending_limits_ts" name="slow_pending_limits" class="tab">
|
||||
|
||||
<label for="slow_pending_limits_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="slow_pending_limits_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/sub_pending_limits/main.go#L10-37"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">nc, err := nats.Connect("demo.nats.io")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
// Subscribe
|
||||
sub1, err := nc.Subscribe("updates", func(m *nats.Msg) {})
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Set limits of 1000 messages or 5MB, whichever comes first
|
||||
sub1.SetPendingLimits(1000, 5*1024*1024)
|
||||
|
||||
// Subscribe
|
||||
sub2, err := nc.Subscribe("updates", func(m *nats.Msg) {})
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Set no limits for this subscription
|
||||
sub2.SetPendingLimits(-1, -1)
|
||||
|
||||
// Close the connection
|
||||
nc.Close()
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="slow_pending_limits_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/SetPendingLimits.java#L12-32"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Connection nc = Nats.connect("nats://demo.nats.io:4222");
|
||||
|
||||
Dispatcher d = nc.createDispatcher((msg) -> {
|
||||
// do something
|
||||
});
|
||||
|
||||
d.subscribe("updates");
|
||||
|
||||
d.setPendingLimits(1_000, 5 * 1024 * 1024); // Set limits on a dispatcher
|
||||
|
||||
// Subscribe
|
||||
Subscription sub = nc.subscribe("updates");
|
||||
|
||||
sub.setPendingLimits(1_000, 5 * 1024 * 1024); // Set limits on a subscription
|
||||
|
||||
// Do something
|
||||
|
||||
// Close the connection
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="slow_pending_limits_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/options_samples.js#L107-109"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">// slow pending limits are not configurable on node-nats
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="slow_pending_limits_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/sub_pending_limits.py#L6-20"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">nc = NATS()
|
||||
|
||||
await nc.connect(servers=["nats://demo.nats.io:4222"])
|
||||
|
||||
future = asyncio.Future()
|
||||
|
||||
async def cb(msg):
|
||||
nonlocal future
|
||||
future.set_result(msg)
|
||||
|
||||
# Set limits of 1000 messages or 5MB
|
||||
await nc.subscribe("updates", cb=cb, pending_bytes_limit=5*1024*1024, pending_msgs_limit=1000)
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="slow_pending_limits_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/notapplicable.txt#L17-19"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby"># The Ruby NATS client currently does not have option to customize slow consumer limits per sub.
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="slow_pending_limits_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/options_samples.ts#L75-77"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">// slow pending limits are not configurable on ts-nats
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
195
docs/developer/examples/subscribe_arrow.html
Normal file
195
docs/developer/examples/subscribe_arrow.html
Normal file
@ -0,0 +1,195 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_arrow_go" name="subscribe_arrow" class="tab" checked>
|
||||
|
||||
<label for="subscribe_arrow_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_arrow_java" name="subscribe_arrow" class="tab">
|
||||
|
||||
<label for="subscribe_arrow_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_arrow_js" name="subscribe_arrow" class="tab">
|
||||
|
||||
<label for="subscribe_arrow_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_arrow_py" name="subscribe_arrow" class="tab">
|
||||
|
||||
<label for="subscribe_arrow_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_arrow_ruby" name="subscribe_arrow" class="tab">
|
||||
|
||||
<label for="subscribe_arrow_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_arrow_ts" name="subscribe_arrow" class="tab">
|
||||
|
||||
<label for="subscribe_arrow_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_arrow_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/subscribe_arrow/main.go#L11-35"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">nc, err := nats.Connect("demo.nats.io")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
// Use a WaitGroup to wait for 4 messages to arrive
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(4)
|
||||
|
||||
// Subscribe
|
||||
if _, err := nc.Subscribe("time.>", func(m *nats.Msg) {
|
||||
log.Printf("%s: %s", m.Subject, m.Data)
|
||||
wg.Done()
|
||||
}); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Wait for the 4 messages to come in
|
||||
wg.Wait()
|
||||
|
||||
// Close the connection
|
||||
nc.Close()
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_arrow_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/SubscribeArrow.java#L14-36"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Connection nc = Nats.connect("nats://demo.nats.io:4222");
|
||||
|
||||
// Use a latch to wait for 4 messages to arrive
|
||||
CountDownLatch latch = new CountDownLatch(4);
|
||||
|
||||
// Create a dispatcher and inline message handler
|
||||
Dispatcher d = nc.createDispatcher((msg) -> {
|
||||
String subject = msg.getSubject();
|
||||
String str = new String(msg.getData(), StandardCharsets.UTF_8);
|
||||
System.out.println(subject + ": " + str);
|
||||
latch.countDown();
|
||||
});
|
||||
|
||||
// Subscribe
|
||||
d.subscribe("time.>");
|
||||
|
||||
// Wait for messages to come in
|
||||
latch.await();
|
||||
|
||||
// Close the connection
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_arrow_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/subscriber_samples.js#L176-199"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">nc.subscribe('time.>', (msg, reply, subject) => {
|
||||
// converting timezones correctly in node requires a library
|
||||
// this doesn't take into account *many* things.
|
||||
let time = "";
|
||||
switch (subject) {
|
||||
case 'time.us.east':
|
||||
time = new Date().toLocaleTimeString("en-us", {timeZone: "America/New_York"});
|
||||
break;
|
||||
case 'time.us.central':
|
||||
time = new Date().toLocaleTimeString("en-us", {timeZone: "America/Chicago"});
|
||||
break;
|
||||
case 'time.us.mountain':
|
||||
time = new Date().toLocaleTimeString("en-us", {timeZone: "America/Denver"});
|
||||
break;
|
||||
case 'time.us.west':
|
||||
time = new Date().toLocaleTimeString("en-us", {timeZone: "America/Los_Angeles"});
|
||||
break;
|
||||
default:
|
||||
time = "I don't know what you are talking about Willis";
|
||||
}
|
||||
t.log(subject, time);
|
||||
});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_arrow_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/subscribe_arrow.py#L6-30"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">nc = NATS()
|
||||
|
||||
await nc.connect(servers=["nats://demo.nats.io:4222"])
|
||||
|
||||
# Use queue to wait for 4 messages to arrive
|
||||
queue = asyncio.Queue()
|
||||
async def cb(msg):
|
||||
await queue.put(msg)
|
||||
|
||||
await nc.subscribe("time.>", cb=cb)
|
||||
|
||||
# Send 2 messages and wait for them to come in
|
||||
await nc.publish("time.A.east", b'A')
|
||||
await nc.publish("time.B.east", b'B')
|
||||
await nc.publish("time.C.west", b'C')
|
||||
await nc.publish("time.D.west", b'D')
|
||||
|
||||
for i in range(0, 4):
|
||||
msg = await queue.get()
|
||||
print("Msg:", msg)
|
||||
|
||||
await nc.close()
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_arrow_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/subscribe_arrow.rb#L1-26"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby">require 'nats/client'
|
||||
require 'fiber'
|
||||
|
||||
NATS.start(servers:["nats://127.0.0.1:4222"]) do |nc|
|
||||
Fiber.new do
|
||||
f = Fiber.current
|
||||
|
||||
nc.subscribe("time.>") do |msg, reply|
|
||||
f.resume Time.now.to_f
|
||||
end
|
||||
|
||||
nc.publish("time.A.east", "A")
|
||||
nc.publish("time.B.east", "B")
|
||||
nc.publish("time.C.west", "C")
|
||||
nc.publish("time.D.west", "D")
|
||||
|
||||
# Use the response
|
||||
4.times do
|
||||
msg = Fiber.yield
|
||||
puts "Msg: #{msg}"
|
||||
end
|
||||
end.resume
|
||||
end
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_arrow_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/subscriber_samples.ts#L156-179"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">await nc.subscribe('time.>', (err, msg) => {
|
||||
// converting timezones correctly in node requires a library
|
||||
// this doesn't take into account *many* things.
|
||||
let time = "";
|
||||
switch (msg.subject) {
|
||||
case 'time.us.east':
|
||||
time = new Date().toLocaleTimeString("en-us", {timeZone: "America/New_York"});
|
||||
break;
|
||||
case 'time.us.central':
|
||||
time = new Date().toLocaleTimeString("en-us", {timeZone: "America/Chicago"});
|
||||
break;
|
||||
case 'time.us.mountain':
|
||||
time = new Date().toLocaleTimeString("en-us", {timeZone: "America/Denver"});
|
||||
break;
|
||||
case 'time.us.west':
|
||||
time = new Date().toLocaleTimeString("en-us", {timeZone: "America/Los_Angeles"});
|
||||
break;
|
||||
default:
|
||||
time = "I don't know what you are talking about Willis";
|
||||
}
|
||||
t.log(msg.subject, time);
|
||||
});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
140
docs/developer/examples/subscribe_async.html
Normal file
140
docs/developer/examples/subscribe_async.html
Normal file
@ -0,0 +1,140 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_async_go" name="subscribe_async" class="tab" checked>
|
||||
|
||||
<label for="subscribe_async_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_async_java" name="subscribe_async" class="tab">
|
||||
|
||||
<label for="subscribe_async_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_async_js" name="subscribe_async" class="tab">
|
||||
|
||||
<label for="subscribe_async_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_async_py" name="subscribe_async" class="tab">
|
||||
|
||||
<label for="subscribe_async_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_async_ruby" name="subscribe_async" class="tab">
|
||||
|
||||
<label for="subscribe_async_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_async_ts" name="subscribe_async" class="tab">
|
||||
|
||||
<label for="subscribe_async_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_async_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/subscribe_async/main.go#L11-34"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">nc, err := nats.Connect("demo.nats.io")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
// Use a WaitGroup to wait for a message to arrive
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(1)
|
||||
|
||||
// Subscribe
|
||||
if _, err := nc.Subscribe("updates", func(m *nats.Msg) {
|
||||
wg.Done()
|
||||
}); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Wait for a message to come in
|
||||
wg.Wait()
|
||||
|
||||
// Close the connection
|
||||
nc.Close()
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_async_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/SubscribeAsync.java#L14-35"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Connection nc = Nats.connect("nats://demo.nats.io:4222");
|
||||
|
||||
// Use a latch to wait for a message to arrive
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
|
||||
// Create a dispatcher and inline message handler
|
||||
Dispatcher d = nc.createDispatcher((msg) -> {
|
||||
String str = new String(msg.getData(), StandardCharsets.UTF_8);
|
||||
System.out.println(str);
|
||||
latch.countDown();
|
||||
});
|
||||
|
||||
// Subscribe
|
||||
d.subscribe("updates");
|
||||
|
||||
// Wait for a message to come in
|
||||
latch.await();
|
||||
|
||||
// Close the connection
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_async_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/subscriber_samples.js#L9-13"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">nc.subscribe("updates", (msg) => {
|
||||
t.log(msg);
|
||||
});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_async_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/subscribe_async.py#L6-24"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">nc = NATS()
|
||||
|
||||
await nc.connect(servers=["nats://demo.nats.io:4222"])
|
||||
|
||||
future = asyncio.Future()
|
||||
|
||||
async def cb(msg):
|
||||
nonlocal future
|
||||
future.set_result(msg)
|
||||
|
||||
await nc.subscribe("updates", cb=cb)
|
||||
await nc.publish("updates", b'All is Well')
|
||||
await nc.flush()
|
||||
|
||||
# Wait for message to come in
|
||||
msg = await asyncio.wait_for(future, 1)
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_async_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/subscribe_async.rb#L1-13"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby">require 'nats/client'
|
||||
|
||||
NATS.start(servers:["nats://127.0.0.1:4222"]) do |nc|
|
||||
nc.subscribe("updates") do |msg|
|
||||
puts msg
|
||||
nc.close
|
||||
end
|
||||
|
||||
nc.publish("updates", "All is Well")
|
||||
end
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_async_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/subscriber_samples.ts#L9-17"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">nc.subscribe("updates", (err, msg) => {
|
||||
if(err) {
|
||||
console.log('error', err);
|
||||
} else {
|
||||
t.log(msg.data);
|
||||
}
|
||||
});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
189
docs/developer/examples/subscribe_json.html
Normal file
189
docs/developer/examples/subscribe_json.html
Normal file
@ -0,0 +1,189 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_json_go" name="subscribe_json" class="tab" checked>
|
||||
|
||||
<label for="subscribe_json_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_json_java" name="subscribe_json" class="tab">
|
||||
|
||||
<label for="subscribe_json_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_json_js" name="subscribe_json" class="tab">
|
||||
|
||||
<label for="subscribe_json_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_json_py" name="subscribe_json" class="tab">
|
||||
|
||||
<label for="subscribe_json_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_json_ruby" name="subscribe_json" class="tab">
|
||||
|
||||
<label for="subscribe_json_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_json_ts" name="subscribe_json" class="tab">
|
||||
|
||||
<label for="subscribe_json_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_json_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/subscribe_json/main.go#L11-45"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">nc, err := nats.Connect("demo.nats.io")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
ec, err := nats.NewEncodedConn(nc, nats.JSON_ENCODER)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer ec.Close()
|
||||
|
||||
// Define the object
|
||||
type stock struct {
|
||||
Symbol string
|
||||
Price int
|
||||
}
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(1)
|
||||
|
||||
// Subscribe
|
||||
if _, err := ec.Subscribe("updates", func(s *stock) {
|
||||
log.Printf("Stock: %s - Price: %v", s.Symbol, s.Price)
|
||||
wg.Done()
|
||||
}); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Wait for a message to come in
|
||||
wg.Wait()
|
||||
|
||||
// Close the connection
|
||||
ec.Close()
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_json_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/SubscribeJSON.java#L12-57"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">class StockForJsonSub {
|
||||
public String symbol;
|
||||
public float price;
|
||||
|
||||
public String toString() {
|
||||
return symbol + " is at " + price;
|
||||
}
|
||||
}
|
||||
|
||||
public class SubscribeJSON {
|
||||
public static void main(String[] args) {
|
||||
|
||||
try {
|
||||
Connection nc = Nats.connect("nats://demo.nats.io:4222");
|
||||
|
||||
// Use a latch to wait for 10 messages to arrive
|
||||
CountDownLatch latch = new CountDownLatch(10);
|
||||
|
||||
// Create a dispatcher and inline message handler
|
||||
Dispatcher d = nc.createDispatcher((msg) -> {
|
||||
Gson gson = new Gson();
|
||||
|
||||
String json = new String(msg.getData(), StandardCharsets.UTF_8);
|
||||
StockForJsonSub stk = gson.fromJson(json, StockForJsonSub.class);
|
||||
|
||||
// Use the object
|
||||
System.out.println(stk);
|
||||
|
||||
latch.countDown();
|
||||
});
|
||||
|
||||
// Subscribe
|
||||
d.subscribe("updates");
|
||||
|
||||
// Wait for a message to come in
|
||||
latch.await();
|
||||
|
||||
// Close the connection
|
||||
nc.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_json_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/subscriber_samples.js#L76-88"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let nc = NATS.connect({
|
||||
url: "nats://demo.nats.io:4222",
|
||||
json: true
|
||||
});
|
||||
|
||||
nc.subscribe('updates', (msg) => {
|
||||
if(msg && msg.ticker === 'TSLA') {
|
||||
t.log('got message:', msg);
|
||||
}
|
||||
});
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_json_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/subscribe_json.py#L1-23"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">import asyncio
|
||||
import json
|
||||
from nats.aio.client import Client as NATS
|
||||
from nats.aio.errors import ErrTimeout
|
||||
|
||||
async def run(loop):
|
||||
nc = NATS()
|
||||
|
||||
await nc.connect(servers=["nats://127.0.0.1:4222"], loop=loop)
|
||||
|
||||
async def message_handler(msg):
|
||||
data = json.loads(msg.data.decode())
|
||||
print(data)
|
||||
|
||||
sid = await nc.subscribe("updates", cb=message_handler)
|
||||
await nc.flush()
|
||||
|
||||
await nc.auto_unsubscribe(sid, 2)
|
||||
await nc.publish("updates", json.dumps({"symbol": "GOOG", "price": 1200 }).encode())
|
||||
await asyncio.sleep(1, loop=loop)
|
||||
await nc.close()
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_json_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/subscribe_json.rb#L1-13"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby">require 'nats/client'
|
||||
require 'json'
|
||||
|
||||
NATS.start(servers:["nats://127.0.0.1:4222"]) do |nc|
|
||||
nc.subscribe("updates") do |msg|
|
||||
m = JSON.parse(msg)
|
||||
|
||||
# {"symbol"=>"GOOG", "price"=>12}
|
||||
p m
|
||||
end
|
||||
end
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_json_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/subscriber_samples.ts#L70-80"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">let nc = await connect({
|
||||
url: "nats://demo.nats.io:4222",
|
||||
payload: Payload.JSON
|
||||
});
|
||||
|
||||
nc.subscribe('updates', (err, msg) => {
|
||||
t.log('got message:', msg.data ? msg.data : "no payload");
|
||||
});
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
143
docs/developer/examples/subscribe_queue.html
Normal file
143
docs/developer/examples/subscribe_queue.html
Normal file
@ -0,0 +1,143 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_queue_go" name="subscribe_queue" class="tab" checked>
|
||||
|
||||
<label for="subscribe_queue_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_queue_java" name="subscribe_queue" class="tab">
|
||||
|
||||
<label for="subscribe_queue_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_queue_js" name="subscribe_queue" class="tab">
|
||||
|
||||
<label for="subscribe_queue_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_queue_py" name="subscribe_queue" class="tab">
|
||||
|
||||
<label for="subscribe_queue_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_queue_ruby" name="subscribe_queue" class="tab">
|
||||
|
||||
<label for="subscribe_queue_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_queue_ts" name="subscribe_queue" class="tab">
|
||||
|
||||
<label for="subscribe_queue_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_queue_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/subscribe_queue/main.go#L11-34"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">nc, err := nats.Connect("demo.nats.io")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
// Use a WaitGroup to wait for 10 messages to arrive
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(10)
|
||||
|
||||
// Create a queue subscription on "updates" with queue name "workers"
|
||||
if _, err := nc.QueueSubscribe("updates", "worker", func(m *nats.Msg) {
|
||||
wg.Done()
|
||||
}); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Wait for messages to come in
|
||||
wg.Wait()
|
||||
|
||||
// Close the connection
|
||||
nc.Close()
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_queue_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/SubscribeQueue.java#L14-35"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Connection nc = Nats.connect("nats://demo.nats.io:4222");
|
||||
|
||||
// Use a latch to wait for 10 messages to arrive
|
||||
CountDownLatch latch = new CountDownLatch(10);
|
||||
|
||||
// Create a dispatcher and inline message handler
|
||||
Dispatcher d = nc.createDispatcher((msg) -> {
|
||||
String str = new String(msg.getData(), StandardCharsets.UTF_8);
|
||||
System.out.println(str);
|
||||
latch.countDown();
|
||||
});
|
||||
|
||||
// Subscribe
|
||||
d.subscribe("updates", "workers");
|
||||
|
||||
// Wait for a message to come in
|
||||
latch.await();
|
||||
|
||||
// Close the connection
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_queue_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/subscriber_samples.js#L217-221"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">nc.subscribe('updates', {queue: "workers"}, (msg) => {
|
||||
t.log('worker got message', msg);
|
||||
});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_queue_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/subscribe_queue.py#L6-23"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">nc = NATS()
|
||||
|
||||
await nc.connect(servers=["nats://demo.nats.io:4222"])
|
||||
|
||||
future = asyncio.Future()
|
||||
|
||||
async def cb(msg):
|
||||
nonlocal future
|
||||
future.set_result(msg)
|
||||
|
||||
await nc.subscribe("updates", queue="workers", cb=cb)
|
||||
await nc.publish("updates", b'All is Well')
|
||||
|
||||
msg = await asyncio.wait_for(future, 1)
|
||||
print("Msg", msg)
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_queue_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/subscribe_queue.rb#L1-21"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby">require 'nats/client'
|
||||
require 'fiber'
|
||||
|
||||
NATS.start(servers:["nats://127.0.0.1:4222"]) do |nc|
|
||||
Fiber.new do
|
||||
f = Fiber.current
|
||||
|
||||
nc.subscribe("updates", queue: "worker") do |msg, reply|
|
||||
f.resume Time.now
|
||||
end
|
||||
|
||||
nc.publish("updates", "A")
|
||||
|
||||
# Use the response
|
||||
msg = Fiber.yield
|
||||
puts "Msg: #{msg}"
|
||||
end.resume
|
||||
end
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_queue_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/subscriber_samples.ts#L193-197"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">await nc.subscribe('updates', (err, msg) => {
|
||||
t.log('worker got message', msg.data);
|
||||
}, {queue: "workers"});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
193
docs/developer/examples/subscribe_star.html
Normal file
193
docs/developer/examples/subscribe_star.html
Normal file
@ -0,0 +1,193 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_star_go" name="subscribe_star" class="tab" checked>
|
||||
|
||||
<label for="subscribe_star_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_star_java" name="subscribe_star" class="tab">
|
||||
|
||||
<label for="subscribe_star_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_star_js" name="subscribe_star" class="tab">
|
||||
|
||||
<label for="subscribe_star_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_star_py" name="subscribe_star" class="tab">
|
||||
|
||||
<label for="subscribe_star_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_star_ruby" name="subscribe_star" class="tab">
|
||||
|
||||
<label for="subscribe_star_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_star_ts" name="subscribe_star" class="tab">
|
||||
|
||||
<label for="subscribe_star_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_star_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/subscribe_star/main.go#L11-35"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">nc, err := nats.Connect("demo.nats.io")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
// Use a WaitGroup to wait for 2 messages to arrive
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(2)
|
||||
|
||||
// Subscribe
|
||||
if _, err := nc.Subscribe("time.*.east", func(m *nats.Msg) {
|
||||
log.Printf("%s: %s", m.Subject, m.Data)
|
||||
wg.Done()
|
||||
}); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Wait for the 2 messages to come in
|
||||
wg.Wait()
|
||||
|
||||
// Close the connection
|
||||
nc.Close()
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_star_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/SubscribeStar.java#L14-36"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Connection nc = Nats.connect("nats://demo.nats.io:4222");
|
||||
|
||||
// Use a latch to wait for 2 messages to arrive
|
||||
CountDownLatch latch = new CountDownLatch(2);
|
||||
|
||||
// Create a dispatcher and inline message handler
|
||||
Dispatcher d = nc.createDispatcher((msg) -> {
|
||||
String subject = msg.getSubject();
|
||||
String str = new String(msg.getData(), StandardCharsets.UTF_8);
|
||||
System.out.println(subject + ": " + str);
|
||||
latch.countDown();
|
||||
});
|
||||
|
||||
// Subscribe
|
||||
d.subscribe("time.*.east");
|
||||
|
||||
// Wait for messages to come in
|
||||
latch.await();
|
||||
|
||||
// Close the connection
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_star_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/subscriber_samples.js#L134-157"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">nc.subscribe('time.us.*', (msg, reply, subject) => {
|
||||
// converting timezones correctly in node requires a library
|
||||
// this doesn't take into account *many* things.
|
||||
let time = "";
|
||||
switch (subject) {
|
||||
case 'time.us.east':
|
||||
time = new Date().toLocaleTimeString("en-us", {timeZone: "America/New_York"});
|
||||
break;
|
||||
case 'time.us.central':
|
||||
time = new Date().toLocaleTimeString("en-us", {timeZone: "America/Chicago"});
|
||||
break;
|
||||
case 'time.us.mountain':
|
||||
time = new Date().toLocaleTimeString("en-us", {timeZone: "America/Denver"});
|
||||
break;
|
||||
case 'time.us.west':
|
||||
time = new Date().toLocaleTimeString("en-us", {timeZone: "America/Los_Angeles"});
|
||||
break;
|
||||
default:
|
||||
time = "I don't know what you are talking about Willis";
|
||||
}
|
||||
t.log(subject, time);
|
||||
});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_star_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/subscribe_star.py#L6-28"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">nc = NATS()
|
||||
|
||||
await nc.connect(servers=["nats://demo.nats.io:4222"])
|
||||
|
||||
# Use queue to wait for 2 messages to arrive
|
||||
queue = asyncio.Queue()
|
||||
async def cb(msg):
|
||||
await queue.put_nowait(msg)
|
||||
|
||||
await nc.subscribe("time.*.east", cb=cb)
|
||||
|
||||
# Send 2 messages and wait for them to come in
|
||||
await nc.publish("time.A.east", b'A')
|
||||
await nc.publish("time.B.east", b'B')
|
||||
|
||||
msg_A = await queue.get()
|
||||
msg_B = await queue.get()
|
||||
|
||||
print("Msg A:", msg_A)
|
||||
print("Msg B:", msg_B)
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_star_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/subscribe_star.rb#L1-26"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby">require 'nats/client'
|
||||
require 'fiber'
|
||||
|
||||
NATS.start(servers:["nats://127.0.0.1:4222"]) do |nc|
|
||||
Fiber.new do
|
||||
f = Fiber.current
|
||||
|
||||
nc.subscribe("time.*.east") do |msg, reply|
|
||||
f.resume Time.now
|
||||
end
|
||||
|
||||
nc.publish("time.A.east", "A")
|
||||
nc.publish("time.B.east", "B")
|
||||
|
||||
# Use the response
|
||||
msg_A = Fiber.yield
|
||||
puts "Msg A: #{msg_A}"
|
||||
|
||||
msg_B = Fiber.yield
|
||||
puts "Msg B: #{msg_B}"
|
||||
|
||||
end.resume
|
||||
end
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_star_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/subscriber_samples.ts#L119-142"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">await nc.subscribe('time.us.*', (err, msg) => {
|
||||
// converting timezones correctly in node requires a library
|
||||
// this doesn't take into account *many* things.
|
||||
let time = "";
|
||||
switch (msg.subject) {
|
||||
case 'time.us.east':
|
||||
time = new Date().toLocaleTimeString("en-us", {timeZone: "America/New_York"});
|
||||
break;
|
||||
case 'time.us.central':
|
||||
time = new Date().toLocaleTimeString("en-us", {timeZone: "America/Chicago"});
|
||||
break;
|
||||
case 'time.us.mountain':
|
||||
time = new Date().toLocaleTimeString("en-us", {timeZone: "America/Denver"});
|
||||
break;
|
||||
case 'time.us.west':
|
||||
time = new Date().toLocaleTimeString("en-us", {timeZone: "America/Los_Angeles"});
|
||||
break;
|
||||
default:
|
||||
time = "I don't know what you are talking about Willis";
|
||||
}
|
||||
console.log(msg.subject, time);
|
||||
});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
100
docs/developer/examples/subscribe_sync.html
Normal file
100
docs/developer/examples/subscribe_sync.html
Normal file
@ -0,0 +1,100 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_sync_go" name="subscribe_sync" class="tab" checked>
|
||||
|
||||
<label for="subscribe_sync_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_sync_java" name="subscribe_sync" class="tab">
|
||||
|
||||
<label for="subscribe_sync_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_sync_js" name="subscribe_sync" class="tab">
|
||||
|
||||
<label for="subscribe_sync_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_sync_py" name="subscribe_sync" class="tab">
|
||||
|
||||
<label for="subscribe_sync_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_sync_ruby" name="subscribe_sync" class="tab">
|
||||
|
||||
<label for="subscribe_sync_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_sync_ts" name="subscribe_sync" class="tab">
|
||||
|
||||
<label for="subscribe_sync_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_sync_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/subscribe_sync/main.go#L11-35"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">nc, err := nats.Connect("demo.nats.io")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
// Subscribe
|
||||
sub, err := nc.SubscribeSync("updates")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Wait for a message
|
||||
msg, err := sub.NextMsg(10 * time.Second)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Use the response
|
||||
log.Printf("Reply: %s", msg.Data)
|
||||
|
||||
// Close the connection
|
||||
nc.Close()
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_sync_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/SubscribeSync.java#L15-29"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Connection nc = Nats.connect("nats://demo.nats.io:4222");
|
||||
|
||||
// Subscribe
|
||||
Subscription sub = nc.subscribe("updates");
|
||||
|
||||
// Read a message
|
||||
Message msg = sub.nextMessage(Duration.ZERO);
|
||||
|
||||
String str = new String(msg.getData(), StandardCharsets.UTF_8);
|
||||
System.out.println(str);
|
||||
|
||||
// Close the connection
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_sync_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/subscriber_samples.js#L246-248"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">// node-nats subscriptions are always async.
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_sync_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/notapplicable.txt#L9-11"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python"># Asyncio NATS client currently does not have a sync subscribe API
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_sync_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/notapplicable.txt#L13-15"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby"># The Ruby NATS client subscriptions are all async.
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_sync_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/subscriber_samples.ts#L238-240"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">// ts-nats subscriptions are always async.
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
162
docs/developer/examples/subscribe_w_reply.html
Normal file
162
docs/developer/examples/subscribe_w_reply.html
Normal file
@ -0,0 +1,162 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_w_reply_go" name="subscribe_w_reply" class="tab" checked>
|
||||
|
||||
<label for="subscribe_w_reply_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_w_reply_java" name="subscribe_w_reply" class="tab">
|
||||
|
||||
<label for="subscribe_w_reply_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_w_reply_js" name="subscribe_w_reply" class="tab">
|
||||
|
||||
<label for="subscribe_w_reply_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_w_reply_py" name="subscribe_w_reply" class="tab">
|
||||
|
||||
<label for="subscribe_w_reply_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_w_reply_ruby" name="subscribe_w_reply" class="tab">
|
||||
|
||||
<label for="subscribe_w_reply_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="subscribe_w_reply_ts" name="subscribe_w_reply" class="tab">
|
||||
|
||||
<label for="subscribe_w_reply_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_w_reply_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/subscribe_w_reply/main.go#L11-39"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">nc, err := nats.Connect("demo.nats.io")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
// Subscribe
|
||||
sub, err := nc.SubscribeSync("time")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Read a message
|
||||
msg, err := sub.NextMsg(10 * time.Second)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Get the time
|
||||
timeAsBytes := []byte(time.Now().String())
|
||||
|
||||
// Send the time
|
||||
nc.Publish(msg.Reply, timeAsBytes)
|
||||
|
||||
// Flush and close the connection
|
||||
nc.Flush()
|
||||
nc.Close()
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_w_reply_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/SubscribeWithReply.java#L17-37"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Connection nc = Nats.connect("nats://demo.nats.io:4222");
|
||||
|
||||
// Subscribe
|
||||
Subscription sub = nc.subscribe("time");
|
||||
|
||||
// Read a message
|
||||
Message msg = sub.nextMessage(Duration.ZERO);
|
||||
|
||||
// Get the time
|
||||
Calendar cal = Calendar.getInstance();
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
|
||||
byte[] timeAsBytes = sdf.format(cal.getTime()).getBytes(StandardCharsets.UTF_8);
|
||||
|
||||
// Send the time
|
||||
nc.publish(msg.getReplyTo(), timeAsBytes);
|
||||
|
||||
// Flush and close the connection
|
||||
nc.flush(Duration.ZERO);
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_w_reply_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/subscriber_samples.js#L28-35"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">// set up a subscription to process a request
|
||||
nc.subscribe('time', (msg, reply) => {
|
||||
if (msg.reply) {
|
||||
nc.publish(msg.reply, new Date().toLocaleTimeString());
|
||||
}
|
||||
});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_w_reply_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/subscribe_w_reply.py#L8-31"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">nc = NATS()
|
||||
|
||||
await nc.connect(servers=["nats://demo.nats.io:4222"])
|
||||
|
||||
future = asyncio.Future()
|
||||
|
||||
async def cb(msg):
|
||||
nonlocal future
|
||||
future.set_result(msg)
|
||||
|
||||
await nc.subscribe("time", cb=cb)
|
||||
|
||||
await nc.publish_request("time", new_inbox(), b'What is the time?')
|
||||
await nc.flush()
|
||||
|
||||
# Read the message
|
||||
msg = await asyncio.wait_for(future, 1)
|
||||
|
||||
# Send the time
|
||||
time_as_bytes = "{}".format(datetime.now()).encode()
|
||||
await nc.publish(msg.reply, time_as_bytes)
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_w_reply_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/subscribe_w_reply.rb#L1-22"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby">require 'nats/client'
|
||||
require 'fiber'
|
||||
|
||||
NATS.start(servers:["nats://127.0.0.1:4222"]) do |nc|
|
||||
Fiber.new do
|
||||
f = Fiber.current
|
||||
|
||||
nc.subscribe("time") do |msg, reply|
|
||||
f.resume Time.now
|
||||
end
|
||||
|
||||
nc.publish("time", 'What is the time?', NATS.create_inbox)
|
||||
|
||||
# Use the response
|
||||
msg = Fiber.yield
|
||||
puts "Reply: #{msg}"
|
||||
|
||||
end.resume
|
||||
end
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="subscribe_w_reply_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/subscriber_samples.ts#L29-38"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">// set up a subscription to process a request
|
||||
await nc.subscribe('time', (err, msg) => {
|
||||
if (msg.reply) {
|
||||
nc.publish(msg.reply, new Date().toLocaleTimeString());
|
||||
} else {
|
||||
t.log('got a request for the time, but no reply subject was set.');
|
||||
}
|
||||
});
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
168
docs/developer/examples/unsubscribe.html
Normal file
168
docs/developer/examples/unsubscribe.html
Normal file
@ -0,0 +1,168 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="unsubscribe_go" name="unsubscribe" class="tab" checked>
|
||||
|
||||
<label for="unsubscribe_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="unsubscribe_java" name="unsubscribe" class="tab">
|
||||
|
||||
<label for="unsubscribe_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="unsubscribe_js" name="unsubscribe" class="tab">
|
||||
|
||||
<label for="unsubscribe_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="unsubscribe_py" name="unsubscribe" class="tab">
|
||||
|
||||
<label for="unsubscribe_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="unsubscribe_ruby" name="unsubscribe" class="tab">
|
||||
|
||||
<label for="unsubscribe_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="unsubscribe_ts" name="unsubscribe" class="tab">
|
||||
|
||||
<label for="unsubscribe_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="unsubscribe_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/unsubscribe/main.go#L10-37"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">nc, err := nats.Connect("demo.nats.io")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
// Sync Subscription
|
||||
sub, err := nc.SubscribeSync("updates")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if err := sub.Unsubscribe(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Async Subscription
|
||||
sub, err = nc.Subscribe("updates", func(_ *nats.Msg) {})
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if err := sub.Unsubscribe(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Close the connection
|
||||
nc.Close()
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="unsubscribe_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/Unsubscribe.java#L14-31"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Connection nc = Nats.connect("nats://demo.nats.io:4222");
|
||||
Dispatcher d = nc.createDispatcher((msg) -> {
|
||||
String str = new String(msg.getData(), StandardCharsets.UTF_8);
|
||||
System.out.println(str);
|
||||
});
|
||||
|
||||
// Sync Subscription
|
||||
Subscription sub = nc.subscribe("updates");
|
||||
sub.unsubscribe();
|
||||
|
||||
// Async Subscription
|
||||
d.subscribe("updates");
|
||||
d.unsubscribe("updates");
|
||||
|
||||
// Close the connection
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="unsubscribe_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/subscriber_samples.js#L54-65"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">// set up a subscription to process a request
|
||||
let sub = nc.subscribe(NATS.createInbox(), (msg, reply) => {
|
||||
if (msg.reply) {
|
||||
nc.publish(reply, new Date().toLocaleTimeString());
|
||||
}
|
||||
});
|
||||
|
||||
// without arguments the subscription will cancel when the server receives it
|
||||
// you can also specify how many messages are expected by the subscription
|
||||
nc.unsubscribe(sub);
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="unsubscribe_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/unsubscribe.py#L6-26"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">nc = NATS()
|
||||
|
||||
await nc.connect(servers=["nats://demo.nats.io:4222"])
|
||||
|
||||
future = asyncio.Future()
|
||||
|
||||
async def cb(msg):
|
||||
nonlocal future
|
||||
future.set_result(msg)
|
||||
|
||||
sid = await nc.subscribe("updates", cb=cb)
|
||||
await nc.publish("updates", b'All is Well')
|
||||
|
||||
# Remove interest in subject
|
||||
await nc.unsubscribe(sid)
|
||||
|
||||
# Won't be received...
|
||||
await nc.publish("updates", b'...')
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="unsubscribe_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/unsubscribe.rb#L1-27"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby">require 'nats/client'
|
||||
require 'fiber'
|
||||
|
||||
NATS.start(servers:["nats://127.0.0.1:4222"]) do |nc|
|
||||
Fiber.new do
|
||||
f = Fiber.current
|
||||
|
||||
sid = nc.subscribe("time") do |msg, reply|
|
||||
f.resume Time.now
|
||||
end
|
||||
|
||||
nc.publish("time", 'What is the time?', NATS.create_inbox)
|
||||
|
||||
# Use the response
|
||||
msg = Fiber.yield
|
||||
puts "Reply: #{msg}"
|
||||
|
||||
nc.unsubscribe(sid)
|
||||
|
||||
# Won't be received
|
||||
nc.publish("time", 'What is the time?', NATS.create_inbox)
|
||||
|
||||
end.resume
|
||||
end
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="unsubscribe_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/subscriber_samples.ts#L51-64"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">// set up a subscription to process a request
|
||||
let sub = await nc.subscribe(createInbox(), (err, msg) => {
|
||||
if (msg.reply) {
|
||||
nc.publish(msg.reply, new Date().toLocaleTimeString());
|
||||
} else {
|
||||
t.log('got a request for the time, but no reply subject was set.');
|
||||
}
|
||||
});
|
||||
|
||||
// without arguments the subscription will cancel when the server receives it
|
||||
// you can also specify how many messages are expected by the subscription
|
||||
sub.unsubscribe();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
167
docs/developer/examples/unsubscribe_auto.html
Normal file
167
docs/developer/examples/unsubscribe_auto.html
Normal file
@ -0,0 +1,167 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="unsubscribe_auto_go" name="unsubscribe_auto" class="tab" checked>
|
||||
|
||||
<label for="unsubscribe_auto_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="unsubscribe_auto_java" name="unsubscribe_auto" class="tab">
|
||||
|
||||
<label for="unsubscribe_auto_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="unsubscribe_auto_js" name="unsubscribe_auto" class="tab">
|
||||
|
||||
<label for="unsubscribe_auto_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="unsubscribe_auto_py" name="unsubscribe_auto" class="tab">
|
||||
|
||||
<label for="unsubscribe_auto_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="unsubscribe_auto_ruby" name="unsubscribe_auto" class="tab">
|
||||
|
||||
<label for="unsubscribe_auto_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="unsubscribe_auto_ts" name="unsubscribe_auto" class="tab">
|
||||
|
||||
<label for="unsubscribe_auto_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="unsubscribe_auto_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/unsubscribe_auto/main.go#L10-37"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">nc, err := nats.Connect("demo.nats.io")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
// Sync Subscription
|
||||
sub, err := nc.SubscribeSync("updates")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if err := sub.AutoUnsubscribe(1); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Async Subscription
|
||||
sub, err = nc.Subscribe("updates", func(_ *nats.Msg) {})
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if err := sub.AutoUnsubscribe(1); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Close the connection
|
||||
nc.Close()
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="unsubscribe_auto_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/AutoUnsubscribe.java#L14-31"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Connection nc = Nats.connect("nats://demo.nats.io:4222");
|
||||
Dispatcher d = nc.createDispatcher((msg) -> {
|
||||
String str = new String(msg.getData(), StandardCharsets.UTF_8);
|
||||
System.out.println(str);
|
||||
});
|
||||
|
||||
// Sync Subscription
|
||||
Subscription sub = nc.subscribe("updates");
|
||||
sub.unsubscribe(1);
|
||||
|
||||
// Async Subscription
|
||||
d.subscribe("updates");
|
||||
d.unsubscribe("updates", 1);
|
||||
|
||||
// Close the connection
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="unsubscribe_auto_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/subscriber_samples.js#L105-120"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">// `max` specifies the number of messages that the server will forward.
|
||||
// The server will auto-cancel.
|
||||
let opts = {max: 10};
|
||||
let sub = nc.subscribe(NATS.createInbox(), opts, (msg) => {
|
||||
t.log(msg);
|
||||
});
|
||||
|
||||
// another way after 10 messages
|
||||
let sub2 = nc.subscribe(NATS.createInbox(), (err, msg) => {
|
||||
t.log(msg.data);
|
||||
});
|
||||
// if the subscription already received 10 messages, the handler
|
||||
// won't get any more messages
|
||||
nc.unsubscribe(sub2, 10);
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="unsubscribe_auto_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/unsubscribe_auto.py#L6-21"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">nc = NATS()
|
||||
|
||||
await nc.connect(servers=["nats://demo.nats.io:4222"])
|
||||
|
||||
async def cb(msg):
|
||||
print(msg)
|
||||
|
||||
sid = await nc.subscribe("updates", cb=cb)
|
||||
await nc.auto_unsubscribe(sid, 1)
|
||||
await nc.publish("updates", b'All is Well')
|
||||
|
||||
# Won't be received...
|
||||
await nc.publish("updates", b'...')
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="unsubscribe_auto_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/unsubscribe_auto.rb#L1-25"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby">require 'nats/client'
|
||||
require 'fiber'
|
||||
|
||||
NATS.start(servers:["nats://127.0.0.1:4222"]) do |nc|
|
||||
Fiber.new do
|
||||
f = Fiber.current
|
||||
|
||||
nc.subscribe("time", max: 1) do |msg, reply|
|
||||
f.resume Time.now
|
||||
end
|
||||
|
||||
nc.publish("time", 'What is the time?', NATS.create_inbox)
|
||||
|
||||
# Use the response
|
||||
msg = Fiber.yield
|
||||
puts "Reply: #{msg}"
|
||||
|
||||
# Won't be received
|
||||
nc.publish("time", 'What is the time?', NATS.create_inbox)
|
||||
|
||||
end.resume
|
||||
end
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="unsubscribe_auto_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/subscriber_samples.ts#L94-109"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">// `max` specifies the number of messages that the server will forward.
|
||||
// The server will auto-cancel.
|
||||
let opts = {max: 10};
|
||||
let sub = await nc.subscribe(createInbox(), (err, msg) => {
|
||||
t.log(msg.data);
|
||||
}, opts);
|
||||
|
||||
// another way after 10 messages
|
||||
let sub2 = await nc.subscribe(createInbox(), (err, msg) => {
|
||||
t.log(msg.data);
|
||||
});
|
||||
// if the subscription already received 10 messages, the handler
|
||||
// won't get any more messages
|
||||
sub2.unsubscribe(10);
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
134
docs/developer/examples/wildcard_tester.html
Normal file
134
docs/developer/examples/wildcard_tester.html
Normal file
@ -0,0 +1,134 @@
|
||||
|
||||
<div class="tab-wrap">
|
||||
|
||||
|
||||
<input type="radio" id="wildcard_tester_go" name="wildcard_tester" class="tab" checked>
|
||||
|
||||
<label for="wildcard_tester_go" class="api-lang" data-language="go">Go</label>
|
||||
|
||||
|
||||
<input type="radio" id="wildcard_tester_java" name="wildcard_tester" class="tab">
|
||||
|
||||
<label for="wildcard_tester_java" class="api-lang" data-language="java">Java</label>
|
||||
|
||||
|
||||
<input type="radio" id="wildcard_tester_js" name="wildcard_tester" class="tab">
|
||||
|
||||
<label for="wildcard_tester_js" class="api-lang" data-language="js">JavaScript</label>
|
||||
|
||||
|
||||
<input type="radio" id="wildcard_tester_py" name="wildcard_tester" class="tab">
|
||||
|
||||
<label for="wildcard_tester_py" class="api-lang" data-language="py">Python</label>
|
||||
|
||||
|
||||
<input type="radio" id="wildcard_tester_ruby" name="wildcard_tester" class="tab">
|
||||
|
||||
<label for="wildcard_tester_ruby" class="api-lang" data-language="ruby">Ruby</label>
|
||||
|
||||
|
||||
<input type="radio" id="wildcard_tester_ts" name="wildcard_tester" class="tab">
|
||||
|
||||
<label for="wildcard_tester_ts" class="api-lang" data-language="ts">TypeScript</label>
|
||||
|
||||
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="wildcard_tester_go_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/go-nats-examples/blob/master/api-examples/wildcard_tester/main.go#L11-41"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-go">nc, err := nats.Connect("demo.nats.io")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer nc.Close()
|
||||
|
||||
zoneID, err := time.LoadLocation("America/New_York")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
now := time.Now()
|
||||
zoneDateTime := now.In(zoneID)
|
||||
formatted := zoneDateTime.String()
|
||||
|
||||
nc.Publish("time.us.east", []byte(formatted))
|
||||
nc.Publish("time.us.east.atlanta", []byte(formatted))
|
||||
|
||||
zoneID, err = time.LoadLocation("Europe/Warsaw")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
zoneDateTime = now.In(zoneID)
|
||||
formatted = zoneDateTime.String()
|
||||
|
||||
nc.Publish("time.eu.east", []byte(formatted))
|
||||
nc.Publish("time.eu.east.warsaw", []byte(formatted))
|
||||
|
||||
// Close the connection
|
||||
nc.Close()
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="wildcard_tester_java_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/java-nats-examples/blob/master/src/main/java/io/nats/examples/PublishForWildcards.java#L17-34"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-java">Connection nc = Nats.connect("nats://demo.nats.io:4222");
|
||||
ZoneId zoneId = ZoneId.of("America/New_York");
|
||||
ZonedDateTime zonedDateTime = ZonedDateTime.ofInstant(Instant.now(), zoneId);
|
||||
String formatted = zonedDateTime.format(DateTimeFormatter.ISO_ZONED_DATE_TIME);
|
||||
|
||||
nc.publish("time.us.east", formatted.getBytes(StandardCharsets.UTF_8));
|
||||
nc.publish("time.us.east.atlanta", formatted.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
zoneId = ZoneId.of("Europe/Warsaw");
|
||||
zonedDateTime = ZonedDateTime.ofInstant(Instant.now(), zoneId);
|
||||
formatted = zonedDateTime.format(DateTimeFormatter.ISO_ZONED_DATE_TIME);
|
||||
nc.publish("time.eu.east", formatted.getBytes(StandardCharsets.UTF_8));
|
||||
nc.publish("time.eu.east.warsaw", formatted.getBytes(StandardCharsets.UTF_8));
|
||||
|
||||
nc.flush(Duration.ZERO);
|
||||
nc.close();
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="wildcard_tester_js_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/node-nats-examples/blob/master/src/publisher_samples.js#L138-143"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">nc.publish('time.us.east');
|
||||
nc.publish('time.us.central');
|
||||
nc.publish('time.us.mountain');
|
||||
nc.publish('time.us.west');
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="wildcard_tester_py_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/asyncio-nats-examples/blob/master/wildcard_tester.py#L6-19"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-python">nc = NATS()
|
||||
|
||||
await nc.connect(servers=["nats://demo.nats.io:4222"])
|
||||
|
||||
await nc.publish("time.us.east", b'...')
|
||||
await nc.publish("time.us.east.atlanta", b'...')
|
||||
|
||||
await nc.publish("time.eu.east", b'...')
|
||||
await nc.publish("time.eu.east.warsaw", b'...')
|
||||
|
||||
await nc.close()
|
||||
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="wildcard_tester_ruby_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ruby-nats-examples/blob/master/wildcard_tester.rb#L2-12"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-ruby">NATS.start do |nc|
|
||||
nc.publish("time.us.east", '...')
|
||||
nc.publish("time.us.east.atlanta", '...')
|
||||
|
||||
nc.publish("time.eu.east", '...')
|
||||
nc.publish("time.eu.east.warsaw", '...')
|
||||
|
||||
nc.drain
|
||||
end
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
<div class="tab__content">
|
||||
<pre id="wildcard_tester_ts_content"><a class="toolbar-icons pull-right" target="_blank" href="https://github.com/nats-io/ts-nats-examples/blob/master/src/publisher_samples.ts#L139-144"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="language-javascript">nc.publish('time.us.east');
|
||||
nc.publish('time.us.central');
|
||||
nc.publish('time.us.mountain');
|
||||
nc.publish('time.us.west');
|
||||
</code></pre>
|
||||
</div>
|
||||
|
||||
</div>
|
871
docs/developer/index.html
Normal file
871
docs/developer/index.html
Normal file
@ -0,0 +1,871 @@
|
||||
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="" >
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||||
<title>Developing with NATS · GitBook</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="description" content="">
|
||||
<meta name="generator" content="GitBook 3.2.3">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/style.css">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
|
||||
<link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
|
||||
|
||||
|
||||
<link rel="next" href="connecting.html" />
|
||||
|
||||
|
||||
<link rel="prev" href="../nats_server/windows_srv.html" />
|
||||
|
||||
|
||||
<link rel="stylesheet" href="https://cdn.materialdesignicons.com/3.6.95/css/materialdesignicons.min.css">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<div class="book">
|
||||
<div class="book-summary">
|
||||
|
||||
|
||||
<div id="book-search-input" role="search">
|
||||
<input type="text" placeholder="Type to search" />
|
||||
</div>
|
||||
|
||||
|
||||
<nav role="navigation">
|
||||
|
||||
|
||||
|
||||
<ul class="summary">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.1" data-path="../">
|
||||
|
||||
<a href="../">
|
||||
|
||||
|
||||
Introduction
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.1.1" data-path="../nats_server/">
|
||||
|
||||
<a href="../nats_server/">
|
||||
|
||||
|
||||
NATS Server
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.1.1.1" data-path="../nats_server/installation.html">
|
||||
|
||||
<a href="../nats_server/installation.html">
|
||||
|
||||
|
||||
Installing
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.2" data-path="../nats_server/running.html">
|
||||
|
||||
<a href="../nats_server/running.html">
|
||||
|
||||
|
||||
Running
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.3" data-path="../nats_server/clients.html">
|
||||
|
||||
<a href="../nats_server/clients.html">
|
||||
|
||||
|
||||
Clients
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.4" data-path="../nats_server/flags.html">
|
||||
|
||||
<a href="../nats_server/flags.html">
|
||||
|
||||
|
||||
Flags
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.5" data-path="../nats_server/configuration.html">
|
||||
|
||||
<a href="../nats_server/configuration.html">
|
||||
|
||||
|
||||
Configuration File
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.6" data-path="../nats_server/signals.html">
|
||||
|
||||
<a href="../nats_server/signals.html">
|
||||
|
||||
|
||||
Signals
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.7" data-path="../nats_server/windows_srv.html">
|
||||
|
||||
<a href="../nats_server/windows_srv.html">
|
||||
|
||||
|
||||
Window Service
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter active" data-level="1.2" data-path="./">
|
||||
|
||||
<a href="./">
|
||||
|
||||
|
||||
Developing with NATS
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.2.1" data-path="connecting.html">
|
||||
|
||||
<a href="connecting.html">
|
||||
|
||||
|
||||
Connecting
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
|
||||
<li class="divider"></li>
|
||||
|
||||
<li>
|
||||
<a href="https://www.gitbook.com" target="blank" class="gitbook-link">
|
||||
Published with GitBook
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
</nav>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="book-body">
|
||||
|
||||
<div class="body-inner">
|
||||
|
||||
|
||||
|
||||
<div class="book-header" role="navigation">
|
||||
|
||||
|
||||
<!-- Title -->
|
||||
<h1>
|
||||
<i class="fa fa-circle-o-notch fa-spin"></i>
|
||||
<a href=".." >Developing with NATS</a>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="page-wrapper" tabindex="-1" role="main">
|
||||
<div class="page-inner">
|
||||
|
||||
<div id="book-search-results">
|
||||
<div class="search-noresults">
|
||||
|
||||
<section class="normal markdown-section">
|
||||
|
||||
<h1 id="nats-messaging-concepts">NATS Messaging Concepts</h1>
|
||||
<p>NATS messaging involves the electronic exchange of data among computer applications and provides a layer between the application and the underlying physical network. Application data is encoded as a message and sent by a publisher. The message is received, decoded, and processed by one or more subscribers. A subscriber can process a NATS message synchronously or asynchronously, depending on the client library used. </p>
|
||||
<h2 id="asynchronous">Asynchronous</h2>
|
||||
<p>Asynchronous processing uses a callback message handler to process messages. When a message arrives, the registered callback handler receives control to process the message. The client or the consuming application is not blocked from performing other work while it is waiting for a message. Asynchronous processing lets you create multi-threaded dispatching designs.</p>
|
||||
<h2 id="synchronous">Synchronous</h2>
|
||||
<p>Synchronous processing requires that application code explicitly call a method to process an incoming message. Typically the message request is a blocking call that suspends processing until a message becomes available and if no message is available, the period for which the message processing call blocks, would be set by the client. Synchronous processing is typically used by a server whose purpose is to wait for and process incoming request messages and to send replies to the requesting application.</p>
|
||||
<div class="graphviz"><code data-viz="dot">
|
||||
graph nats {
|
||||
graph [splines=ortho, nodesep=1];
|
||||
|
||||
publisher [shape="record", label="{Application 1 | NATS Publisher}"];
|
||||
application [shape="record", label="{Application 3 | }"];
|
||||
gnatsd [shape="box", label="", width=4, height=0, penwidth=1];
|
||||
subscriber [shape="record", label="{ NATS Subscriber | Application 2}"];
|
||||
|
||||
publisher:nats -- gnatsd [penwidth=2];
|
||||
application:nats -- gnatsd;
|
||||
gnatsd -- subscriber:nats [penwidth=2, dir="forward"];
|
||||
}
|
||||
</code></div>
|
||||
|
||||
<p>NATS makes it easy for programs to communicate across different environments, languages, and systems because all a client has to do is parse the message. NATS lets programs share common message-handling code, isolate resources and interdependencies, and scale by easily handling an increase in message volume.</p>
|
||||
<h2 id="publish-subscribe"><a name="pubsub"></a>Publish Subscribe</h2>
|
||||
<p>NATS implements a publish subscribe message distribution model as a one-to-many communication. A publisher sends a message on a subject and any active subscriber listening on that subject receives the message. Subscribers can also register interest in wildcard subjects. NATS and NATS Streaming combine to offer two qualities of service:</p>
|
||||
<ul>
|
||||
<li><p><strong>At Most Once Delivery (NATS w/TCP reliability)</strong> - In the basic NATS platform, if a subscriber is not listening on the subject (no subject match), or is not active when the message is sent, the message is not received. NATS is a fire-and-forget messaging system. If you need higher levels of service, you can either use <a href="../documentation/streaming/nats-streaming-intro">NATS Streaming</a>, or build the additional reliability into your client(s) yourself.</p>
|
||||
</li>
|
||||
<li><p><strong>At Least Once Delivery (<a href="../documentation/streaming/nats-streaming-intro">NATS Streaming</a>)</strong> - Some applications require higher levels of service and more stringent delivery guarantees but at the potential cost of lower message throughput and higher end-to-end delivery latency. These applications rely on the underlying messaging transport to ensure that messages are delivered to subscribers irrespective of network outages or whether or not a subscriber is offline at a particular point in time.</p>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="graphviz"><code data-viz="dot">
|
||||
digraph nats_pub_sub {
|
||||
rankdir=LR
|
||||
publisher [shape=box, style="rounded", label="Publisher"];
|
||||
subject [shape=circle, label="Subject"];
|
||||
sub1 [shape=box, style="rounded", label="Subscriber"];
|
||||
sub2 [shape=box, style="rounded", label="Subscriber"];
|
||||
sub3 [shape=box, style="rounded", label="Subscriber"];
|
||||
|
||||
publisher -> subject [label="msg1"];
|
||||
subject -> sub1 [label="msg1"];
|
||||
subject -> sub2 [label="msg1"];
|
||||
subject -> sub3 [label="msg1"];
|
||||
}
|
||||
</code></div>
|
||||
|
||||
<p>Try NATS publish subscribe on your own, using a live server by walking through the <a href="../doc/additional_documentation/nats-pub-sub">pub-sub tutorial</a>.</p>
|
||||
<h2 id="request-reply"><a name="reqrep"></a>Request Reply</h2>
|
||||
<p>NATS supports two flavors of request reply messaging: point-to-point or one-to-many. Point-to-point involves the fastest or first to respond. In a one-to-many exchange, you set a limit on the number of responses the requestor may receive.</p>
|
||||
<p>In a request-response exchange, publish request operation publishes a message with a reply subject expecting a response on that reply subject. You can request to automatically wait for a response inline.</p>
|
||||
<p>The request creates an inbox and performs a request call with the inbox reply and returns the first reply received. This is optimized in the case of multiple responses.</p>
|
||||
<div class="graphviz"><code data-viz="dot">
|
||||
digraph nats_request_reply {
|
||||
rankdir=LR
|
||||
|
||||
subgraph {
|
||||
publisher [shape=box, style="rounded", label="Publisher"];
|
||||
}
|
||||
|
||||
subgraph {
|
||||
subject [shape=circle, label="Subject"];
|
||||
reply [shape=circle, label="Reply"];
|
||||
{rank = same subject reply}
|
||||
}
|
||||
|
||||
subgraph {
|
||||
sub1 [shape=box, style="rounded", label="Subscriber"];
|
||||
sub2 [shape=box, style="rounded", label="Subscriber"];
|
||||
sub3 [shape=box, style="rounded", label="Subscriber"];
|
||||
}
|
||||
|
||||
publisher -> subject [label="msg1"];
|
||||
publisher -> reply [style="invis", weight=2];
|
||||
reply -> sub3 [style="invis", weight=2];
|
||||
subject -> sub1 [label="msg1", style="dotted"];
|
||||
subject -> sub2 [label="msg1", style="dotted"];
|
||||
subject -> sub3 [label="msg1"];
|
||||
sub3 -> reply;
|
||||
reply -> publisher;
|
||||
}
|
||||
</code></div>
|
||||
|
||||
<p>Try NATS request reply on your own, using a live server by walking through the <a href="../doc/additional_documentation/nats-req-rep">request/reply tutorial</a>.</p>
|
||||
<h2 id="queue-subscribers--sharing-work"><a name="queue"></a>Queue Subscribers & Sharing Work</h2>
|
||||
<p>NATS provides a load balancing feature called queue subscriptions. Using queue subscribers will load balance message delivery across a group of subscribers which can be used to provide application fault tolerance and scale workload processing.</p>
|
||||
<p>To create a queue subscription, subscribers register a queue name. All subscribers with the same queue name form the queue group. As messages on the registered subject are published, one member of the group is chosen randomly to receive the message. Although queue groups have multiple subscribers, each message is consumed by only one.</p>
|
||||
<p>Queue subscribers can be asynchronous, in which case the message handler callback function processes the delivered message. Synchronous queue subscribers must build in logic to process the message. Queue subscribers are ideal for auto scaling as you can add or remove them anytime, without any configuration changes or restarting the server or clients.</p>
|
||||
<div class="graphviz"><code data-viz="dot">
|
||||
digraph nats_queues {
|
||||
rankdir=LR
|
||||
publisher [shape=box, style="rounded", label="Publisher"];
|
||||
subject [shape=circle, label="Queue"];
|
||||
sub1 [shape=box, style="rounded", label="Subscriber"];
|
||||
sub2 [shape=box, style="rounded", label="Subscriber"];
|
||||
sub3 [shape=box, style="rounded", label="Subscriber"];
|
||||
|
||||
publisher -> subject [label="msgs 1,2,3"];
|
||||
subject -> sub1 [label="msg 2"];
|
||||
subject -> sub2 [label="msg 1"];
|
||||
subject -> sub3 [label="msg 3"];
|
||||
}
|
||||
</code></div>
|
||||
|
||||
<p>Try NATS queue subscriptions on your own, using a live server by walking through the <a href="../doc/additional_documentation/nats-queueing">queueing tutorial</a>.</p>
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<div class="search-results">
|
||||
<div class="has-results">
|
||||
|
||||
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
|
||||
<ul class="search-results-list"></ul>
|
||||
|
||||
</div>
|
||||
<div class="no-results">
|
||||
|
||||
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<a href="../nats_server/windows_srv.html" class="navigation navigation-prev " aria-label="Previous page: Window Service">
|
||||
<i class="fa fa-angle-left"></i>
|
||||
</a>
|
||||
|
||||
|
||||
<a href="connecting.html" class="navigation navigation-next " aria-label="Next page: Connecting">
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var gitbook = gitbook || [];
|
||||
gitbook.push(function() {
|
||||
gitbook.page.hasChanged({"page":{"title":"Developing with NATS","level":"1.2","depth":1,"next":{"title":"Connecting","level":"1.2.1","depth":2,"path":"developer/connecting.md","ref":"developer/connecting.md","articles":[]},"previous":{"title":"Window Service","level":"1.1.1.7","depth":3,"path":"nats_server/windows_srv.md","ref":"nats_server/windows_srv.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["prism","-highlight","include-html"],"pluginsConfig":{"prism":{},"include-html":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"developer/README.md","mtime":"2019-05-15T15:14:27.336Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-05-15T15:16:11.909Z"},"basePath":"..","book":{"language":""}});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<!-- 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();
|
||||
});
|
||||
}
|
||||
|
||||
function pageChanged() {
|
||||
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>
|
||||
div.graphviz {
|
||||
background: transparent;
|
||||
border: 0;
|
||||
padding-top: 15px;
|
||||
padding-right: 15px;
|
||||
padding-bottom: 15px;
|
||||
padding-left: 15px;
|
||||
}
|
||||
|
||||
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: 10px 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>
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook.js"></script>
|
||||
<script src="../gitbook/theme.js"></script>
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,135 +0,0 @@
|
||||
pre,
|
||||
code {
|
||||
/* http://jmblog.github.io/color-themes-for-highlightjs */
|
||||
/* Tomorrow Comment */
|
||||
/* Tomorrow Red */
|
||||
/* Tomorrow Orange */
|
||||
/* Tomorrow Yellow */
|
||||
/* Tomorrow Green */
|
||||
/* Tomorrow Aqua */
|
||||
/* Tomorrow Blue */
|
||||
/* Tomorrow Purple */
|
||||
}
|
||||
pre .hljs-comment,
|
||||
code .hljs-comment,
|
||||
pre .hljs-title,
|
||||
code .hljs-title {
|
||||
color: #8e908c;
|
||||
}
|
||||
pre .hljs-variable,
|
||||
code .hljs-variable,
|
||||
pre .hljs-attribute,
|
||||
code .hljs-attribute,
|
||||
pre .hljs-tag,
|
||||
code .hljs-tag,
|
||||
pre .hljs-regexp,
|
||||
code .hljs-regexp,
|
||||
pre .hljs-deletion,
|
||||
code .hljs-deletion,
|
||||
pre .ruby .hljs-constant,
|
||||
code .ruby .hljs-constant,
|
||||
pre .xml .hljs-tag .hljs-title,
|
||||
code .xml .hljs-tag .hljs-title,
|
||||
pre .xml .hljs-pi,
|
||||
code .xml .hljs-pi,
|
||||
pre .xml .hljs-doctype,
|
||||
code .xml .hljs-doctype,
|
||||
pre .html .hljs-doctype,
|
||||
code .html .hljs-doctype,
|
||||
pre .css .hljs-id,
|
||||
code .css .hljs-id,
|
||||
pre .css .hljs-class,
|
||||
code .css .hljs-class,
|
||||
pre .css .hljs-pseudo,
|
||||
code .css .hljs-pseudo {
|
||||
color: #c82829;
|
||||
}
|
||||
pre .hljs-number,
|
||||
code .hljs-number,
|
||||
pre .hljs-preprocessor,
|
||||
code .hljs-preprocessor,
|
||||
pre .hljs-pragma,
|
||||
code .hljs-pragma,
|
||||
pre .hljs-built_in,
|
||||
code .hljs-built_in,
|
||||
pre .hljs-literal,
|
||||
code .hljs-literal,
|
||||
pre .hljs-params,
|
||||
code .hljs-params,
|
||||
pre .hljs-constant,
|
||||
code .hljs-constant {
|
||||
color: #f5871f;
|
||||
}
|
||||
pre .ruby .hljs-class .hljs-title,
|
||||
code .ruby .hljs-class .hljs-title,
|
||||
pre .css .hljs-rules .hljs-attribute,
|
||||
code .css .hljs-rules .hljs-attribute {
|
||||
color: #eab700;
|
||||
}
|
||||
pre .hljs-string,
|
||||
code .hljs-string,
|
||||
pre .hljs-value,
|
||||
code .hljs-value,
|
||||
pre .hljs-inheritance,
|
||||
code .hljs-inheritance,
|
||||
pre .hljs-header,
|
||||
code .hljs-header,
|
||||
pre .hljs-addition,
|
||||
code .hljs-addition,
|
||||
pre .ruby .hljs-symbol,
|
||||
code .ruby .hljs-symbol,
|
||||
pre .xml .hljs-cdata,
|
||||
code .xml .hljs-cdata {
|
||||
color: #718c00;
|
||||
}
|
||||
pre .css .hljs-hexcolor,
|
||||
code .css .hljs-hexcolor {
|
||||
color: #3e999f;
|
||||
}
|
||||
pre .hljs-function,
|
||||
code .hljs-function,
|
||||
pre .python .hljs-decorator,
|
||||
code .python .hljs-decorator,
|
||||
pre .python .hljs-title,
|
||||
code .python .hljs-title,
|
||||
pre .ruby .hljs-function .hljs-title,
|
||||
code .ruby .hljs-function .hljs-title,
|
||||
pre .ruby .hljs-title .hljs-keyword,
|
||||
code .ruby .hljs-title .hljs-keyword,
|
||||
pre .perl .hljs-sub,
|
||||
code .perl .hljs-sub,
|
||||
pre .javascript .hljs-title,
|
||||
code .javascript .hljs-title,
|
||||
pre .coffeescript .hljs-title,
|
||||
code .coffeescript .hljs-title {
|
||||
color: #4271ae;
|
||||
}
|
||||
pre .hljs-keyword,
|
||||
code .hljs-keyword,
|
||||
pre .javascript .hljs-function,
|
||||
code .javascript .hljs-function {
|
||||
color: #8959a8;
|
||||
}
|
||||
pre .hljs,
|
||||
code .hljs {
|
||||
display: block;
|
||||
background: white;
|
||||
color: #4d4d4c;
|
||||
padding: 0.5em;
|
||||
}
|
||||
pre .coffeescript .javascript,
|
||||
code .coffeescript .javascript,
|
||||
pre .javascript .xml,
|
||||
code .javascript .xml,
|
||||
pre .tex .hljs-formula,
|
||||
code .tex .hljs-formula,
|
||||
pre .xml .javascript,
|
||||
code .xml .javascript,
|
||||
pre .xml .vbscript,
|
||||
code .xml .vbscript,
|
||||
pre .xml .css,
|
||||
code .xml .css,
|
||||
pre .xml .hljs-cdata,
|
||||
code .xml .hljs-cdata {
|
||||
opacity: 0.5;
|
||||
}
|
@ -1,434 +0,0 @@
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code {
|
||||
/* http://jmblog.github.com/color-themes-for-google-code-highlightjs */
|
||||
/* Tomorrow Comment */
|
||||
/* Tomorrow Red */
|
||||
/* Tomorrow Orange */
|
||||
/* Tomorrow Yellow */
|
||||
/* Tomorrow Green */
|
||||
/* Tomorrow Aqua */
|
||||
/* Tomorrow Blue */
|
||||
/* Tomorrow Purple */
|
||||
}
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .hljs-comment,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .hljs-comment,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .hljs-title,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .hljs-title {
|
||||
color: #8e908c;
|
||||
}
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .hljs-variable,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .hljs-variable,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .hljs-attribute,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .hljs-attribute,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .hljs-tag,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .hljs-tag,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .hljs-regexp,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .hljs-regexp,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .hljs-deletion,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .hljs-deletion,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .ruby .hljs-constant,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .ruby .hljs-constant,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .xml .hljs-tag .hljs-title,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .xml .hljs-tag .hljs-title,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .xml .hljs-pi,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .xml .hljs-pi,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .xml .hljs-doctype,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .xml .hljs-doctype,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .html .hljs-doctype,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .html .hljs-doctype,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .css .hljs-id,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .css .hljs-id,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .css .hljs-class,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .css .hljs-class,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .css .hljs-pseudo,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .css .hljs-pseudo {
|
||||
color: #c82829;
|
||||
}
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .hljs-number,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .hljs-number,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .hljs-preprocessor,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .hljs-preprocessor,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .hljs-pragma,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .hljs-pragma,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .hljs-built_in,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .hljs-built_in,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .hljs-literal,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .hljs-literal,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .hljs-params,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .hljs-params,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .hljs-constant,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .hljs-constant {
|
||||
color: #f5871f;
|
||||
}
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .ruby .hljs-class .hljs-title,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .ruby .hljs-class .hljs-title,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .css .hljs-rules .hljs-attribute,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .css .hljs-rules .hljs-attribute {
|
||||
color: #eab700;
|
||||
}
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .hljs-string,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .hljs-string,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .hljs-value,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .hljs-value,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .hljs-inheritance,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .hljs-inheritance,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .hljs-header,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .hljs-header,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .hljs-addition,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .hljs-addition,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .ruby .hljs-symbol,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .ruby .hljs-symbol,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .xml .hljs-cdata,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .xml .hljs-cdata {
|
||||
color: #718c00;
|
||||
}
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .css .hljs-hexcolor,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .css .hljs-hexcolor {
|
||||
color: #3e999f;
|
||||
}
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .hljs-function,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .hljs-function,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .python .hljs-decorator,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .python .hljs-decorator,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .python .hljs-title,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .python .hljs-title,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .ruby .hljs-function .hljs-title,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .ruby .hljs-function .hljs-title,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .ruby .hljs-title .hljs-keyword,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .ruby .hljs-title .hljs-keyword,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .perl .hljs-sub,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .perl .hljs-sub,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .javascript .hljs-title,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .javascript .hljs-title,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .coffeescript .hljs-title,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .coffeescript .hljs-title {
|
||||
color: #4271ae;
|
||||
}
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .hljs-keyword,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .hljs-keyword,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .javascript .hljs-function,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .javascript .hljs-function {
|
||||
color: #8959a8;
|
||||
}
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .hljs,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .hljs {
|
||||
display: block;
|
||||
background: white;
|
||||
color: #4d4d4c;
|
||||
padding: 0.5em;
|
||||
}
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .coffeescript .javascript,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .coffeescript .javascript,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .javascript .xml,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .javascript .xml,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .tex .hljs-formula,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .tex .hljs-formula,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .xml .javascript,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .xml .javascript,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .xml .vbscript,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .xml .vbscript,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .xml .css,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .xml .css,
|
||||
.book .book-body .page-wrapper .page-inner section.normal pre .xml .hljs-cdata,
|
||||
.book .book-body .page-wrapper .page-inner section.normal code .xml .hljs-cdata {
|
||||
opacity: 0.5;
|
||||
}
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code {
|
||||
/*
|
||||
|
||||
Orginal Style from ethanschoonover.com/solarized (c) Jeremy Hull <sourdrums@gmail.com>
|
||||
|
||||
*/
|
||||
/* Solarized Green */
|
||||
/* Solarized Cyan */
|
||||
/* Solarized Blue */
|
||||
/* Solarized Yellow */
|
||||
/* Solarized Orange */
|
||||
/* Solarized Red */
|
||||
/* Solarized Violet */
|
||||
}
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs {
|
||||
display: block;
|
||||
padding: 0.5em;
|
||||
background: #fdf6e3;
|
||||
color: #657b83;
|
||||
}
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-comment,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-comment,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-template_comment,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-template_comment,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .diff .hljs-header,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .diff .hljs-header,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-doctype,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-doctype,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-pi,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-pi,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .lisp .hljs-string,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .lisp .hljs-string,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-javadoc,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-javadoc {
|
||||
color: #93a1a1;
|
||||
}
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-keyword,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-keyword,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-winutils,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-winutils,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .method,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .method,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-addition,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-addition,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .css .hljs-tag,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .css .hljs-tag,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-request,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-request,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-status,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-status,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .nginx .hljs-title,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .nginx .hljs-title {
|
||||
color: #859900;
|
||||
}
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-number,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-number,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-command,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-command,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-string,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-string,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-tag .hljs-value,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-tag .hljs-value,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-rules .hljs-value,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-rules .hljs-value,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-phpdoc,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-phpdoc,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .tex .hljs-formula,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .tex .hljs-formula,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-regexp,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-regexp,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-hexcolor,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-hexcolor,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-link_url,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-link_url {
|
||||
color: #2aa198;
|
||||
}
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-title,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-title,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-localvars,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-localvars,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-chunk,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-chunk,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-decorator,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-decorator,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-built_in,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-built_in,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-identifier,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-identifier,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .vhdl .hljs-literal,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .vhdl .hljs-literal,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-id,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-id,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .css .hljs-function,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .css .hljs-function {
|
||||
color: #268bd2;
|
||||
}
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-attribute,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-attribute,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-variable,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-variable,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .lisp .hljs-body,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .lisp .hljs-body,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .smalltalk .hljs-number,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .smalltalk .hljs-number,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-constant,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-constant,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-class .hljs-title,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-class .hljs-title,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-parent,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-parent,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .haskell .hljs-type,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .haskell .hljs-type,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-link_reference,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-link_reference {
|
||||
color: #b58900;
|
||||
}
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-preprocessor,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-preprocessor,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-preprocessor .hljs-keyword,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-preprocessor .hljs-keyword,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-pragma,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-pragma,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-shebang,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-shebang,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-symbol,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-symbol,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-symbol .hljs-string,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-symbol .hljs-string,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .diff .hljs-change,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .diff .hljs-change,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-special,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-special,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-attr_selector,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-attr_selector,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-subst,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-subst,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-cdata,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-cdata,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .clojure .hljs-title,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .clojure .hljs-title,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .css .hljs-pseudo,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .css .hljs-pseudo,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-header,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-header {
|
||||
color: #cb4b16;
|
||||
}
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-deletion,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-deletion,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-important,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-important {
|
||||
color: #dc322f;
|
||||
}
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .hljs-link_label,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .hljs-link_label {
|
||||
color: #6c71c4;
|
||||
}
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre .tex .hljs-formula,
|
||||
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code .tex .hljs-formula {
|
||||
background: #eee8d5;
|
||||
}
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code {
|
||||
/* Tomorrow Night Bright Theme */
|
||||
/* Original theme - https://github.com/chriskempson/tomorrow-theme */
|
||||
/* http://jmblog.github.com/color-themes-for-google-code-highlightjs */
|
||||
/* Tomorrow Comment */
|
||||
/* Tomorrow Red */
|
||||
/* Tomorrow Orange */
|
||||
/* Tomorrow Yellow */
|
||||
/* Tomorrow Green */
|
||||
/* Tomorrow Aqua */
|
||||
/* Tomorrow Blue */
|
||||
/* Tomorrow Purple */
|
||||
}
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .hljs-comment,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .hljs-comment,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .hljs-title,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .hljs-title {
|
||||
color: #969896;
|
||||
}
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .hljs-variable,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .hljs-variable,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .hljs-attribute,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .hljs-attribute,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .hljs-tag,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .hljs-tag,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .hljs-regexp,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .hljs-regexp,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .hljs-deletion,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .hljs-deletion,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .ruby .hljs-constant,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .ruby .hljs-constant,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .xml .hljs-tag .hljs-title,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .xml .hljs-tag .hljs-title,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .xml .hljs-pi,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .xml .hljs-pi,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .xml .hljs-doctype,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .xml .hljs-doctype,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .html .hljs-doctype,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .html .hljs-doctype,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .css .hljs-id,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .css .hljs-id,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .css .hljs-class,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .css .hljs-class,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .css .hljs-pseudo,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .css .hljs-pseudo {
|
||||
color: #d54e53;
|
||||
}
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .hljs-number,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .hljs-number,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .hljs-preprocessor,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .hljs-preprocessor,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .hljs-pragma,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .hljs-pragma,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .hljs-built_in,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .hljs-built_in,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .hljs-literal,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .hljs-literal,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .hljs-params,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .hljs-params,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .hljs-constant,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .hljs-constant {
|
||||
color: #e78c45;
|
||||
}
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .ruby .hljs-class .hljs-title,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .ruby .hljs-class .hljs-title,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .css .hljs-rules .hljs-attribute,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .css .hljs-rules .hljs-attribute {
|
||||
color: #e7c547;
|
||||
}
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .hljs-string,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .hljs-string,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .hljs-value,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .hljs-value,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .hljs-inheritance,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .hljs-inheritance,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .hljs-header,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .hljs-header,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .hljs-addition,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .hljs-addition,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .ruby .hljs-symbol,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .ruby .hljs-symbol,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .xml .hljs-cdata,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .xml .hljs-cdata {
|
||||
color: #b9ca4a;
|
||||
}
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .css .hljs-hexcolor,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .css .hljs-hexcolor {
|
||||
color: #70c0b1;
|
||||
}
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .hljs-function,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .hljs-function,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .python .hljs-decorator,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .python .hljs-decorator,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .python .hljs-title,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .python .hljs-title,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .ruby .hljs-function .hljs-title,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .ruby .hljs-function .hljs-title,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .ruby .hljs-title .hljs-keyword,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .ruby .hljs-title .hljs-keyword,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .perl .hljs-sub,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .perl .hljs-sub,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .javascript .hljs-title,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .javascript .hljs-title,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .coffeescript .hljs-title,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .coffeescript .hljs-title {
|
||||
color: #7aa6da;
|
||||
}
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .hljs-keyword,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .hljs-keyword,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .javascript .hljs-function,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .javascript .hljs-function {
|
||||
color: #c397d8;
|
||||
}
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .hljs,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .hljs {
|
||||
display: block;
|
||||
background: black;
|
||||
color: #eaeaea;
|
||||
padding: 0.5em;
|
||||
}
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .coffeescript .javascript,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .coffeescript .javascript,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .javascript .xml,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .javascript .xml,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .tex .hljs-formula,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .tex .hljs-formula,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .xml .javascript,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .xml .javascript,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .xml .vbscript,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .xml .vbscript,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .xml .css,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .xml .css,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre .xml .hljs-cdata,
|
||||
.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code .xml .hljs-cdata {
|
||||
opacity: 0.5;
|
||||
}
|
226
docs/gitbook/gitbook-plugin-prism/prism-coy.css
Normal file
226
docs/gitbook/gitbook-plugin-prism/prism-coy.css
Normal file
@ -0,0 +1,226 @@
|
||||
/**
|
||||
* prism.js Coy theme for JavaScript, CoffeeScript, CSS and HTML
|
||||
* Based on https://github.com/tshedor/workshop-wp-theme (Example: http://workshop.kansan.com/category/sessions/basics or http://workshop.timshedor.com/category/sessions/basics);
|
||||
* @author Tim Shedor
|
||||
*/
|
||||
|
||||
code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
color: black;
|
||||
background: none;
|
||||
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
|
||||
font-size: 1em;
|
||||
text-align: left;
|
||||
white-space: pre;
|
||||
word-spacing: normal;
|
||||
word-break: normal;
|
||||
word-wrap: normal;
|
||||
line-height: 1.5;
|
||||
|
||||
-moz-tab-size: 4;
|
||||
-o-tab-size: 4;
|
||||
tab-size: 4;
|
||||
|
||||
-webkit-hyphens: none;
|
||||
-moz-hyphens: none;
|
||||
-ms-hyphens: none;
|
||||
hyphens: none;
|
||||
}
|
||||
|
||||
/* Code blocks */
|
||||
pre[class*="language-"] {
|
||||
position: relative;
|
||||
margin: .5em 0;
|
||||
overflow: visible;
|
||||
padding: 0;
|
||||
}
|
||||
pre[class*="language-"]>code {
|
||||
position: relative;
|
||||
border-left: 10px solid #358ccb;
|
||||
box-shadow: -1px 0px 0px 0px #358ccb, 0px 0px 0px 1px #dfdfdf;
|
||||
background-color: #fdfdfd;
|
||||
background-image: linear-gradient(transparent 50%, rgba(69, 142, 209, 0.04) 50%);
|
||||
background-size: 3em 3em;
|
||||
background-origin: content-box;
|
||||
background-attachment: local;
|
||||
}
|
||||
|
||||
code[class*="language"] {
|
||||
max-height: inherit;
|
||||
height: inherit;
|
||||
padding: 0 1em;
|
||||
display: block;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
/* Margin bottom to accommodate shadow */
|
||||
:not(pre) > code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
background-color: #fdfdfd;
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
/* Inline code */
|
||||
:not(pre) > code[class*="language-"] {
|
||||
position: relative;
|
||||
padding: .2em;
|
||||
border-radius: 0.3em;
|
||||
color: #c92c2c;
|
||||
border: 1px solid rgba(0, 0, 0, 0.1);
|
||||
display: inline;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
pre[class*="language-"]:before,
|
||||
pre[class*="language-"]:after {
|
||||
content: '';
|
||||
z-index: -2;
|
||||
display: block;
|
||||
position: absolute;
|
||||
bottom: 0.75em;
|
||||
left: 0.18em;
|
||||
width: 40%;
|
||||
height: 20%;
|
||||
max-height: 13em;
|
||||
box-shadow: 0px 13px 8px #979797;
|
||||
-webkit-transform: rotate(-2deg);
|
||||
-moz-transform: rotate(-2deg);
|
||||
-ms-transform: rotate(-2deg);
|
||||
-o-transform: rotate(-2deg);
|
||||
transform: rotate(-2deg);
|
||||
}
|
||||
|
||||
:not(pre) > code[class*="language-"]:after,
|
||||
pre[class*="language-"]:after {
|
||||
right: 0.75em;
|
||||
left: auto;
|
||||
-webkit-transform: rotate(2deg);
|
||||
-moz-transform: rotate(2deg);
|
||||
-ms-transform: rotate(2deg);
|
||||
-o-transform: rotate(2deg);
|
||||
transform: rotate(2deg);
|
||||
}
|
||||
|
||||
.token.comment,
|
||||
.token.block-comment,
|
||||
.token.prolog,
|
||||
.token.doctype,
|
||||
.token.cdata {
|
||||
color: #7D8B99;
|
||||
}
|
||||
|
||||
.token.punctuation {
|
||||
color: #5F6364;
|
||||
}
|
||||
|
||||
.token.property,
|
||||
.token.tag,
|
||||
.token.boolean,
|
||||
.token.number,
|
||||
.token.function-name,
|
||||
.token.constant,
|
||||
.token.symbol,
|
||||
.token.deleted {
|
||||
color: #c92c2c;
|
||||
}
|
||||
|
||||
.token.selector,
|
||||
.token.attr-name,
|
||||
.token.string,
|
||||
.token.char,
|
||||
.token.function,
|
||||
.token.builtin,
|
||||
.token.inserted {
|
||||
color: #2f9c0a;
|
||||
}
|
||||
|
||||
.token.operator,
|
||||
.token.entity,
|
||||
.token.url,
|
||||
.token.variable {
|
||||
color: #a67f59;
|
||||
background: rgba(255, 255, 255, 0.5);
|
||||
}
|
||||
|
||||
.token.atrule,
|
||||
.token.attr-value,
|
||||
.token.keyword,
|
||||
.token.class-name {
|
||||
color: #1990b8;
|
||||
}
|
||||
|
||||
.token.regex,
|
||||
.token.important {
|
||||
color: #e90;
|
||||
}
|
||||
|
||||
.language-css .token.string,
|
||||
.style .token.string {
|
||||
color: #a67f59;
|
||||
background: rgba(255, 255, 255, 0.5);
|
||||
}
|
||||
|
||||
.token.important {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.token.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
.token.italic {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.token.entity {
|
||||
cursor: help;
|
||||
}
|
||||
|
||||
.namespace {
|
||||
opacity: .7;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 767px) {
|
||||
pre[class*="language-"]:before,
|
||||
pre[class*="language-"]:after {
|
||||
bottom: 14px;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Plugin styles */
|
||||
.token.tab:not(:empty):before,
|
||||
.token.cr:before,
|
||||
.token.lf:before {
|
||||
color: #e0d7d1;
|
||||
}
|
||||
|
||||
/* Plugin styles: Line Numbers */
|
||||
pre[class*="language-"].line-numbers.line-numbers {
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
pre[class*="language-"].line-numbers.line-numbers code {
|
||||
padding-left: 3.8em;
|
||||
}
|
||||
|
||||
pre[class*="language-"].line-numbers.line-numbers .line-numbers-rows {
|
||||
left: 0;
|
||||
}
|
||||
|
||||
/* Plugin styles: Line Highlight */
|
||||
pre[class*="language-"][data-line] {
|
||||
padding-top: 0;
|
||||
padding-bottom: 0;
|
||||
padding-left: 0;
|
||||
}
|
||||
pre[data-line] code {
|
||||
position: relative;
|
||||
padding-left: 4em;
|
||||
}
|
||||
pre .line-highlight {
|
||||
margin-top: 0;
|
||||
}
|
129
docs/gitbook/gitbook-plugin-prism/prism-dark.css
Normal file
129
docs/gitbook/gitbook-plugin-prism/prism-dark.css
Normal file
@ -0,0 +1,129 @@
|
||||
/**
|
||||
* prism.js Dark theme for JavaScript, CSS and HTML
|
||||
* Based on the slides of the talk “/Reg(exp){2}lained/”
|
||||
* @author Lea Verou
|
||||
*/
|
||||
|
||||
code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
color: white;
|
||||
background: none;
|
||||
text-shadow: 0 -.1em .2em black;
|
||||
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
|
||||
font-size: 1em;
|
||||
text-align: left;
|
||||
white-space: pre;
|
||||
word-spacing: normal;
|
||||
word-break: normal;
|
||||
word-wrap: normal;
|
||||
line-height: 1.5;
|
||||
|
||||
-moz-tab-size: 4;
|
||||
-o-tab-size: 4;
|
||||
tab-size: 4;
|
||||
|
||||
-webkit-hyphens: none;
|
||||
-moz-hyphens: none;
|
||||
-ms-hyphens: none;
|
||||
hyphens: none;
|
||||
}
|
||||
|
||||
@media print {
|
||||
code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
text-shadow: none;
|
||||
}
|
||||
}
|
||||
|
||||
pre[class*="language-"],
|
||||
:not(pre) > code[class*="language-"] {
|
||||
background: hsl(30, 20%, 25%);
|
||||
}
|
||||
|
||||
/* Code blocks */
|
||||
pre[class*="language-"] {
|
||||
padding: 1em;
|
||||
margin: .5em 0;
|
||||
overflow: auto;
|
||||
border: .3em solid hsl(30, 20%, 40%);
|
||||
border-radius: .5em;
|
||||
box-shadow: 1px 1px .5em black inset;
|
||||
}
|
||||
|
||||
/* Inline code */
|
||||
:not(pre) > code[class*="language-"] {
|
||||
padding: .15em .2em .05em;
|
||||
border-radius: .3em;
|
||||
border: .13em solid hsl(30, 20%, 40%);
|
||||
box-shadow: 1px 1px .3em -.1em black inset;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.token.comment,
|
||||
.token.prolog,
|
||||
.token.doctype,
|
||||
.token.cdata {
|
||||
color: hsl(30, 20%, 50%);
|
||||
}
|
||||
|
||||
.token.punctuation {
|
||||
opacity: .7;
|
||||
}
|
||||
|
||||
.namespace {
|
||||
opacity: .7;
|
||||
}
|
||||
|
||||
.token.property,
|
||||
.token.tag,
|
||||
.token.boolean,
|
||||
.token.number,
|
||||
.token.constant,
|
||||
.token.symbol {
|
||||
color: hsl(350, 40%, 70%);
|
||||
}
|
||||
|
||||
.token.selector,
|
||||
.token.attr-name,
|
||||
.token.string,
|
||||
.token.char,
|
||||
.token.builtin,
|
||||
.token.inserted {
|
||||
color: hsl(75, 70%, 60%);
|
||||
}
|
||||
|
||||
.token.operator,
|
||||
.token.entity,
|
||||
.token.url,
|
||||
.language-css .token.string,
|
||||
.style .token.string,
|
||||
.token.variable {
|
||||
color: hsl(40, 90%, 60%);
|
||||
}
|
||||
|
||||
.token.atrule,
|
||||
.token.attr-value,
|
||||
.token.keyword {
|
||||
color: hsl(350, 40%, 70%);
|
||||
}
|
||||
|
||||
.token.regex,
|
||||
.token.important {
|
||||
color: #e90;
|
||||
}
|
||||
|
||||
.token.important,
|
||||
.token.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
.token.italic {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.token.entity {
|
||||
cursor: help;
|
||||
}
|
||||
|
||||
.token.deleted {
|
||||
color: red;
|
||||
}
|
117
docs/gitbook/gitbook-plugin-prism/prism-funky.css
Normal file
117
docs/gitbook/gitbook-plugin-prism/prism-funky.css
Normal file
@ -0,0 +1,117 @@
|
||||
/**
|
||||
* prism.js Funky theme
|
||||
* Based on “Polyfilling the gaps” talk slides http://lea.verou.me/polyfilling-the-gaps/
|
||||
* @author Lea Verou
|
||||
*/
|
||||
|
||||
code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
|
||||
font-size: 1em;
|
||||
text-align: left;
|
||||
white-space: pre;
|
||||
word-spacing: normal;
|
||||
word-break: normal;
|
||||
word-wrap: normal;
|
||||
line-height: 1.5;
|
||||
|
||||
-moz-tab-size: 4;
|
||||
-o-tab-size: 4;
|
||||
tab-size: 4;
|
||||
|
||||
-webkit-hyphens: none;
|
||||
-moz-hyphens: none;
|
||||
-ms-hyphens: none;
|
||||
hyphens: none;
|
||||
}
|
||||
|
||||
/* Code blocks */
|
||||
pre[class*="language-"] {
|
||||
padding: .4em .8em;
|
||||
margin: .5em 0;
|
||||
overflow: auto;
|
||||
background: url('data:image/svg+xml;charset=utf-8,<svg%20version%3D"1.1"%20xmlns%3D"http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg"%20width%3D"100"%20height%3D"100"%20fill%3D"rgba(0%2C0%2C0%2C.2)">%0D%0A<polygon%20points%3D"0%2C50%2050%2C0%200%2C0"%20%2F>%0D%0A<polygon%20points%3D"0%2C100%2050%2C100%20100%2C50%20100%2C0"%20%2F>%0D%0A<%2Fsvg>');
|
||||
background-size: 1em 1em;
|
||||
}
|
||||
|
||||
code[class*="language-"] {
|
||||
background: black;
|
||||
color: white;
|
||||
box-shadow: -.3em 0 0 .3em black, .3em 0 0 .3em black;
|
||||
}
|
||||
|
||||
/* Inline code */
|
||||
:not(pre) > code[class*="language-"] {
|
||||
padding: .2em;
|
||||
border-radius: .3em;
|
||||
box-shadow: none;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.token.comment,
|
||||
.token.prolog,
|
||||
.token.doctype,
|
||||
.token.cdata {
|
||||
color: #aaa;
|
||||
}
|
||||
|
||||
.token.punctuation {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.namespace {
|
||||
opacity: .7;
|
||||
}
|
||||
|
||||
.token.property,
|
||||
.token.tag,
|
||||
.token.boolean,
|
||||
.token.number,
|
||||
.token.constant,
|
||||
.token.symbol {
|
||||
color: #0cf;
|
||||
}
|
||||
|
||||
.token.selector,
|
||||
.token.attr-name,
|
||||
.token.string,
|
||||
.token.char,
|
||||
.token.builtin {
|
||||
color: yellow;
|
||||
}
|
||||
|
||||
.token.operator,
|
||||
.token.entity,
|
||||
.token.url,
|
||||
.language-css .token.string,
|
||||
.toke.variable,
|
||||
.token.inserted {
|
||||
color: yellowgreen;
|
||||
}
|
||||
|
||||
.token.atrule,
|
||||
.token.attr-value,
|
||||
.token.keyword {
|
||||
color: deeppink;
|
||||
}
|
||||
|
||||
.token.regex,
|
||||
.token.important {
|
||||
color: orange;
|
||||
}
|
||||
|
||||
.token.important,
|
||||
.token.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
.token.italic {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.token.entity {
|
||||
cursor: help;
|
||||
}
|
||||
|
||||
.token.deleted {
|
||||
color: red;
|
||||
}
|
123
docs/gitbook/gitbook-plugin-prism/prism-okaidia.css
Normal file
123
docs/gitbook/gitbook-plugin-prism/prism-okaidia.css
Normal file
@ -0,0 +1,123 @@
|
||||
/**
|
||||
* okaidia theme for JavaScript, CSS and HTML
|
||||
* Loosely based on Monokai textmate theme by http://www.monokai.nl/
|
||||
* @author ocodia
|
||||
*/
|
||||
|
||||
code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
color: #f8f8f2;
|
||||
background: none;
|
||||
text-shadow: 0 1px rgba(0, 0, 0, 0.3);
|
||||
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
|
||||
font-size: 1em;
|
||||
text-align: left;
|
||||
white-space: pre;
|
||||
word-spacing: normal;
|
||||
word-break: normal;
|
||||
word-wrap: normal;
|
||||
line-height: 1.5;
|
||||
|
||||
-moz-tab-size: 4;
|
||||
-o-tab-size: 4;
|
||||
tab-size: 4;
|
||||
|
||||
-webkit-hyphens: none;
|
||||
-moz-hyphens: none;
|
||||
-ms-hyphens: none;
|
||||
hyphens: none;
|
||||
}
|
||||
|
||||
/* Code blocks */
|
||||
pre[class*="language-"] {
|
||||
padding: 1em;
|
||||
margin: .5em 0;
|
||||
overflow: auto;
|
||||
border-radius: 0.3em;
|
||||
}
|
||||
|
||||
:not(pre) > code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
background: #272822;
|
||||
}
|
||||
|
||||
/* Inline code */
|
||||
:not(pre) > code[class*="language-"] {
|
||||
padding: .1em;
|
||||
border-radius: .3em;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.token.comment,
|
||||
.token.prolog,
|
||||
.token.doctype,
|
||||
.token.cdata {
|
||||
color: slategray;
|
||||
}
|
||||
|
||||
.token.punctuation {
|
||||
color: #f8f8f2;
|
||||
}
|
||||
|
||||
.namespace {
|
||||
opacity: .7;
|
||||
}
|
||||
|
||||
.token.property,
|
||||
.token.tag,
|
||||
.token.constant,
|
||||
.token.symbol,
|
||||
.token.deleted {
|
||||
color: #f92672;
|
||||
}
|
||||
|
||||
.token.boolean,
|
||||
.token.number {
|
||||
color: #ae81ff;
|
||||
}
|
||||
|
||||
.token.selector,
|
||||
.token.attr-name,
|
||||
.token.string,
|
||||
.token.char,
|
||||
.token.builtin,
|
||||
.token.inserted {
|
||||
color: #a6e22e;
|
||||
}
|
||||
|
||||
.token.operator,
|
||||
.token.entity,
|
||||
.token.url,
|
||||
.language-css .token.string,
|
||||
.style .token.string,
|
||||
.token.variable {
|
||||
color: #f8f8f2;
|
||||
}
|
||||
|
||||
.token.atrule,
|
||||
.token.attr-value,
|
||||
.token.function,
|
||||
.token.class-name {
|
||||
color: #e6db74;
|
||||
}
|
||||
|
||||
.token.keyword {
|
||||
color: #66d9ef;
|
||||
}
|
||||
|
||||
.token.regex,
|
||||
.token.important {
|
||||
color: #fd971f;
|
||||
}
|
||||
|
||||
.token.important,
|
||||
.token.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
.token.italic {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.token.entity {
|
||||
cursor: help;
|
||||
}
|
150
docs/gitbook/gitbook-plugin-prism/prism-solarizedlight.css
Normal file
150
docs/gitbook/gitbook-plugin-prism/prism-solarizedlight.css
Normal file
@ -0,0 +1,150 @@
|
||||
/*
|
||||
Solarized Color Schemes originally by Ethan Schoonover
|
||||
http://ethanschoonover.com/solarized
|
||||
|
||||
Ported for PrismJS by Hector Matos
|
||||
Website: https://krakendev.io
|
||||
Twitter Handle: https://twitter.com/allonsykraken)
|
||||
*/
|
||||
|
||||
/*
|
||||
SOLARIZED HEX
|
||||
--------- -------
|
||||
base03 #002b36
|
||||
base02 #073642
|
||||
base01 #586e75
|
||||
base00 #657b83
|
||||
base0 #839496
|
||||
base1 #93a1a1
|
||||
base2 #eee8d5
|
||||
base3 #fdf6e3
|
||||
yellow #b58900
|
||||
orange #cb4b16
|
||||
red #dc322f
|
||||
magenta #d33682
|
||||
violet #6c71c4
|
||||
blue #268bd2
|
||||
cyan #2aa198
|
||||
green #859900
|
||||
*/
|
||||
|
||||
code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
color: #657b83; /* base00 */
|
||||
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
|
||||
font-size: 1em;
|
||||
text-align: left;
|
||||
white-space: pre;
|
||||
word-spacing: normal;
|
||||
word-break: normal;
|
||||
word-wrap: normal;
|
||||
|
||||
line-height: 1.5;
|
||||
|
||||
-moz-tab-size: 4;
|
||||
-o-tab-size: 4;
|
||||
tab-size: 4;
|
||||
|
||||
-webkit-hyphens: none;
|
||||
-moz-hyphens: none;
|
||||
-ms-hyphens: none;
|
||||
hyphens: none;
|
||||
}
|
||||
|
||||
pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection,
|
||||
code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection {
|
||||
background: #073642; /* base02 */
|
||||
}
|
||||
|
||||
pre[class*="language-"]::selection, pre[class*="language-"] ::selection,
|
||||
code[class*="language-"]::selection, code[class*="language-"] ::selection {
|
||||
background: #073642; /* base02 */
|
||||
}
|
||||
|
||||
/* Code blocks */
|
||||
pre[class*="language-"] {
|
||||
padding: 1em;
|
||||
margin: .5em 0;
|
||||
overflow: auto;
|
||||
border-radius: 0.3em;
|
||||
}
|
||||
|
||||
:not(pre) > code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
background-color: #fdf6e3; /* base3 */
|
||||
}
|
||||
|
||||
/* Inline code */
|
||||
:not(pre) > code[class*="language-"] {
|
||||
padding: .1em;
|
||||
border-radius: .3em;
|
||||
}
|
||||
|
||||
.token.comment,
|
||||
.token.prolog,
|
||||
.token.doctype,
|
||||
.token.cdata {
|
||||
color: #93a1a1; /* base1 */
|
||||
}
|
||||
|
||||
.token.punctuation {
|
||||
color: #586e75; /* base01 */
|
||||
}
|
||||
|
||||
.namespace {
|
||||
opacity: .7;
|
||||
}
|
||||
|
||||
.token.property,
|
||||
.token.tag,
|
||||
.token.boolean,
|
||||
.token.number,
|
||||
.token.constant,
|
||||
.token.symbol,
|
||||
.token.deleted {
|
||||
color: #268bd2; /* blue */
|
||||
}
|
||||
|
||||
.token.selector,
|
||||
.token.attr-name,
|
||||
.token.string,
|
||||
.token.char,
|
||||
.token.builtin,
|
||||
.token.url,
|
||||
.token.inserted {
|
||||
color: #2aa198; /* cyan */
|
||||
}
|
||||
|
||||
.token.entity {
|
||||
color: #657b83; /* base00 */
|
||||
background: #eee8d5; /* base2 */
|
||||
}
|
||||
|
||||
.token.atrule,
|
||||
.token.attr-value,
|
||||
.token.keyword {
|
||||
color: #859900; /* green */
|
||||
}
|
||||
|
||||
.token.function,
|
||||
.token.class-name {
|
||||
color: #b58900; /* yellow */
|
||||
}
|
||||
|
||||
.token.regex,
|
||||
.token.important,
|
||||
.token.variable {
|
||||
color: #cb4b16; /* orange */
|
||||
}
|
||||
|
||||
.token.important,
|
||||
.token.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
.token.italic {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.token.entity {
|
||||
cursor: help;
|
||||
}
|
122
docs/gitbook/gitbook-plugin-prism/prism-tomorrow.css
Normal file
122
docs/gitbook/gitbook-plugin-prism/prism-tomorrow.css
Normal file
@ -0,0 +1,122 @@
|
||||
/**
|
||||
* prism.js tomorrow night eighties for JavaScript, CoffeeScript, CSS and HTML
|
||||
* Based on https://github.com/chriskempson/tomorrow-theme
|
||||
* @author Rose Pritchard
|
||||
*/
|
||||
|
||||
code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
color: #ccc;
|
||||
background: none;
|
||||
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
|
||||
font-size: 1em;
|
||||
text-align: left;
|
||||
white-space: pre;
|
||||
word-spacing: normal;
|
||||
word-break: normal;
|
||||
word-wrap: normal;
|
||||
line-height: 1.5;
|
||||
|
||||
-moz-tab-size: 4;
|
||||
-o-tab-size: 4;
|
||||
tab-size: 4;
|
||||
|
||||
-webkit-hyphens: none;
|
||||
-moz-hyphens: none;
|
||||
-ms-hyphens: none;
|
||||
hyphens: none;
|
||||
|
||||
}
|
||||
|
||||
/* Code blocks */
|
||||
pre[class*="language-"] {
|
||||
padding: 1em;
|
||||
margin: .5em 0;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
:not(pre) > code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
background: #2d2d2d;
|
||||
}
|
||||
|
||||
/* Inline code */
|
||||
:not(pre) > code[class*="language-"] {
|
||||
padding: .1em;
|
||||
border-radius: .3em;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.token.comment,
|
||||
.token.block-comment,
|
||||
.token.prolog,
|
||||
.token.doctype,
|
||||
.token.cdata {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.token.punctuation {
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.token.tag,
|
||||
.token.attr-name,
|
||||
.token.namespace,
|
||||
.token.deleted {
|
||||
color: #e2777a;
|
||||
}
|
||||
|
||||
.token.function-name {
|
||||
color: #6196cc;
|
||||
}
|
||||
|
||||
.token.boolean,
|
||||
.token.number,
|
||||
.token.function {
|
||||
color: #f08d49;
|
||||
}
|
||||
|
||||
.token.property,
|
||||
.token.class-name,
|
||||
.token.constant,
|
||||
.token.symbol {
|
||||
color: #f8c555;
|
||||
}
|
||||
|
||||
.token.selector,
|
||||
.token.important,
|
||||
.token.atrule,
|
||||
.token.keyword,
|
||||
.token.builtin {
|
||||
color: #cc99cd;
|
||||
}
|
||||
|
||||
.token.string,
|
||||
.token.char,
|
||||
.token.attr-value,
|
||||
.token.regex,
|
||||
.token.variable {
|
||||
color: #7ec699;
|
||||
}
|
||||
|
||||
.token.operator,
|
||||
.token.entity,
|
||||
.token.url {
|
||||
color: #67cdcc;
|
||||
}
|
||||
|
||||
.token.important,
|
||||
.token.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
.token.italic {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.token.entity {
|
||||
cursor: help;
|
||||
}
|
||||
|
||||
.token.inserted {
|
||||
color: green;
|
||||
}
|
199
docs/gitbook/gitbook-plugin-prism/prism-twilight.css
Normal file
199
docs/gitbook/gitbook-plugin-prism/prism-twilight.css
Normal file
@ -0,0 +1,199 @@
|
||||
/**
|
||||
* prism.js Twilight theme
|
||||
* Based (more or less) on the Twilight theme originally of Textmate fame.
|
||||
* @author Remy Bach
|
||||
*/
|
||||
code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
color: white;
|
||||
background: none;
|
||||
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
|
||||
font-size: 1em;
|
||||
text-align: left;
|
||||
text-shadow: 0 -.1em .2em black;
|
||||
white-space: pre;
|
||||
word-spacing: normal;
|
||||
word-break: normal;
|
||||
word-wrap: normal;
|
||||
line-height: 1.5;
|
||||
|
||||
-moz-tab-size: 4;
|
||||
-o-tab-size: 4;
|
||||
tab-size: 4;
|
||||
|
||||
-webkit-hyphens: none;
|
||||
-moz-hyphens: none;
|
||||
-ms-hyphens: none;
|
||||
hyphens: none;
|
||||
}
|
||||
|
||||
pre[class*="language-"],
|
||||
:not(pre) > code[class*="language-"] {
|
||||
background: hsl(0, 0%, 8%); /* #141414 */
|
||||
}
|
||||
|
||||
/* Code blocks */
|
||||
pre[class*="language-"] {
|
||||
border-radius: .5em;
|
||||
border: .3em solid hsl(0, 0%, 33%); /* #282A2B */
|
||||
box-shadow: 1px 1px .5em black inset;
|
||||
margin: .5em 0;
|
||||
overflow: auto;
|
||||
padding: 1em;
|
||||
}
|
||||
|
||||
pre[class*="language-"]::-moz-selection {
|
||||
/* Firefox */
|
||||
background: hsl(200, 4%, 16%); /* #282A2B */
|
||||
}
|
||||
|
||||
pre[class*="language-"]::selection {
|
||||
/* Safari */
|
||||
background: hsl(200, 4%, 16%); /* #282A2B */
|
||||
}
|
||||
|
||||
/* Text Selection colour */
|
||||
pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection,
|
||||
code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection {
|
||||
text-shadow: none;
|
||||
background: hsla(0, 0%, 93%, 0.15); /* #EDEDED */
|
||||
}
|
||||
|
||||
pre[class*="language-"]::selection, pre[class*="language-"] ::selection,
|
||||
code[class*="language-"]::selection, code[class*="language-"] ::selection {
|
||||
text-shadow: none;
|
||||
background: hsla(0, 0%, 93%, 0.15); /* #EDEDED */
|
||||
}
|
||||
|
||||
/* Inline code */
|
||||
:not(pre) > code[class*="language-"] {
|
||||
border-radius: .3em;
|
||||
border: .13em solid hsl(0, 0%, 33%); /* #545454 */
|
||||
box-shadow: 1px 1px .3em -.1em black inset;
|
||||
padding: .15em .2em .05em;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.token.comment,
|
||||
.token.prolog,
|
||||
.token.doctype,
|
||||
.token.cdata {
|
||||
color: hsl(0, 0%, 47%); /* #777777 */
|
||||
}
|
||||
|
||||
.token.punctuation {
|
||||
opacity: .7;
|
||||
}
|
||||
|
||||
.namespace {
|
||||
opacity: .7;
|
||||
}
|
||||
|
||||
.token.tag,
|
||||
.token.boolean,
|
||||
.token.number,
|
||||
.token.deleted {
|
||||
color: hsl(14, 58%, 55%); /* #CF6A4C */
|
||||
}
|
||||
|
||||
.token.keyword,
|
||||
.token.property,
|
||||
.token.selector,
|
||||
.token.constant,
|
||||
.token.symbol,
|
||||
.token.builtin {
|
||||
color: hsl(53, 89%, 79%); /* #F9EE98 */
|
||||
}
|
||||
|
||||
.token.attr-name,
|
||||
.token.attr-value,
|
||||
.token.string,
|
||||
.token.char,
|
||||
.token.operator,
|
||||
.token.entity,
|
||||
.token.url,
|
||||
.language-css .token.string,
|
||||
.style .token.string,
|
||||
.token.variable,
|
||||
.token.inserted {
|
||||
color: hsl(76, 21%, 52%); /* #8F9D6A */
|
||||
}
|
||||
|
||||
.token.atrule {
|
||||
color: hsl(218, 22%, 55%); /* #7587A6 */
|
||||
}
|
||||
|
||||
.token.regex,
|
||||
.token.important {
|
||||
color: hsl(42, 75%, 65%); /* #E9C062 */
|
||||
}
|
||||
|
||||
.token.important,
|
||||
.token.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
.token.italic {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.token.entity {
|
||||
cursor: help;
|
||||
}
|
||||
|
||||
pre[data-line] {
|
||||
padding: 1em 0 1em 3em;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* Markup */
|
||||
.language-markup .token.tag,
|
||||
.language-markup .token.attr-name,
|
||||
.language-markup .token.punctuation {
|
||||
color: hsl(33, 33%, 52%); /* #AC885B */
|
||||
}
|
||||
|
||||
/* Make the tokens sit above the line highlight so the colours don't look faded. */
|
||||
.token {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.line-highlight {
|
||||
background: hsla(0, 0%, 33%, 0.25); /* #545454 */
|
||||
background: linear-gradient(to right, hsla(0, 0%, 33%, .1) 70%, hsla(0, 0%, 33%, 0)); /* #545454 */
|
||||
border-bottom: 1px dashed hsl(0, 0%, 33%); /* #545454 */
|
||||
border-top: 1px dashed hsl(0, 0%, 33%); /* #545454 */
|
||||
left: 0;
|
||||
line-height: inherit;
|
||||
margin-top: 0.75em; /* Same as .prism’s padding-top */
|
||||
padding: inherit 0;
|
||||
pointer-events: none;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
white-space: pre;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.line-highlight:before,
|
||||
.line-highlight[data-end]:after {
|
||||
background-color: hsl(215, 15%, 59%); /* #8794A6 */
|
||||
border-radius: 999px;
|
||||
box-shadow: 0 1px white;
|
||||
color: hsl(24, 20%, 95%); /* #F5F2F0 */
|
||||
content: attr(data-start);
|
||||
font: bold 65%/1.5 sans-serif;
|
||||
left: .6em;
|
||||
min-width: 1em;
|
||||
padding: 0 .5em;
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
text-shadow: none;
|
||||
top: .4em;
|
||||
vertical-align: .3em;
|
||||
}
|
||||
|
||||
.line-highlight[data-end]:after {
|
||||
bottom: .4em;
|
||||
content: attr(data-end);
|
||||
top: auto;
|
||||
}
|
139
docs/gitbook/gitbook-plugin-prism/prism.css
Normal file
139
docs/gitbook/gitbook-plugin-prism/prism.css
Normal file
@ -0,0 +1,139 @@
|
||||
/**
|
||||
* prism.js default theme for JavaScript, CSS and HTML
|
||||
* Based on dabblet (http://dabblet.com)
|
||||
* @author Lea Verou
|
||||
*/
|
||||
|
||||
code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
color: black;
|
||||
background: none;
|
||||
text-shadow: 0 1px white;
|
||||
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
|
||||
font-size: 1em;
|
||||
text-align: left;
|
||||
white-space: pre;
|
||||
word-spacing: normal;
|
||||
word-break: normal;
|
||||
word-wrap: normal;
|
||||
line-height: 1.5;
|
||||
|
||||
-moz-tab-size: 4;
|
||||
-o-tab-size: 4;
|
||||
tab-size: 4;
|
||||
|
||||
-webkit-hyphens: none;
|
||||
-moz-hyphens: none;
|
||||
-ms-hyphens: none;
|
||||
hyphens: none;
|
||||
}
|
||||
|
||||
pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection,
|
||||
code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection {
|
||||
text-shadow: none;
|
||||
background: #b3d4fc;
|
||||
}
|
||||
|
||||
pre[class*="language-"]::selection, pre[class*="language-"] ::selection,
|
||||
code[class*="language-"]::selection, code[class*="language-"] ::selection {
|
||||
text-shadow: none;
|
||||
background: #b3d4fc;
|
||||
}
|
||||
|
||||
@media print {
|
||||
code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
text-shadow: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* Code blocks */
|
||||
pre[class*="language-"] {
|
||||
padding: 1em;
|
||||
margin: .5em 0;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
:not(pre) > code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
background: #f5f2f0;
|
||||
}
|
||||
|
||||
/* Inline code */
|
||||
:not(pre) > code[class*="language-"] {
|
||||
padding: .1em;
|
||||
border-radius: .3em;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.token.comment,
|
||||
.token.prolog,
|
||||
.token.doctype,
|
||||
.token.cdata {
|
||||
color: slategray;
|
||||
}
|
||||
|
||||
.token.punctuation {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.namespace {
|
||||
opacity: .7;
|
||||
}
|
||||
|
||||
.token.property,
|
||||
.token.tag,
|
||||
.token.boolean,
|
||||
.token.number,
|
||||
.token.constant,
|
||||
.token.symbol,
|
||||
.token.deleted {
|
||||
color: #905;
|
||||
}
|
||||
|
||||
.token.selector,
|
||||
.token.attr-name,
|
||||
.token.string,
|
||||
.token.char,
|
||||
.token.builtin,
|
||||
.token.inserted {
|
||||
color: #690;
|
||||
}
|
||||
|
||||
.token.operator,
|
||||
.token.entity,
|
||||
.token.url,
|
||||
.language-css .token.string,
|
||||
.style .token.string {
|
||||
color: #9a6e3a;
|
||||
background: hsla(0, 0%, 100%, .5);
|
||||
}
|
||||
|
||||
.token.atrule,
|
||||
.token.attr-value,
|
||||
.token.keyword {
|
||||
color: #07a;
|
||||
}
|
||||
|
||||
.token.function,
|
||||
.token.class-name {
|
||||
color: #DD4A68;
|
||||
}
|
||||
|
||||
.token.regex,
|
||||
.token.important,
|
||||
.token.variable {
|
||||
color: #e90;
|
||||
}
|
||||
|
||||
.token.important,
|
||||
.token.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
.token.italic {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.token.entity {
|
||||
cursor: help;
|
||||
}
|
478
docs/index.html
478
docs/index.html
@ -17,7 +17,7 @@
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
|
||||
<link rel="stylesheet" href="gitbook/gitbook-plugin-prism/prism.css">
|
||||
|
||||
|
||||
|
||||
@ -47,6 +47,7 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
@ -61,9 +62,12 @@
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="https://cdn.materialdesignicons.com/3.6.95/css/materialdesignicons.min.css">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<div class="book">
|
||||
<div class="book-summary">
|
||||
|
||||
@ -152,6 +156,58 @@
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.4" data-path="nats_server/flags.html">
|
||||
|
||||
<a href="nats_server/flags.html">
|
||||
|
||||
|
||||
Flags
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.5" data-path="nats_server/configuration.html">
|
||||
|
||||
<a href="nats_server/configuration.html">
|
||||
|
||||
|
||||
Configuration File
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.6" data-path="nats_server/signals.html">
|
||||
|
||||
<a href="nats_server/signals.html">
|
||||
|
||||
|
||||
Signals
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.7" data-path="nats_server/windows_srv.html">
|
||||
|
||||
<a href="nats_server/windows_srv.html">
|
||||
|
||||
|
||||
Window Service
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
@ -164,6 +220,38 @@
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2" data-path="developer/">
|
||||
|
||||
<a href="developer/">
|
||||
|
||||
|
||||
Developing with NATS
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.2.1" data-path="developer/connecting.html">
|
||||
|
||||
<a href="developer/connecting.html">
|
||||
|
||||
|
||||
Connecting
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
|
||||
@ -249,11 +337,397 @@
|
||||
<script>
|
||||
var gitbook = gitbook || [];
|
||||
gitbook.push(function() {
|
||||
gitbook.page.hasChanged({"page":{"title":"Introduction","level":"1.1","depth":1,"next":{"title":"NATS Server","level":"1.1.1","depth":2,"path":"nats_server/README.md","ref":"nats_server/README.md","articles":[{"title":"Installing","level":"1.1.1.1","depth":3,"path":"nats_server/installation.md","ref":"nats_server/installation.md","articles":[]},{"title":"Running","level":"1.1.1.2","depth":3,"path":"nats_server/running.md","ref":"nats_server/running.md","articles":[]},{"title":"Clients","level":"1.1.1.3","depth":3,"path":"nats_server/clients.md","ref":"nats_server/clients.md","articles":[]}]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"README.md","mtime":"2019-05-13T22:01:38.511Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-05-13T22:02:53.861Z"},"basePath":".","book":{"language":""}});
|
||||
gitbook.page.hasChanged({"page":{"title":"Introduction","level":"1.1","depth":1,"next":{"title":"NATS Server","level":"1.1.1","depth":2,"path":"nats_server/README.md","ref":"nats_server/README.md","articles":[{"title":"Installing","level":"1.1.1.1","depth":3,"path":"nats_server/installation.md","ref":"nats_server/installation.md","articles":[]},{"title":"Running","level":"1.1.1.2","depth":3,"path":"nats_server/running.md","ref":"nats_server/running.md","articles":[]},{"title":"Clients","level":"1.1.1.3","depth":3,"path":"nats_server/clients.md","ref":"nats_server/clients.md","articles":[]},{"title":"Flags","level":"1.1.1.4","depth":3,"path":"nats_server/flags.md","ref":"nats_server/flags.md","articles":[]},{"title":"Configuration File","level":"1.1.1.5","depth":3,"path":"nats_server/configuration.md","ref":"nats_server/configuration.md","articles":[]},{"title":"Signals","level":"1.1.1.6","depth":3,"path":"nats_server/signals.md","ref":"nats_server/signals.md","articles":[]},{"title":"Window Service","level":"1.1.1.7","depth":3,"path":"nats_server/windows_srv.md","ref":"nats_server/windows_srv.md","articles":[]}]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["prism","-highlight","include-html"],"pluginsConfig":{"prism":{},"include-html":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"README.md","mtime":"2019-05-13T13:59:31.118Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-05-15T15:16:11.909Z"},"basePath":".","book":{"language":""}});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<!-- 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();
|
||||
});
|
||||
}
|
||||
|
||||
function pageChanged() {
|
||||
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>
|
||||
div.graphviz {
|
||||
background: transparent;
|
||||
border: 0;
|
||||
padding-top: 15px;
|
||||
padding-right: 15px;
|
||||
padding-bottom: 15px;
|
||||
padding-left: 15px;
|
||||
}
|
||||
|
||||
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: 10px 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>
|
||||
|
||||
|
||||
<script src="gitbook/gitbook.js"></script>
|
||||
<script src="gitbook/theme.js"></script>
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism.css">
|
||||
|
||||
|
||||
|
||||
@ -47,6 +47,7 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
@ -57,13 +58,18 @@
|
||||
<link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
|
||||
|
||||
|
||||
<link rel="next" href="flags.html" />
|
||||
|
||||
|
||||
<link rel="prev" href="running.html" />
|
||||
|
||||
|
||||
<link rel="stylesheet" href="https://cdn.materialdesignicons.com/3.6.95/css/materialdesignicons.min.css">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<div class="book">
|
||||
<div class="book-summary">
|
||||
|
||||
@ -152,6 +158,58 @@
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.4" data-path="flags.html">
|
||||
|
||||
<a href="flags.html">
|
||||
|
||||
|
||||
Flags
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.5" data-path="configuration.html">
|
||||
|
||||
<a href="configuration.html">
|
||||
|
||||
|
||||
Configuration File
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.6" data-path="signals.html">
|
||||
|
||||
<a href="signals.html">
|
||||
|
||||
|
||||
Signals
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.7" data-path="windows_srv.html">
|
||||
|
||||
<a href="windows_srv.html">
|
||||
|
||||
|
||||
Window Service
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
@ -164,6 +222,38 @@
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2" data-path="../developer/">
|
||||
|
||||
<a href="../developer/">
|
||||
|
||||
|
||||
Developing with NATS
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.2.1" data-path="../developer/connecting.html">
|
||||
|
||||
<a href="../developer/connecting.html">
|
||||
|
||||
|
||||
Connecting
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
|
||||
@ -213,20 +303,20 @@
|
||||
<p>The nats-server doesn't come bundled with any clients. But most client libraries come with tools that allow you to publish, subscribe, send requests and reply messages.</p>
|
||||
<p>If you have a client library installed you can try using a bundled client. Otherwise you can easily install some clients.</p>
|
||||
<h3 id="if-you-have-go-installed">If you have Go installed:</h3>
|
||||
<pre><code>> go get https://github.com/nats-io/go-nats-examples/tools/nats-pub
|
||||
<pre class="language-"><code>> go get https://github.com/nats-io/go-nats-examples/tools/nats-pub
|
||||
> go get https://github.com/nats-io/go-nats-examples/tools/nats-sub
|
||||
</code></pre><h3 id="or-download-a-zip-file">Or download a zip file</h3>
|
||||
<p>You can pre-built binaries from the <a href="https://github.com/nats-io/go-nats-examples/releases/tag/0.0.50" target="_blank">go-nats-examples repo</a></p>
|
||||
<h3 id="testing-your-setup">Testing your setup</h3>
|
||||
<p>First <a href="running.html">start a nats-server</a>. Then you can on two different terminal windows:</p>
|
||||
<p>Start a subscriber:</p>
|
||||
<pre><code>> nats-sub ">"
|
||||
<pre class="language-"><code>> nats-sub ">"
|
||||
Listening on [>]
|
||||
</code></pre><p>Publish your first message:</p>
|
||||
<pre><code>> nats-pub hello world
|
||||
<pre class="language-"><code>> nats-pub hello world
|
||||
Published [hello] : 'world'
|
||||
</code></pre><p>On the subscriber window you should see:</p>
|
||||
<pre><code>[#1] Received on [hello]: 'world'
|
||||
<pre class="language-"><code>[#1] Received on [hello]: 'world'
|
||||
</code></pre>
|
||||
|
||||
</section>
|
||||
@ -254,11 +344,15 @@ Published [hello] : 'world'
|
||||
|
||||
|
||||
|
||||
<a href="running.html" class="navigation navigation-prev navigation-unique" aria-label="Previous page: Running">
|
||||
<a href="running.html" class="navigation navigation-prev " aria-label="Previous page: Running">
|
||||
<i class="fa fa-angle-left"></i>
|
||||
</a>
|
||||
|
||||
|
||||
<a href="flags.html" class="navigation navigation-next " aria-label="Next page: Flags">
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
@ -266,11 +360,397 @@ Published [hello] : 'world'
|
||||
<script>
|
||||
var gitbook = gitbook || [];
|
||||
gitbook.push(function() {
|
||||
gitbook.page.hasChanged({"page":{"title":"Clients","level":"1.1.1.3","depth":3,"previous":{"title":"Running","level":"1.1.1.2","depth":3,"path":"nats_server/running.md","ref":"nats_server/running.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"nats_server/clients.md","mtime":"2019-05-13T22:01:38.527Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-05-13T22:02:53.861Z"},"basePath":"..","book":{"language":""}});
|
||||
gitbook.page.hasChanged({"page":{"title":"Clients","level":"1.1.1.3","depth":3,"next":{"title":"Flags","level":"1.1.1.4","depth":3,"path":"nats_server/flags.md","ref":"nats_server/flags.md","articles":[]},"previous":{"title":"Running","level":"1.1.1.2","depth":3,"path":"nats_server/running.md","ref":"nats_server/running.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["prism","-highlight","include-html"],"pluginsConfig":{"prism":{},"include-html":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"nats_server/clients.md","mtime":"2019-05-13T15:08:53.940Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-05-15T15:16:11.909Z"},"basePath":"..","book":{"language":""}});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<!-- 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();
|
||||
});
|
||||
}
|
||||
|
||||
function pageChanged() {
|
||||
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>
|
||||
div.graphviz {
|
||||
background: transparent;
|
||||
border: 0;
|
||||
padding-top: 15px;
|
||||
padding-right: 15px;
|
||||
padding-bottom: 15px;
|
||||
padding-left: 15px;
|
||||
}
|
||||
|
||||
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: 10px 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>
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook.js"></script>
|
||||
<script src="../gitbook/theme.js"></script>
|
||||
|
806
docs/nats_server/configuration.html
Normal file
806
docs/nats_server/configuration.html
Normal file
@ -0,0 +1,806 @@
|
||||
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="" >
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||||
<title>Configuration File · GitBook</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="description" content="">
|
||||
<meta name="generator" content="GitBook 3.2.3">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/style.css">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
|
||||
<link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
|
||||
|
||||
|
||||
<link rel="next" href="signals.html" />
|
||||
|
||||
|
||||
<link rel="prev" href="flags.html" />
|
||||
|
||||
|
||||
<link rel="stylesheet" href="https://cdn.materialdesignicons.com/3.6.95/css/materialdesignicons.min.css">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<div class="book">
|
||||
<div class="book-summary">
|
||||
|
||||
|
||||
<div id="book-search-input" role="search">
|
||||
<input type="text" placeholder="Type to search" />
|
||||
</div>
|
||||
|
||||
|
||||
<nav role="navigation">
|
||||
|
||||
|
||||
|
||||
<ul class="summary">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.1" data-path="../">
|
||||
|
||||
<a href="../">
|
||||
|
||||
|
||||
Introduction
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.1.1" data-path="./">
|
||||
|
||||
<a href="./">
|
||||
|
||||
|
||||
NATS Server
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.1.1.1" data-path="installation.html">
|
||||
|
||||
<a href="installation.html">
|
||||
|
||||
|
||||
Installing
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.2" data-path="running.html">
|
||||
|
||||
<a href="running.html">
|
||||
|
||||
|
||||
Running
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.3" data-path="clients.html">
|
||||
|
||||
<a href="clients.html">
|
||||
|
||||
|
||||
Clients
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.4" data-path="flags.html">
|
||||
|
||||
<a href="flags.html">
|
||||
|
||||
|
||||
Flags
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter active" data-level="1.1.1.5" data-path="configuration.html">
|
||||
|
||||
<a href="configuration.html">
|
||||
|
||||
|
||||
Configuration File
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.6" data-path="signals.html">
|
||||
|
||||
<a href="signals.html">
|
||||
|
||||
|
||||
Signals
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.7" data-path="windows_srv.html">
|
||||
|
||||
<a href="windows_srv.html">
|
||||
|
||||
|
||||
Window Service
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2" data-path="../developer/">
|
||||
|
||||
<a href="../developer/">
|
||||
|
||||
|
||||
Developing with NATS
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.2.1" data-path="../developer/connecting.html">
|
||||
|
||||
<a href="../developer/connecting.html">
|
||||
|
||||
|
||||
Connecting
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
|
||||
<li class="divider"></li>
|
||||
|
||||
<li>
|
||||
<a href="https://www.gitbook.com" target="blank" class="gitbook-link">
|
||||
Published with GitBook
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
</nav>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="book-body">
|
||||
|
||||
<div class="body-inner">
|
||||
|
||||
|
||||
|
||||
<div class="book-header" role="navigation">
|
||||
|
||||
|
||||
<!-- Title -->
|
||||
<h1>
|
||||
<i class="fa fa-circle-o-notch fa-spin"></i>
|
||||
<a href=".." >Configuration File</a>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="page-wrapper" tabindex="-1" role="main">
|
||||
<div class="page-inner">
|
||||
|
||||
<div id="book-search-results">
|
||||
<div class="search-noresults">
|
||||
|
||||
<section class="normal markdown-section">
|
||||
|
||||
<h2 id="configuration-file-format">Configuration File Format</h2>
|
||||
<p>The NATS server products provide a flexible configuration format that combines the best of traditional formats and newer styles such as JSON and YAML.</p>
|
||||
<p>The config file supports the following syntax:</p>
|
||||
<ul>
|
||||
<li>Lines or options can be commented with <code>#</code> and <code>//</code></li>
|
||||
<li>Value assignment can use:<ul>
|
||||
<li>Equals sign: <code>foo = 2</code></li>
|
||||
<li>Colon: <code>foo: 2</code></li>
|
||||
<li>Whitespace: <code>foo 2</code></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>Arrays are enclosed in brackets: <code>[...]</code></li>
|
||||
<li>Maps are enclosed in braces: <code>{...}</code></li>
|
||||
<li>Maps can be assigned with no key separator</li>
|
||||
<li>Semicolons can be used as terminators</li>
|
||||
</ul>
|
||||
<h3 id="variables">Variables</h3>
|
||||
<p>Server configurations can specify variables. Variables allow you to reference a value from one or more sections in the configuration. </p>
|
||||
<p>Variables:</p>
|
||||
<ul>
|
||||
<li>Are block scoped</li>
|
||||
<li>Are referenced with a <code>$</code> prefix.</li>
|
||||
<li>Can be resolved from the environment</li>
|
||||
</ul>
|
||||
<blockquote>
|
||||
<p>If the environment variable value begins with a number you may have trouble resolving it depending on the server version you are running.</p>
|
||||
</blockquote>
|
||||
<pre class="language-"><code># Define a variable in the config
|
||||
TOKEN: "secret"
|
||||
|
||||
# Reference the variable
|
||||
authorization {
|
||||
token: $TOKEN
|
||||
}
|
||||
</code></pre><p>A similar configuration, but this time, the value is in the environment:</p>
|
||||
<pre class="language-"><code>authorization {
|
||||
token: $TOKEN
|
||||
}
|
||||
</code></pre><p>export TOKEN="hello"; nats-server -c /config/file</p>
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<div class="search-results">
|
||||
<div class="has-results">
|
||||
|
||||
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
|
||||
<ul class="search-results-list"></ul>
|
||||
|
||||
</div>
|
||||
<div class="no-results">
|
||||
|
||||
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<a href="flags.html" class="navigation navigation-prev " aria-label="Previous page: Flags">
|
||||
<i class="fa fa-angle-left"></i>
|
||||
</a>
|
||||
|
||||
|
||||
<a href="signals.html" class="navigation navigation-next " aria-label="Next page: Signals">
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var gitbook = gitbook || [];
|
||||
gitbook.push(function() {
|
||||
gitbook.page.hasChanged({"page":{"title":"Configuration File","level":"1.1.1.5","depth":3,"next":{"title":"Signals","level":"1.1.1.6","depth":3,"path":"nats_server/signals.md","ref":"nats_server/signals.md","articles":[]},"previous":{"title":"Flags","level":"1.1.1.4","depth":3,"path":"nats_server/flags.md","ref":"nats_server/flags.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["prism","-highlight","include-html"],"pluginsConfig":{"prism":{},"include-html":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"nats_server/configuration.md","mtime":"2019-05-13T21:46:03.611Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-05-15T15:16:11.909Z"},"basePath":"..","book":{"language":""}});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<!-- 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();
|
||||
});
|
||||
}
|
||||
|
||||
function pageChanged() {
|
||||
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>
|
||||
div.graphviz {
|
||||
background: transparent;
|
||||
border: 0;
|
||||
padding-top: 15px;
|
||||
padding-right: 15px;
|
||||
padding-bottom: 15px;
|
||||
padding-left: 15px;
|
||||
}
|
||||
|
||||
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: 10px 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>
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook.js"></script>
|
||||
<script src="../gitbook/theme.js"></script>
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
972
docs/nats_server/flags.html
Normal file
972
docs/nats_server/flags.html
Normal file
@ -0,0 +1,972 @@
|
||||
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="" >
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||||
<title>Flags · GitBook</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="description" content="">
|
||||
<meta name="generator" content="GitBook 3.2.3">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/style.css">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
|
||||
<link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
|
||||
|
||||
|
||||
<link rel="next" href="configuration.html" />
|
||||
|
||||
|
||||
<link rel="prev" href="clients.html" />
|
||||
|
||||
|
||||
<link rel="stylesheet" href="https://cdn.materialdesignicons.com/3.6.95/css/materialdesignicons.min.css">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<div class="book">
|
||||
<div class="book-summary">
|
||||
|
||||
|
||||
<div id="book-search-input" role="search">
|
||||
<input type="text" placeholder="Type to search" />
|
||||
</div>
|
||||
|
||||
|
||||
<nav role="navigation">
|
||||
|
||||
|
||||
|
||||
<ul class="summary">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.1" data-path="../">
|
||||
|
||||
<a href="../">
|
||||
|
||||
|
||||
Introduction
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.1.1" data-path="./">
|
||||
|
||||
<a href="./">
|
||||
|
||||
|
||||
NATS Server
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.1.1.1" data-path="installation.html">
|
||||
|
||||
<a href="installation.html">
|
||||
|
||||
|
||||
Installing
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.2" data-path="running.html">
|
||||
|
||||
<a href="running.html">
|
||||
|
||||
|
||||
Running
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.3" data-path="clients.html">
|
||||
|
||||
<a href="clients.html">
|
||||
|
||||
|
||||
Clients
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter active" data-level="1.1.1.4" data-path="flags.html">
|
||||
|
||||
<a href="flags.html">
|
||||
|
||||
|
||||
Flags
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.5" data-path="configuration.html">
|
||||
|
||||
<a href="configuration.html">
|
||||
|
||||
|
||||
Configuration File
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.6" data-path="signals.html">
|
||||
|
||||
<a href="signals.html">
|
||||
|
||||
|
||||
Signals
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.7" data-path="windows_srv.html">
|
||||
|
||||
<a href="windows_srv.html">
|
||||
|
||||
|
||||
Window Service
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2" data-path="../developer/">
|
||||
|
||||
<a href="../developer/">
|
||||
|
||||
|
||||
Developing with NATS
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.2.1" data-path="../developer/connecting.html">
|
||||
|
||||
<a href="../developer/connecting.html">
|
||||
|
||||
|
||||
Connecting
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
|
||||
<li class="divider"></li>
|
||||
|
||||
<li>
|
||||
<a href="https://www.gitbook.com" target="blank" class="gitbook-link">
|
||||
Published with GitBook
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
</nav>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="book-body">
|
||||
|
||||
<div class="body-inner">
|
||||
|
||||
|
||||
|
||||
<div class="book-header" role="navigation">
|
||||
|
||||
|
||||
<!-- Title -->
|
||||
<h1>
|
||||
<i class="fa fa-circle-o-notch fa-spin"></i>
|
||||
<a href=".." >Flags</a>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="page-wrapper" tabindex="-1" role="main">
|
||||
<div class="page-inner">
|
||||
|
||||
<div id="book-search-results">
|
||||
<div class="search-noresults">
|
||||
|
||||
<section class="normal markdown-section">
|
||||
|
||||
<h2 id="flags">Flags</h2>
|
||||
<p>The NATS server has many flags to customize it's behaviour without having to write a configuration file.</p>
|
||||
<p>The configuration flags revolve around:</p>
|
||||
<ul>
|
||||
<li>Server Options</li>
|
||||
<li>Logging</li>
|
||||
<li>Authorization</li>
|
||||
<li>TLS Security</li>
|
||||
<li>Clustering</li>
|
||||
<li>Information</li>
|
||||
</ul>
|
||||
<h3 id="server-options">Server Options</h3>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="text-align:left">Flag</th>
|
||||
<th style="text-align:left">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="text-align:left"><code>-a</code>, <code>--addr</code></td>
|
||||
<td style="text-align:left">Host address to bind to (default: 0.0.0.0) - all interfaces.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:left"><code>-p</code>, <code>--port</code></td>
|
||||
<td style="text-align:left">NATS client port (default: 4222).</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:left"><code>-P</code>, <code>--pid</code></td>
|
||||
<td style="text-align:left">File to store the process ID (PID).</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:left"><code>-m</code>, <code>--http_port</code></td>
|
||||
<td style="text-align:left">HTTP port for monitoring dashboard (exclusive of <code>--https_port</code>).</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:left"><code>-ms</code>, <code>--https_port</code></td>
|
||||
<td style="text-align:left">HTTPS port monitoring for monitoring dashboard (exclusive of <code>--http_port</code>).</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:left"><code>-c</code>, <code>--config</code></td>
|
||||
<td style="text-align:left">Path to NATS server configuration file.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:left"><code>-sl</code>, <code>--signal</code></td>
|
||||
<td style="text-align:left">Send a signal to nats-server process. See <a href="signals.html">process signaling</a>.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:left"><code>--client_advertise</code></td>
|
||||
<td style="text-align:left">Client HostPort to advertise to other servers.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:left"><code>-t</code></td>
|
||||
<td style="text-align:left">Test configuration and exit</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<h3 id="logging-options">Logging Options</h3>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="text-align:left">Flag</th>
|
||||
<th style="text-align:left">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="text-align:left"><code>-l</code>, <code>--log</code></td>
|
||||
<td style="text-align:left">File to redirect log output</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:left"><code>-T</code>, <code>--logtime</code></td>
|
||||
<td style="text-align:left">Specify <code>-T=false</code> to disable timestamping log entries</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:left"><code>-s</code>, <code>--syslog</code></td>
|
||||
<td style="text-align:left">Log to syslog or windows event log</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:left"><code>-r</code>, <code>--remote_syslog</code></td>
|
||||
<td style="text-align:left">The syslog server address, like <code>udp://localhost:514</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:left"><code>-D</code>, <code>--debug</code></td>
|
||||
<td style="text-align:left">Enable debugging output</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:left"><code>-V</code>, <code>--trace</code></td>
|
||||
<td style="text-align:left">Enable protocol trace log messages</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:left"><code>-DV</code></td>
|
||||
<td style="text-align:left">Enable both debug and protocol trace messages</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<h3 id="authorization-options">Authorization Options</h3>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="text-align:left">Flag</th>
|
||||
<th style="text-align:left">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="text-align:left"><code>--user</code></td>
|
||||
<td style="text-align:left">Required <em>username</em> for connections.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:left"><code>--pass</code></td>
|
||||
<td style="text-align:left">Required <em>password</em> for connections.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:left"><code>--auth</code></td>
|
||||
<td style="text-align:left">Required <em>authorization token</em> for connections.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<h3 id="tls-options">TLS Options</h3>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="text-align:left">Flag</th>
|
||||
<th style="text-align:left">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="text-align:left"><code>--tls</code></td>
|
||||
<td style="text-align:left">Enable TLS, do not verify clients</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:left"><code>--tlscert</code></td>
|
||||
<td style="text-align:left">Server certificate file</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:left"><code>--tlskey</code></td>
|
||||
<td style="text-align:left">Private key for server certificate</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:left"><code>--tlsverify</code></td>
|
||||
<td style="text-align:left">Enable client TLS certificate verification</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:left"><code>--tlscacert</code></td>
|
||||
<td style="text-align:left">Client certificate CA for verification</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<h3 id="cluster-options">Cluster Options</h3>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="text-align:left">Flag</th>
|
||||
<th style="text-align:left">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="text-align:left"><code>--routes</code></td>
|
||||
<td style="text-align:left">Comma separated list of cluster URLs to solicit and connect</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:left"><code>--cluster</code></td>
|
||||
<td style="text-align:left">Cluster URL for clustering requests</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:left"><code>--no_advertise</code></td>
|
||||
<td style="text-align:left">Do not advertise known cluster information to clients</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:left"><code>--cluster_advertise</code></td>
|
||||
<td style="text-align:left">Cluster URL to advertise to other servers</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:left"><code>--connect_retries</code></td>
|
||||
<td style="text-align:left">For implicit routes, number of connect retries</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<h3 id="common-options">Common Options</h3>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="text-align:left">Flag</th>
|
||||
<th style="text-align:left">Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="text-align:left"><code>-h</code>, <code>--help</code></td>
|
||||
<td style="text-align:left">Show this message</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:left"><code>-v</code>, <code>--version</code></td>
|
||||
<td style="text-align:left">Show version</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:left"><code>--help_tls</code></td>
|
||||
<td style="text-align:left">TLS help</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<div class="search-results">
|
||||
<div class="has-results">
|
||||
|
||||
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
|
||||
<ul class="search-results-list"></ul>
|
||||
|
||||
</div>
|
||||
<div class="no-results">
|
||||
|
||||
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<a href="clients.html" class="navigation navigation-prev " aria-label="Previous page: Clients">
|
||||
<i class="fa fa-angle-left"></i>
|
||||
</a>
|
||||
|
||||
|
||||
<a href="configuration.html" class="navigation navigation-next " aria-label="Next page: Configuration File">
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var gitbook = gitbook || [];
|
||||
gitbook.push(function() {
|
||||
gitbook.page.hasChanged({"page":{"title":"Flags","level":"1.1.1.4","depth":3,"next":{"title":"Configuration File","level":"1.1.1.5","depth":3,"path":"nats_server/configuration.md","ref":"nats_server/configuration.md","articles":[]},"previous":{"title":"Clients","level":"1.1.1.3","depth":3,"path":"nats_server/clients.md","ref":"nats_server/clients.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["prism","-highlight","include-html"],"pluginsConfig":{"prism":{},"include-html":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"nats_server/flags.md","mtime":"2019-05-13T21:14:44.370Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-05-15T15:16:11.909Z"},"basePath":"..","book":{"language":""}});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<!-- 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();
|
||||
});
|
||||
}
|
||||
|
||||
function pageChanged() {
|
||||
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>
|
||||
div.graphviz {
|
||||
background: transparent;
|
||||
border: 0;
|
||||
padding-top: 15px;
|
||||
padding-right: 15px;
|
||||
padding-bottom: 15px;
|
||||
padding-left: 15px;
|
||||
}
|
||||
|
||||
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: 10px 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>
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook.js"></script>
|
||||
<script src="../gitbook/theme.js"></script>
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism.css">
|
||||
|
||||
|
||||
|
||||
@ -47,6 +47,7 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
@ -63,9 +64,12 @@
|
||||
<link rel="prev" href="../" />
|
||||
|
||||
|
||||
<link rel="stylesheet" href="https://cdn.materialdesignicons.com/3.6.95/css/materialdesignicons.min.css">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<div class="book">
|
||||
<div class="book-summary">
|
||||
|
||||
@ -154,6 +158,58 @@
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.4" data-path="flags.html">
|
||||
|
||||
<a href="flags.html">
|
||||
|
||||
|
||||
Flags
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.5" data-path="configuration.html">
|
||||
|
||||
<a href="configuration.html">
|
||||
|
||||
|
||||
Configuration File
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.6" data-path="signals.html">
|
||||
|
||||
<a href="signals.html">
|
||||
|
||||
|
||||
Signals
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.7" data-path="windows_srv.html">
|
||||
|
||||
<a href="windows_srv.html">
|
||||
|
||||
|
||||
Window Service
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
@ -166,6 +222,38 @@
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2" data-path="../developer/">
|
||||
|
||||
<a href="../developer/">
|
||||
|
||||
|
||||
Developing with NATS
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.2.1" data-path="../developer/connecting.html">
|
||||
|
||||
<a href="../developer/connecting.html">
|
||||
|
||||
|
||||
Connecting
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
|
||||
@ -259,11 +347,397 @@
|
||||
<script>
|
||||
var gitbook = gitbook || [];
|
||||
gitbook.push(function() {
|
||||
gitbook.page.hasChanged({"page":{"title":"NATS Server","level":"1.1.1","depth":2,"next":{"title":"Installing","level":"1.1.1.1","depth":3,"path":"nats_server/installation.md","ref":"nats_server/installation.md","articles":[]},"previous":{"title":"Introduction","level":"1.1","depth":1,"path":"README.md","ref":"README.md","articles":[{"title":"NATS Server","level":"1.1.1","depth":2,"path":"nats_server/README.md","ref":"nats_server/README.md","articles":[{"title":"Installing","level":"1.1.1.1","depth":3,"path":"nats_server/installation.md","ref":"nats_server/installation.md","articles":[]},{"title":"Running","level":"1.1.1.2","depth":3,"path":"nats_server/running.md","ref":"nats_server/running.md","articles":[]},{"title":"Clients","level":"1.1.1.3","depth":3,"path":"nats_server/clients.md","ref":"nats_server/clients.md","articles":[]}]}]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"nats_server/README.md","mtime":"2019-05-13T22:01:38.527Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-05-13T22:02:53.861Z"},"basePath":"..","book":{"language":""}});
|
||||
gitbook.page.hasChanged({"page":{"title":"NATS Server","level":"1.1.1","depth":2,"next":{"title":"Installing","level":"1.1.1.1","depth":3,"path":"nats_server/installation.md","ref":"nats_server/installation.md","articles":[]},"previous":{"title":"Introduction","level":"1.1","depth":1,"path":"README.md","ref":"README.md","articles":[{"title":"NATS Server","level":"1.1.1","depth":2,"path":"nats_server/README.md","ref":"nats_server/README.md","articles":[{"title":"Installing","level":"1.1.1.1","depth":3,"path":"nats_server/installation.md","ref":"nats_server/installation.md","articles":[]},{"title":"Running","level":"1.1.1.2","depth":3,"path":"nats_server/running.md","ref":"nats_server/running.md","articles":[]},{"title":"Clients","level":"1.1.1.3","depth":3,"path":"nats_server/clients.md","ref":"nats_server/clients.md","articles":[]},{"title":"Flags","level":"1.1.1.4","depth":3,"path":"nats_server/flags.md","ref":"nats_server/flags.md","articles":[]},{"title":"Configuration File","level":"1.1.1.5","depth":3,"path":"nats_server/configuration.md","ref":"nats_server/configuration.md","articles":[]},{"title":"Signals","level":"1.1.1.6","depth":3,"path":"nats_server/signals.md","ref":"nats_server/signals.md","articles":[]},{"title":"Window Service","level":"1.1.1.7","depth":3,"path":"nats_server/windows_srv.md","ref":"nats_server/windows_srv.md","articles":[]}]}]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["prism","-highlight","include-html"],"pluginsConfig":{"prism":{},"include-html":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"nats_server/README.md","mtime":"2019-05-13T14:20:04.050Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-05-15T15:16:11.909Z"},"basePath":"..","book":{"language":""}});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<!-- 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();
|
||||
});
|
||||
}
|
||||
|
||||
function pageChanged() {
|
||||
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>
|
||||
div.graphviz {
|
||||
background: transparent;
|
||||
border: 0;
|
||||
padding-top: 15px;
|
||||
padding-right: 15px;
|
||||
padding-bottom: 15px;
|
||||
padding-left: 15px;
|
||||
}
|
||||
|
||||
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: 10px 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>
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook.js"></script>
|
||||
<script src="../gitbook/theme.js"></script>
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism.css">
|
||||
|
||||
|
||||
|
||||
@ -47,6 +47,7 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
@ -63,9 +64,12 @@
|
||||
<link rel="prev" href="./" />
|
||||
|
||||
|
||||
<link rel="stylesheet" href="https://cdn.materialdesignicons.com/3.6.95/css/materialdesignicons.min.css">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<div class="book">
|
||||
<div class="book-summary">
|
||||
|
||||
@ -154,6 +158,58 @@
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.4" data-path="flags.html">
|
||||
|
||||
<a href="flags.html">
|
||||
|
||||
|
||||
Flags
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.5" data-path="configuration.html">
|
||||
|
||||
<a href="configuration.html">
|
||||
|
||||
|
||||
Configuration File
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.6" data-path="signals.html">
|
||||
|
||||
<a href="signals.html">
|
||||
|
||||
|
||||
Signals
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.7" data-path="windows_srv.html">
|
||||
|
||||
<a href="windows_srv.html">
|
||||
|
||||
|
||||
Window Service
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
@ -166,6 +222,38 @@
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2" data-path="../developer/">
|
||||
|
||||
<a href="../developer/">
|
||||
|
||||
|
||||
Developing with NATS
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.2.1" data-path="../developer/connecting.html">
|
||||
|
||||
<a href="../developer/connecting.html">
|
||||
|
||||
|
||||
Connecting
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
|
||||
@ -215,15 +303,15 @@
|
||||
<p>NATS philosophy is simplicity. Installation is just decompression a zip file and copying the binary to an appropiate directory; you can also use your favorite package manager.</p>
|
||||
<h3 id="installing-via-a-package-manager">Installing via a Package Manager</h3>
|
||||
<p>On Windows:</p>
|
||||
<pre><code>> choco install nats-server
|
||||
<pre class="language-"><code>> choco install nats-server
|
||||
</code></pre><p>On Mac OS:</p>
|
||||
<pre><code>> brew install nats-server
|
||||
<pre class="language-"><code>> brew install nats-server
|
||||
</code></pre><p>Via Docker:</p>
|
||||
<pre><code>> docker pull nats-server:latest
|
||||
<pre class="language-"><code>> docker pull nats-server:latest
|
||||
</code></pre><h3 id="installing-directly-release-build">Installing directly Release Build</h3>
|
||||
<p>You can find the latest release of nats-server <a href="https://github.com/nats-io/nats-server/releases/latest" target="_blank">here</a>.</p>
|
||||
<p>Simply download the zip file matching your systems architecture, and unzip. For this example, assuming version 2.0.0 of the server, and a Linux AMD64:</p>
|
||||
<pre><code>> curl -L https://github.com/nats-io/nats-server/releases/download/v2.0.0/nats-server-v2.0.0-linux-amd64.zip -o nats-server.zip
|
||||
<pre class="language-"><code>> curl -L https://github.com/nats-io/nats-server/releases/download/v2.0.0/nats-server-v2.0.0-linux-amd64.zip -o nats-server.zip
|
||||
|
||||
> unzip nats-server.zip -d nats-server
|
||||
Archive: nats-server.zip
|
||||
@ -235,11 +323,11 @@ Archive: nats-server.zip
|
||||
> cp nats-server-v2.0.0darwin-amd64/nats-server /usr/local/bin
|
||||
</code></pre><h3 id="installing-from-the-source">Installing from the source</h3>
|
||||
<p>If you have go installed, installing the binary is very easy:</p>
|
||||
<pre><code>> go get github.com/nats-io/nats-server
|
||||
<pre class="language-"><code>> go get github.com/nats-io/nats-server
|
||||
</code></pre><p>This mechanism will always install the latest build on <a href="https://github.com/nats-io/nats-server" target="_blank">master</a>, which almost certainly will not be a released version. If you are a developer and want to play with the the latest, this is the easiest way of obtaining it. </p>
|
||||
<h2 id="testing-your-installation">Testing Your Installation</h2>
|
||||
<p>To test your installation (provided the install locations are visible by your shell):</p>
|
||||
<pre><code>> nats-server
|
||||
<pre class="language-"><code>> nats-server
|
||||
[41634] 2019/05/13 09:42:11.745919 [INF] Starting nats-server version 2.0.0
|
||||
[41634] 2019/05/13 09:42:11.746240 [INF] Listening for client connections on 0.0.0.0:4222
|
||||
...
|
||||
@ -288,11 +376,397 @@ Archive: nats-server.zip
|
||||
<script>
|
||||
var gitbook = gitbook || [];
|
||||
gitbook.push(function() {
|
||||
gitbook.page.hasChanged({"page":{"title":"Installing","level":"1.1.1.1","depth":3,"next":{"title":"Running","level":"1.1.1.2","depth":3,"path":"nats_server/running.md","ref":"nats_server/running.md","articles":[]},"previous":{"title":"NATS Server","level":"1.1.1","depth":2,"path":"nats_server/README.md","ref":"nats_server/README.md","articles":[{"title":"Installing","level":"1.1.1.1","depth":3,"path":"nats_server/installation.md","ref":"nats_server/installation.md","articles":[]},{"title":"Running","level":"1.1.1.2","depth":3,"path":"nats_server/running.md","ref":"nats_server/running.md","articles":[]},{"title":"Clients","level":"1.1.1.3","depth":3,"path":"nats_server/clients.md","ref":"nats_server/clients.md","articles":[]}]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"nats_server/installation.md","mtime":"2019-05-13T22:01:38.527Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-05-13T22:02:53.861Z"},"basePath":"..","book":{"language":""}});
|
||||
gitbook.page.hasChanged({"page":{"title":"Installing","level":"1.1.1.1","depth":3,"next":{"title":"Running","level":"1.1.1.2","depth":3,"path":"nats_server/running.md","ref":"nats_server/running.md","articles":[]},"previous":{"title":"NATS Server","level":"1.1.1","depth":2,"path":"nats_server/README.md","ref":"nats_server/README.md","articles":[{"title":"Installing","level":"1.1.1.1","depth":3,"path":"nats_server/installation.md","ref":"nats_server/installation.md","articles":[]},{"title":"Running","level":"1.1.1.2","depth":3,"path":"nats_server/running.md","ref":"nats_server/running.md","articles":[]},{"title":"Clients","level":"1.1.1.3","depth":3,"path":"nats_server/clients.md","ref":"nats_server/clients.md","articles":[]},{"title":"Flags","level":"1.1.1.4","depth":3,"path":"nats_server/flags.md","ref":"nats_server/flags.md","articles":[]},{"title":"Configuration File","level":"1.1.1.5","depth":3,"path":"nats_server/configuration.md","ref":"nats_server/configuration.md","articles":[]},{"title":"Signals","level":"1.1.1.6","depth":3,"path":"nats_server/signals.md","ref":"nats_server/signals.md","articles":[]},{"title":"Window Service","level":"1.1.1.7","depth":3,"path":"nats_server/windows_srv.md","ref":"nats_server/windows_srv.md","articles":[]}]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["prism","-highlight","include-html"],"pluginsConfig":{"prism":{},"include-html":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"nats_server/installation.md","mtime":"2019-05-13T14:43:31.021Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-05-15T15:16:11.909Z"},"basePath":"..","book":{"language":""}});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<!-- 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();
|
||||
});
|
||||
}
|
||||
|
||||
function pageChanged() {
|
||||
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>
|
||||
div.graphviz {
|
||||
background: transparent;
|
||||
border: 0;
|
||||
padding-top: 15px;
|
||||
padding-right: 15px;
|
||||
padding-bottom: 15px;
|
||||
padding-left: 15px;
|
||||
}
|
||||
|
||||
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: 10px 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>
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook.js"></script>
|
||||
<script src="../gitbook/theme.js"></script>
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism.css">
|
||||
|
||||
|
||||
|
||||
@ -47,6 +47,7 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
@ -63,9 +64,12 @@
|
||||
<link rel="prev" href="installation.html" />
|
||||
|
||||
|
||||
<link rel="stylesheet" href="https://cdn.materialdesignicons.com/3.6.95/css/materialdesignicons.min.css">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<div class="book">
|
||||
<div class="book-summary">
|
||||
|
||||
@ -154,6 +158,58 @@
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.4" data-path="flags.html">
|
||||
|
||||
<a href="flags.html">
|
||||
|
||||
|
||||
Flags
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.5" data-path="configuration.html">
|
||||
|
||||
<a href="configuration.html">
|
||||
|
||||
|
||||
Configuration File
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.6" data-path="signals.html">
|
||||
|
||||
<a href="signals.html">
|
||||
|
||||
|
||||
Signals
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.7" data-path="windows_srv.html">
|
||||
|
||||
<a href="windows_srv.html">
|
||||
|
||||
|
||||
Window Service
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
@ -166,6 +222,38 @@
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2" data-path="../developer/">
|
||||
|
||||
<a href="../developer/">
|
||||
|
||||
|
||||
Developing with NATS
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.2.1" data-path="../developer/connecting.html">
|
||||
|
||||
<a href="../developer/connecting.html">
|
||||
|
||||
|
||||
Connecting
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
|
||||
@ -217,7 +305,7 @@ In the absence of any flags, the NATS server will start listening for NATS clien
|
||||
By default, security is not enabled.</p>
|
||||
<h3 id="standalone">Standalone</h3>
|
||||
<p>When the server starts it will print some information including where the server is listening for client connections:</p>
|
||||
<pre><code>> nats-server
|
||||
<pre class="language-"><code>> nats-server
|
||||
[41634] 2019/05/13 09:42:11.745919 [INF] Starting nats-server version 2.0.0
|
||||
[41634] 2019/05/13 09:42:11.746240 [INF] Listening for client connections on 0.0.0.0:4222
|
||||
...
|
||||
@ -225,7 +313,7 @@ By default, security is not enabled.</p>
|
||||
[41634] 2019/05/13 09:42:11.746252 [INF] Server is ready
|
||||
</code></pre><h3 id="docker">Docker</h3>
|
||||
<p>If you are running your NATS server in a docker container:</p>
|
||||
<pre><code>> docker run -p 4222:4222 -ti nats-server:latest
|
||||
<pre class="language-"><code>> docker run -p 4222:4222 -ti nats-server:latest
|
||||
[1] 2019/05/13 14:55:11.981434 [INF] Starting nats-server version 2.0.0
|
||||
...
|
||||
[1] 2019/05/13 14:55:11.981545 [INF] Starting http monitor on 0.0.0.0:8222
|
||||
@ -276,11 +364,397 @@ By default, security is not enabled.</p>
|
||||
<script>
|
||||
var gitbook = gitbook || [];
|
||||
gitbook.push(function() {
|
||||
gitbook.page.hasChanged({"page":{"title":"Running","level":"1.1.1.2","depth":3,"next":{"title":"Clients","level":"1.1.1.3","depth":3,"path":"nats_server/clients.md","ref":"nats_server/clients.md","articles":[]},"previous":{"title":"Installing","level":"1.1.1.1","depth":3,"path":"nats_server/installation.md","ref":"nats_server/installation.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"nats_server/running.md","mtime":"2019-05-13T22:01:38.527Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-05-13T22:02:53.861Z"},"basePath":"..","book":{"language":""}});
|
||||
gitbook.page.hasChanged({"page":{"title":"Running","level":"1.1.1.2","depth":3,"next":{"title":"Clients","level":"1.1.1.3","depth":3,"path":"nats_server/clients.md","ref":"nats_server/clients.md","articles":[]},"previous":{"title":"Installing","level":"1.1.1.1","depth":3,"path":"nats_server/installation.md","ref":"nats_server/installation.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["prism","-highlight","include-html"],"pluginsConfig":{"prism":{},"include-html":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"nats_server/running.md","mtime":"2019-05-13T14:56:43.909Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-05-15T15:16:11.909Z"},"basePath":"..","book":{"language":""}});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<!-- 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();
|
||||
});
|
||||
}
|
||||
|
||||
function pageChanged() {
|
||||
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>
|
||||
div.graphviz {
|
||||
background: transparent;
|
||||
border: 0;
|
||||
padding-top: 15px;
|
||||
padding-right: 15px;
|
||||
padding-bottom: 15px;
|
||||
padding-left: 15px;
|
||||
}
|
||||
|
||||
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: 10px 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>
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook.js"></script>
|
||||
<script src="../gitbook/theme.js"></script>
|
||||
|
821
docs/nats_server/signals.html
Normal file
821
docs/nats_server/signals.html
Normal file
@ -0,0 +1,821 @@
|
||||
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="" >
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||||
<title>Signals · GitBook</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="description" content="">
|
||||
<meta name="generator" content="GitBook 3.2.3">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/style.css">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
|
||||
<link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
|
||||
|
||||
|
||||
<link rel="next" href="windows_srv.html" />
|
||||
|
||||
|
||||
<link rel="prev" href="configuration.html" />
|
||||
|
||||
|
||||
<link rel="stylesheet" href="https://cdn.materialdesignicons.com/3.6.95/css/materialdesignicons.min.css">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<div class="book">
|
||||
<div class="book-summary">
|
||||
|
||||
|
||||
<div id="book-search-input" role="search">
|
||||
<input type="text" placeholder="Type to search" />
|
||||
</div>
|
||||
|
||||
|
||||
<nav role="navigation">
|
||||
|
||||
|
||||
|
||||
<ul class="summary">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.1" data-path="../">
|
||||
|
||||
<a href="../">
|
||||
|
||||
|
||||
Introduction
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.1.1" data-path="./">
|
||||
|
||||
<a href="./">
|
||||
|
||||
|
||||
NATS Server
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.1.1.1" data-path="installation.html">
|
||||
|
||||
<a href="installation.html">
|
||||
|
||||
|
||||
Installing
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.2" data-path="running.html">
|
||||
|
||||
<a href="running.html">
|
||||
|
||||
|
||||
Running
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.3" data-path="clients.html">
|
||||
|
||||
<a href="clients.html">
|
||||
|
||||
|
||||
Clients
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.4" data-path="flags.html">
|
||||
|
||||
<a href="flags.html">
|
||||
|
||||
|
||||
Flags
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.5" data-path="configuration.html">
|
||||
|
||||
<a href="configuration.html">
|
||||
|
||||
|
||||
Configuration File
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter active" data-level="1.1.1.6" data-path="signals.html">
|
||||
|
||||
<a href="signals.html">
|
||||
|
||||
|
||||
Signals
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.7" data-path="windows_srv.html">
|
||||
|
||||
<a href="windows_srv.html">
|
||||
|
||||
|
||||
Window Service
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2" data-path="../developer/">
|
||||
|
||||
<a href="../developer/">
|
||||
|
||||
|
||||
Developing with NATS
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.2.1" data-path="../developer/connecting.html">
|
||||
|
||||
<a href="../developer/connecting.html">
|
||||
|
||||
|
||||
Connecting
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
|
||||
<li class="divider"></li>
|
||||
|
||||
<li>
|
||||
<a href="https://www.gitbook.com" target="blank" class="gitbook-link">
|
||||
Published with GitBook
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
</nav>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="book-body">
|
||||
|
||||
<div class="body-inner">
|
||||
|
||||
|
||||
|
||||
<div class="book-header" role="navigation">
|
||||
|
||||
|
||||
<!-- Title -->
|
||||
<h1>
|
||||
<i class="fa fa-circle-o-notch fa-spin"></i>
|
||||
<a href=".." >Signals</a>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="page-wrapper" tabindex="-1" role="main">
|
||||
<div class="page-inner">
|
||||
|
||||
<div id="book-search-results">
|
||||
<div class="search-noresults">
|
||||
|
||||
<section class="normal markdown-section">
|
||||
|
||||
<h2 id="process-signaling">Process Signaling</h2>
|
||||
<p>On Unix systems, the NATS server responds to the following signals:</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="text-align:left">Signal</th>
|
||||
<th style="text-align:left">Result</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="text-align:left">SIGKILL</td>
|
||||
<td style="text-align:left">Kills the process immediately</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:left">SIGINT</td>
|
||||
<td style="text-align:left">Stops the server gracefully</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:left">SIGUSR1</td>
|
||||
<td style="text-align:left">Reopens the log file for log rotation</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:left">SIGHUP</td>
|
||||
<td style="text-align:left">Reloads server configuration file</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:left">SIGUSR2</td>
|
||||
<td style="text-align:left">Stops the server after evicting all clients (lame duck mode)</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>The <code>nats-server</code> binary can be used to send these signals to running NATS servers using the <code>-sl</code> flag:</p>
|
||||
<pre class="language-"><code class="lang-sh"><span class="token comment"># Quit the server</span>
|
||||
nats-server -sl quit
|
||||
|
||||
<span class="token comment"># Stop the server</span>
|
||||
nats-server -sl stop
|
||||
|
||||
<span class="token comment"># Reopen log file for log rotation</span>
|
||||
nats-server -sl reopen
|
||||
|
||||
<span class="token comment"># Reload server configuration</span>
|
||||
nats-server -sl reload
|
||||
|
||||
<span class="token comment"># Lame duck mode server configuration</span>
|
||||
nats-server -sl ldm
|
||||
</code></pre>
|
||||
<p>If there are multiple <code>nats-server</code> processes running, or if <code>pgrep</code> isn't available, you must either specify a PID or the absolute path to a PID file:</p>
|
||||
<pre class="language-"><code class="lang-sh">nats-server -sl stop<span class="token operator">=</span><span class="token operator"><</span>pid<span class="token operator">></span>
|
||||
</code></pre>
|
||||
<pre class="language-"><code class="lang-sh">nats-server -sl stop<span class="token operator">=</span>/path/to/pidfile
|
||||
</code></pre>
|
||||
<p>See the <a href="windows_srv.html">Windows Service</a> section for information on signaling the NATS server on Windows.</p>
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<div class="search-results">
|
||||
<div class="has-results">
|
||||
|
||||
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
|
||||
<ul class="search-results-list"></ul>
|
||||
|
||||
</div>
|
||||
<div class="no-results">
|
||||
|
||||
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<a href="configuration.html" class="navigation navigation-prev " aria-label="Previous page: Configuration File">
|
||||
<i class="fa fa-angle-left"></i>
|
||||
</a>
|
||||
|
||||
|
||||
<a href="windows_srv.html" class="navigation navigation-next " aria-label="Next page: Window Service">
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var gitbook = gitbook || [];
|
||||
gitbook.push(function() {
|
||||
gitbook.page.hasChanged({"page":{"title":"Signals","level":"1.1.1.6","depth":3,"next":{"title":"Window Service","level":"1.1.1.7","depth":3,"path":"nats_server/windows_srv.md","ref":"nats_server/windows_srv.md","articles":[]},"previous":{"title":"Configuration File","level":"1.1.1.5","depth":3,"path":"nats_server/configuration.md","ref":"nats_server/configuration.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["prism","-highlight","include-html"],"pluginsConfig":{"prism":{},"include-html":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"nats_server/signals.md","mtime":"2019-05-13T16:14:12.238Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-05-15T15:16:11.909Z"},"basePath":"..","book":{"language":""}});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<!-- 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();
|
||||
});
|
||||
}
|
||||
|
||||
function pageChanged() {
|
||||
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>
|
||||
div.graphviz {
|
||||
background: transparent;
|
||||
border: 0;
|
||||
padding-top: 15px;
|
||||
padding-right: 15px;
|
||||
padding-bottom: 15px;
|
||||
padding-left: 15px;
|
||||
}
|
||||
|
||||
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: 10px 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>
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook.js"></script>
|
||||
<script src="../gitbook/theme.js"></script>
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
785
docs/nats_server/windows_srv.html
Normal file
785
docs/nats_server/windows_srv.html
Normal file
@ -0,0 +1,785 @@
|
||||
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="" >
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||||
<title>Window Service · GitBook</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="description" content="">
|
||||
<meta name="generator" content="GitBook 3.2.3">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/style.css">
|
||||
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
|
||||
|
||||
|
||||
|
||||
<link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<meta name="HandheldFriendly" content="true"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||||
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
|
||||
<link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
|
||||
|
||||
|
||||
<link rel="next" href="../developer/" />
|
||||
|
||||
|
||||
<link rel="prev" href="signals.html" />
|
||||
|
||||
|
||||
<link rel="stylesheet" href="https://cdn.materialdesignicons.com/3.6.95/css/materialdesignicons.min.css">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<div class="book">
|
||||
<div class="book-summary">
|
||||
|
||||
|
||||
<div id="book-search-input" role="search">
|
||||
<input type="text" placeholder="Type to search" />
|
||||
</div>
|
||||
|
||||
|
||||
<nav role="navigation">
|
||||
|
||||
|
||||
|
||||
<ul class="summary">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.1" data-path="../">
|
||||
|
||||
<a href="../">
|
||||
|
||||
|
||||
Introduction
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.1.1" data-path="./">
|
||||
|
||||
<a href="./">
|
||||
|
||||
|
||||
NATS Server
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.1.1.1" data-path="installation.html">
|
||||
|
||||
<a href="installation.html">
|
||||
|
||||
|
||||
Installing
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.2" data-path="running.html">
|
||||
|
||||
<a href="running.html">
|
||||
|
||||
|
||||
Running
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.3" data-path="clients.html">
|
||||
|
||||
<a href="clients.html">
|
||||
|
||||
|
||||
Clients
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.4" data-path="flags.html">
|
||||
|
||||
<a href="flags.html">
|
||||
|
||||
|
||||
Flags
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.5" data-path="configuration.html">
|
||||
|
||||
<a href="configuration.html">
|
||||
|
||||
|
||||
Configuration File
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.1.1.6" data-path="signals.html">
|
||||
|
||||
<a href="signals.html">
|
||||
|
||||
|
||||
Signals
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter active" data-level="1.1.1.7" data-path="windows_srv.html">
|
||||
|
||||
<a href="windows_srv.html">
|
||||
|
||||
|
||||
Window Service
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
<li class="chapter " data-level="1.2" data-path="../developer/">
|
||||
|
||||
<a href="../developer/">
|
||||
|
||||
|
||||
Developing with NATS
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
<ul class="articles">
|
||||
|
||||
|
||||
<li class="chapter " data-level="1.2.1" data-path="../developer/connecting.html">
|
||||
|
||||
<a href="../developer/connecting.html">
|
||||
|
||||
|
||||
Connecting
|
||||
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
|
||||
|
||||
|
||||
|
||||
<li class="divider"></li>
|
||||
|
||||
<li>
|
||||
<a href="https://www.gitbook.com" target="blank" class="gitbook-link">
|
||||
Published with GitBook
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
</nav>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="book-body">
|
||||
|
||||
<div class="body-inner">
|
||||
|
||||
|
||||
|
||||
<div class="book-header" role="navigation">
|
||||
|
||||
|
||||
<!-- Title -->
|
||||
<h1>
|
||||
<i class="fa fa-circle-o-notch fa-spin"></i>
|
||||
<a href=".." >Window Service</a>
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="page-wrapper" tabindex="-1" role="main">
|
||||
<div class="page-inner">
|
||||
|
||||
<div id="book-search-results">
|
||||
<div class="search-noresults">
|
||||
|
||||
<section class="normal markdown-section">
|
||||
|
||||
<h3 id="windows-service">Windows Service</h3>
|
||||
<p>The NATS server supports running as a Windows service. In fact, this is the recommended way of running NATS on Windows. There is currently no installer and instead users should use <code>sc.exe</code> to install the service:</p>
|
||||
<pre class="language-"><code class="lang-batch"><span class="token command"><span class="token keyword">sc</span>.exe create nats-server binPath= <span class="token string">"%NATS_PATH%\nats-server.exe [nats-server flags]"</span></span>
|
||||
<span class="token command"><span class="token keyword">sc</span>.exe start nats-server</span>
|
||||
</code></pre>
|
||||
<p>The above will create and start a <code>nats-server</code> service. Note that the nats-server flags should be passed in when creating the service. This allows for running multiple NATS server configurations on a single Windows server by using a 1:1 service instance per installed NATS server service. Once the service is running, it can be controlled using <code>sc.exe</code> or <code>nats-server.exe -sl</code>:</p>
|
||||
<pre class="language-"><code class="lang-batch"><span class="token comment">REM Reload server configuration</span>
|
||||
<span class="token command"><span class="token keyword">nats</span>-server.exe -sl reload</span>
|
||||
|
||||
<span class="token comment">REM Reopen log file for log rotation</span>
|
||||
<span class="token command"><span class="token keyword">nats</span>-server.exe -sl reopen</span>
|
||||
|
||||
<span class="token comment">REM Stop the server</span>
|
||||
<span class="token command"><span class="token keyword">nats</span>-server.exe -sl stop</span>
|
||||
</code></pre>
|
||||
<p>The above commands will default to controlling the <code>nats-server</code> service. If the service is another name, it can be specified:</p>
|
||||
<pre class="language-"><code class="lang-batch"><span class="token command"><span class="token keyword">nats</span>-server.exe -sl stop=<service name></span>
|
||||
</code></pre>
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<div class="search-results">
|
||||
<div class="has-results">
|
||||
|
||||
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
|
||||
<ul class="search-results-list"></ul>
|
||||
|
||||
</div>
|
||||
<div class="no-results">
|
||||
|
||||
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<a href="signals.html" class="navigation navigation-prev " aria-label="Previous page: Signals">
|
||||
<i class="fa fa-angle-left"></i>
|
||||
</a>
|
||||
|
||||
|
||||
<a href="../developer/" class="navigation navigation-next " aria-label="Next page: Developing with NATS">
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var gitbook = gitbook || [];
|
||||
gitbook.push(function() {
|
||||
gitbook.page.hasChanged({"page":{"title":"Window Service","level":"1.1.1.7","depth":3,"next":{"title":"Developing with NATS","level":"1.2","depth":1,"path":"developer/README.md","ref":"developer/README.md","articles":[{"title":"Connecting","level":"1.2.1","depth":2,"path":"developer/connecting.md","ref":"developer/connecting.md","articles":[]}]},"previous":{"title":"Signals","level":"1.1.1.6","depth":3,"path":"nats_server/signals.md","ref":"nats_server/signals.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["prism","-highlight","include-html"],"pluginsConfig":{"prism":{},"include-html":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"nats_server/windows_srv.md","mtime":"2019-05-13T16:13:54.780Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-05-15T15:16:11.909Z"},"basePath":"..","book":{"language":""}});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<!-- 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();
|
||||
});
|
||||
}
|
||||
|
||||
function pageChanged() {
|
||||
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>
|
||||
div.graphviz {
|
||||
background: transparent;
|
||||
border: 0;
|
||||
padding-top: 15px;
|
||||
padding-right: 15px;
|
||||
padding-bottom: 15px;
|
||||
padding-left: 15px;
|
||||
}
|
||||
|
||||
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: 10px 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>
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook.js"></script>
|
||||
<script src="../gitbook/theme.js"></script>
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-search/search.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
|
||||
|
||||
|
||||
|
||||
<script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
File diff suppressed because one or more lines are too long
42
docs/tools/examplecompiler/example_repos.json
Normal file
42
docs/tools/examplecompiler/example_repos.json
Normal file
@ -0,0 +1,42 @@
|
||||
[{
|
||||
"LanguageName": "java",
|
||||
"FormalName": "Java",
|
||||
"RepoURL": "https://github.com/nats-io/java-nats-examples.git",
|
||||
"Extensions": [".java", ".txt"],
|
||||
"SyntaxClass": "language-java"
|
||||
},
|
||||
{
|
||||
"LanguageName": "go",
|
||||
"FormalName": "Go",
|
||||
"RepoURL": "https://github.com/nats-io/go-nats-examples.git",
|
||||
"Extensions": [".go", ".txt"],
|
||||
"SyntaxClass": "language-go"
|
||||
},
|
||||
{
|
||||
"LanguageName": "ts",
|
||||
"FormalName": "TypeScript",
|
||||
"RepoURL": "https://github.com/nats-io/ts-nats-examples.git",
|
||||
"Extensions": [".ts", ".txt"],
|
||||
"SyntaxClass": "language-javascript"
|
||||
},
|
||||
{
|
||||
"LanguageName": "js",
|
||||
"FormalName": "JavaScript",
|
||||
"RepoURL": "https://github.com/nats-io/node-nats-examples.git",
|
||||
"Extensions": [".js", ".txt"],
|
||||
"SyntaxClass": "language-javascript"
|
||||
},
|
||||
{
|
||||
"LanguageName": "py",
|
||||
"FormalName": "Python",
|
||||
"RepoURL": "https://github.com/nats-io/asyncio-nats-examples.git",
|
||||
"Extensions": [".py", ".txt"],
|
||||
"SyntaxClass": "language-python"
|
||||
},
|
||||
{
|
||||
"LanguageName": "ruby",
|
||||
"FormalName": "Ruby",
|
||||
"RepoURL": "https://github.com/nats-io/ruby-nats-examples.git",
|
||||
"Extensions": [".rb", ".txt"],
|
||||
"SyntaxClass": "language-ruby"
|
||||
}]
|
17
docs/tools/examplecompiler/example_template.tmp
Normal file
17
docs/tools/examplecompiler/example_template.tmp
Normal file
@ -0,0 +1,17 @@
|
||||
{{$n := .Name}}
|
||||
<div class="tab-wrap">
|
||||
{{range .Languages}}
|
||||
{{if .First}}
|
||||
<input type="radio" id="{{$n}}_{{.Language}}" name="{{$n}}" class="tab" checked>
|
||||
{{else}}
|
||||
<input type="radio" id="{{$n}}_{{.Language}}" name="{{$n}}" class="tab">
|
||||
{{end}}
|
||||
<label for="{{$n}}_{{.Language}}" class="api-lang" data-language="{{.Language}}">{{.FormalName}}</label>
|
||||
{{end}}
|
||||
|
||||
{{range .Languages}}
|
||||
<div class="tab__content">
|
||||
<pre id="{{$n}}_{{.Language}}_content"><a class="toolbar-icons pull-right" target="_blank" href="{{.RepoURL}}"><i class="mdi mdi-github-circle" title="View on GitHub"></i></a><a class="toolbar-icons pull-right"><i class="mdi mdi-content-copy js-copy" title="Copy to Clipboard"></i></a><span class="copy-msg pull-right"></span><code class="{{.SyntaxClass}}">{{.Content}}</code></pre>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
287
docs/tools/examplecompiler/main.go
Normal file
287
docs/tools/examplecompiler/main.go
Normal file
@ -0,0 +1,287 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"bufio"
|
||||
"bytes"
|
||||
"flag"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
"unicode"
|
||||
)
|
||||
|
||||
type exampleRepo struct {
|
||||
LanguageName string
|
||||
FormalName string
|
||||
RepoURL string
|
||||
Extensions []string
|
||||
SyntaxClass string
|
||||
}
|
||||
|
||||
type languageExample struct {
|
||||
Language string
|
||||
FormalName string
|
||||
Content string
|
||||
RepoURL string
|
||||
SyntaxClass string
|
||||
First bool
|
||||
}
|
||||
|
||||
type languageList []languageExample
|
||||
|
||||
func (s languageList) Len() int {
|
||||
return len(s)
|
||||
}
|
||||
func (s languageList) Swap(i, j int) {
|
||||
s[i], s[j] = s[j], s[i]
|
||||
}
|
||||
func (s languageList) Less(i, j int) bool {
|
||||
return s[i].Language < s[j].Language
|
||||
}
|
||||
|
||||
type example struct {
|
||||
Name string
|
||||
Languages languageList
|
||||
}
|
||||
|
||||
func searchRepo(repoDirectory string, repo exampleRepo, examples map[string]*example) error {
|
||||
|
||||
extensions := make(map[string]string)
|
||||
for _, ext := range repo.Extensions {
|
||||
extensions[ext] = ext
|
||||
}
|
||||
|
||||
fmt.Printf("Searching for examples in: %q\n", repoDirectory)
|
||||
|
||||
err := filepath.Walk(repoDirectory, func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
fmt.Printf("prevent panic by handling failure accessing a path %q: %v\n", repoDirectory, err)
|
||||
return err
|
||||
}
|
||||
|
||||
ext := filepath.Ext(path)
|
||||
|
||||
if _, ok := extensions[ext]; ok {
|
||||
fmt.Printf("\tReading: %q\n", info.Name())
|
||||
file, err := os.Open(path)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
var buffer bytes.Buffer
|
||||
exampleName := ""
|
||||
beginExample, err := regexp.Compile(`\[begin ([^\s\[\]]+)\]`)
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
endExample, err := regexp.Compile(`\[end ([^\s\[\]]+)\]`)
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
scanner := bufio.NewScanner(file)
|
||||
lineNumber := 1
|
||||
beginLineNumber := lineNumber
|
||||
relativePath, err := filepath.Rel(repoDirectory, path)
|
||||
var indentRegex *regexp.Regexp
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
for scanner.Scan() {
|
||||
currentLine := scanner.Text()
|
||||
|
||||
if exampleName == "" {
|
||||
matches := beginExample.FindStringSubmatch(currentLine)
|
||||
|
||||
if len(matches) == 2 {
|
||||
exampleName = matches[1]
|
||||
beginLineNumber = lineNumber
|
||||
endExample, err = regexp.Compile(`\[end ` + exampleName + `\]`)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
} else if endExample.FindStringSubmatch(currentLine) != nil {
|
||||
fmt.Printf("\t\tFound %q example\n", exampleName)
|
||||
|
||||
if _, ok := examples[exampleName]; !ok {
|
||||
examples[exampleName] = &example{
|
||||
Name: exampleName,
|
||||
Languages: []languageExample{},
|
||||
}
|
||||
}
|
||||
|
||||
simpleRepoURL := strings.Replace(repo.RepoURL, ".git", "", -1)
|
||||
gitHubURL := fmt.Sprintf("%s/blob/master/%s#L%d-%d", simpleRepoURL, relativePath, beginLineNumber, lineNumber)
|
||||
example := examples[exampleName]
|
||||
langExample := languageExample{
|
||||
Language: repo.LanguageName,
|
||||
FormalName: repo.FormalName,
|
||||
SyntaxClass: repo.SyntaxClass,
|
||||
Content: buffer.String(),
|
||||
RepoURL: gitHubURL,
|
||||
}
|
||||
|
||||
example.Languages = append(example.Languages, langExample)
|
||||
|
||||
// fmt.Printf("\t\tRepo url: %s\n", langExample.RepoURL)
|
||||
|
||||
exampleName = "" // Look for another example in this file
|
||||
buffer.Reset()
|
||||
} else {
|
||||
// Calculate indent from first line
|
||||
// Blindly chop following lines (this could be smarter)
|
||||
if buffer.Len() == 0 {
|
||||
before := len(currentLine)
|
||||
currentLine = strings.TrimLeftFunc(currentLine, func(r rune) bool {
|
||||
return unicode.IsSpace(r)
|
||||
})
|
||||
after := len(currentLine)
|
||||
indent := before - after
|
||||
|
||||
if indent > 0 {
|
||||
indentRegexString := fmt.Sprintf("^\\s{0,%d}", indent)
|
||||
indentRegex, err = regexp.Compile(indentRegexString)
|
||||
}
|
||||
} else {
|
||||
if indentRegex != nil {
|
||||
currentLine = string(indentRegex.ReplaceAllString(currentLine, ""))
|
||||
}
|
||||
}
|
||||
buffer.WriteString(currentLine)
|
||||
buffer.WriteString("\n")
|
||||
}
|
||||
|
||||
lineNumber++
|
||||
}
|
||||
|
||||
if err := scanner.Err(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
fmt.Printf("error walking the path %q: %v\n", repoDirectory, err)
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func formatExamples(examples map[string]*example, exampleTemplate *template.Template, outputFolder string) {
|
||||
fmt.Printf("Formatting examples\n")
|
||||
|
||||
for _, example := range examples {
|
||||
if len(example.Languages) == 0 {
|
||||
fmt.Printf("\tSkipping empty example %q\n", example.Name)
|
||||
return
|
||||
}
|
||||
|
||||
sort.Sort(languageList(example.Languages))
|
||||
example.Languages[0].First = true
|
||||
|
||||
var buffer bytes.Buffer
|
||||
err := exampleTemplate.Execute(&buffer, example)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
htmlPath := filepath.Join(outputFolder, fmt.Sprintf("%s.html", example.Name))
|
||||
err = ioutil.WriteFile(htmlPath, buffer.Bytes(), 0666)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fmt.Printf("\tFormatted %q to %q\n", example.Name, htmlPath)
|
||||
}
|
||||
}
|
||||
|
||||
func usage() {
|
||||
log.Fatalf("Usage: examplecompiler -o <outputfolder> -t <template> -r <repo_list>\n")
|
||||
}
|
||||
|
||||
func main() {
|
||||
var outputFolder string
|
||||
var templateFile string
|
||||
var repoList string
|
||||
|
||||
flag.StringVar(&outputFolder, "o", "", "Output folder")
|
||||
flag.StringVar(&repoList, "r", "", "Repo list as a JSON file")
|
||||
flag.StringVar(&templateFile, "t", "", "Template file")
|
||||
|
||||
log.SetFlags(0)
|
||||
flag.Usage = usage
|
||||
flag.Parse()
|
||||
|
||||
if outputFolder == "" || templateFile == "" || repoList == "" {
|
||||
usage()
|
||||
}
|
||||
|
||||
templateData, err := ioutil.ReadFile(templateFile)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
exampleTemplateString := string(templateData)
|
||||
|
||||
exampleTemplate, err := template.New("example").Parse(exampleTemplateString)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// Create a tmp dir to do our work in
|
||||
dir, err := ioutil.TempDir("", "site_examples")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fmt.Printf("Working directory created: %q\n", dir)
|
||||
|
||||
allRepoDir := filepath.Join(dir, "repos")
|
||||
_ = os.Mkdir(allRepoDir, 0777)
|
||||
|
||||
fmt.Printf("Insuring output folder: %s\n", outputFolder)
|
||||
_ = os.Mkdir(outputFolder, 0777)
|
||||
|
||||
repoJSON, err := ioutil.ReadFile(repoList)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
repos := []exampleRepo{}
|
||||
err = json.Unmarshal(repoJSON, &repos)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
examples := make(map[string]*example)
|
||||
|
||||
for _, repo := range repos {
|
||||
_, repoName := filepath.Split(repo.RepoURL)
|
||||
repoName = repoName[0 : len(repoName)-len(".git")]
|
||||
|
||||
repoPath := filepath.Join(allRepoDir, repoName)
|
||||
|
||||
fmt.Printf("Downloading repo: %q\n", repo.RepoURL)
|
||||
cmd := exec.Command("git", "clone", repo.RepoURL, repoName)
|
||||
cmd.Dir = allRepoDir
|
||||
cmd.Run()
|
||||
|
||||
searchRepo(repoPath, repo, examples)
|
||||
}
|
||||
|
||||
formatExamples(examples, exampleTemplate, outputFolder)
|
||||
}
|
111
nats_server/authentication.md
Normal file
111
nats_server/authentication.md
Normal file
@ -0,0 +1,111 @@
|
||||
## NATS Server Authentication
|
||||
|
||||
You can enable authentication on the NATS server so that a client must authenticate its identity when connecting. The NATS server supports single user authentication via the command line or using a configuration file, and multi-user authentication via a configuration file. Single user authentication is truly single user. The server will accept one set of credentials and no other.
|
||||
|
||||
## Command Line Options
|
||||
|
||||
You can start the NATS server with single-user authentication enabled by passing in the required credentials on the command line. The following server authentication options are supported on the command line:
|
||||
|
||||
--user user User required for connections
|
||||
--pass password Password required for connections
|
||||
--auth token Authorization token required for connections
|
||||
|
||||
Token is mutually exclusive from user and password, so only use one of those.
|
||||
|
||||
For example:
|
||||
|
||||
```sh
|
||||
nats-server -DV --user foo --pass bar
|
||||
```
|
||||
|
||||
will allow the user `foo` to log in with the password `bar`, but no other users to access the server.
|
||||
|
||||
Using the command line with an authorization token:
|
||||
|
||||
```sh
|
||||
nats-server -DV -auth 'S3Cr3T0k3n!'
|
||||
```
|
||||
|
||||
will allow clients with that token to connect, and no others.
|
||||
|
||||
## Single User Configuration Options
|
||||
|
||||
Single-user authentication can be configured in the configuration file:
|
||||
|
||||
```ascii
|
||||
authorization {
|
||||
user: derek
|
||||
password: T0pS3cr3t
|
||||
timeout: 1
|
||||
}
|
||||
```
|
||||
|
||||
If the server is part of a cluster, you can set up single-user authentication for route connections as well:
|
||||
|
||||
```ascii
|
||||
cluster {
|
||||
authorization {
|
||||
user: route_user
|
||||
password: T0pS3cr3tT00!
|
||||
timeout: 0.5
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Both of these configurations set a user and password as well as a connect timeout. The `auth` option can also be set to use tokens *instead of* user/password.
|
||||
|
||||
## Multi-User Authentication
|
||||
|
||||
Multi-user Authentication can only be set up in the configuration file. Users are defined in a list with user/password pairs.
|
||||
|
||||
For example, to define two users `alice` and `bob`:
|
||||
|
||||
```ascii
|
||||
authorization {
|
||||
users = [
|
||||
{user: alice, password: foo}
|
||||
{user: bob, password: bar}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
You can also use [variables](/documentation/managing_the_server/configuration) to set user and password values. For example, here a password is declared as a variable named PASS and assigned to Joe.
|
||||
|
||||
```ascii
|
||||
authorization {
|
||||
PASS: abcdefghijklmnopqrstuvwxyz0123456789
|
||||
users = [
|
||||
{user: alice, password: foo}
|
||||
{user: bob, password: bar}
|
||||
{user: joe, password: $PASS}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
The nats-server source code includes a tool that can be used to bcrypt passwords for the config file:
|
||||
|
||||
```sh
|
||||
> go run mkpasswd.go -p
|
||||
> password: password
|
||||
> bcrypt hash: $2a$11$1oJy/wZYNTxr9jNwMNwS3eUGhBpHT3On8CL9o7ey89mpgo88VG6ba
|
||||
```
|
||||
|
||||
This allows you to store hashed passwords instead of plain text ones.
|
||||
|
||||
## Client connection string
|
||||
|
||||
To connect to the server as an authenticated client, you can pass in the credentials in the connection string.
|
||||
|
||||
For example, user 'foo' with password 'bar':
|
||||
|
||||
```sh
|
||||
nats://foo:bar@localhost:4222
|
||||
```
|
||||
|
||||
Using token 'S3Cr3T0k3n!'
|
||||
|
||||
```sh
|
||||
nats://S3Cr3T0k3n!@localhost:4222
|
||||
```
|
||||
|
||||
The server also supports TLS mutual authentication documented in the [Security/Encryption section](/documentation/managing_the_server/security). Other methods are also discussed in the [developer doc](/documentation/writing_applications/secure_connection).
|
58
nats_server/authorization.md
Normal file
58
nats_server/authorization.md
Normal file
@ -0,0 +1,58 @@
|
||||
## Authorization
|
||||
|
||||
The NATS server supports authorization using subject-level permissions on a per-user basis. Permission-based authorization is available with [multi-user authentication](/documentation/managing_the_server/authentication/).
|
||||
|
||||
Each permission grant is an object with two fields: what subject(s) the authenticated user can publish to, and what subject(s) the authenticated user can subscribe to. The parser is generous at understanding what the intent is, so both arrays and singletons are processed. Subjects themselves can contain wildcards. Permissions can make use of [variables](/documentation/managing_the_server/configuration).
|
||||
|
||||
You set permissions by creating an entry inside of the `authorization` configuration block that conforms to the following syntax:
|
||||
|
||||
```ascii
|
||||
authorization {
|
||||
PERMISSION_NAME = {
|
||||
publish = "singleton" or ["array", ...]
|
||||
subscribe = "singleton" or ["array", ...]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Important Note** NATS Authorizations are whitelist only, meaning in order to not break request/reply patterns you need to add rules as above with Alice and Bob for the `_INBOX.>` pattern. If an unauthorized client publishes or attempts to subscribe to a subject that has not been whitelisted, the action fails and is logged at the server, and an error message is returned to the client.
|
||||
|
||||
### Example
|
||||
|
||||
Here is an example authorization configuration that defines four users, three of whom are assigned explicit permissions.
|
||||
|
||||
```ascii
|
||||
authorization {
|
||||
ADMIN = {
|
||||
publish = ">"
|
||||
subscribe = ">"
|
||||
}
|
||||
REQUESTOR = {
|
||||
publish = ["req.foo", "req.bar"]
|
||||
subscribe = "_INBOX.>"
|
||||
}
|
||||
RESPONDER = {
|
||||
subscribe = ["req.foo", "req.bar"]
|
||||
publish = "_INBOX.>"
|
||||
}
|
||||
DEFAULT_PERMISSIONS = {
|
||||
publish = "SANDBOX.*"
|
||||
subscribe = ["PUBLIC.>", "_INBOX.>"]
|
||||
}
|
||||
PASS: abcdefghijklmnopqrstuvwxwz0123456789
|
||||
users = [
|
||||
{user: joe, password: foo, permissions: $ADMIN}
|
||||
{user: alice, password: bar, permissions: $REQUESTOR}
|
||||
{user: bob, password: $PASS, permissions: $RESPONDER}
|
||||
{user: charlie, password: bar}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Since Joe is an ADMIN he can publish/subscribe on any subject. We use the wildcard `>` to match any subject.
|
||||
|
||||
Alice is a REQUESTOR and can publish requests on subjects `req.foo` or `req.bar`, and subscribe to anything that is a response (`_INBOX.>`).
|
||||
|
||||
Charlie has no permissions granted and therefore inherits the default permission set. You set the inherited default permissions by assigning them to the default_permissions entry inside of the authorization configuration block.
|
||||
|
||||
Bob is a RESPONDER to any of Alice's requests, so Bob needs to be able to subscribe to the request subjects and respond to Alice's reply subject which will be an `_INBOX.>`.
|
@ -13,7 +13,7 @@ If you have a client library installed you can try using a bundled client. Other
|
||||
|
||||
### Or download a zip file
|
||||
|
||||
You can pre-built binaries from the [go-nats-examples repo](https://github.com/nats-io/go-nats-examples/releases/tag/0.0.50)
|
||||
You can install pre-built binaries from the [go-nats-examples repo](https://github.com/nats-io/go-nats-examples/releases/tag/0.0.50)
|
||||
|
||||
|
||||
### Testing your setup
|
||||
|
190
nats_server/clustering.md
Normal file
190
nats_server/clustering.md
Normal file
@ -0,0 +1,190 @@
|
||||
## NATS Server Clustering
|
||||
|
||||
|
||||
NATS supports running each server in clustered mode. You can cluster servers together for high volume messaging systems and resiliency and high availability. Clients are cluster-aware.
|
||||
|
||||
Note that NATS clustered servers have a forwarding limit of one hop. This means that each `nats-server` instance will **only** forward messages that it has received **from a client** to the immediately adjacent `nats-server` instances to which it has routes. Messages received **from** a route will only be distributed to local clients. Therefore a full mesh cluster, or complete graph, is recommended for NATS to function as intended and as described throughout the documentation.
|
||||
|
||||
## Cluster URLs
|
||||
|
||||
In addition to a port for listening for clients, `nats-server` can listen on a "cluster" URL (the `-cluster` option). Additional `nats-server` servers can then add that URL to their `-routes` argument to join the cluster. These options can also be specified in a config file, but only the command-line version is shown in this overview for simplicity.
|
||||
|
||||
### Running with No Cluster
|
||||
|
||||
```sh
|
||||
nats-server -p 4222
|
||||
```
|
||||
----
|
||||
|
||||
### Running a Simple Cluster
|
||||
|
||||
```sh
|
||||
# Server A on 10.10.0.1
|
||||
nats-server -p 4222 -cluster nats://10.10.0.1:5222
|
||||
|
||||
# Server B on 10.10.0.2
|
||||
nats-server -p 4222 -cluster nats://10.10.0.2:5222 -routes nats://10.10.0.1:5222
|
||||
```
|
||||
|
||||
----
|
||||
|
||||
```sh
|
||||
# Server A on 10.10.0.1
|
||||
nats-server -p 4222 -cluster nats://10.10.0.1:5222 -routes nats://10.10.0.2:5222
|
||||
|
||||
# Server B on 10.10.0.2
|
||||
nats-server -p 4222 -cluster nats://10.10.0.2:5222 -routes nats://10.10.0.1:5222
|
||||
```
|
||||
|
||||
Clients connecting to any server in the cluster will remain connected to the cluster even if the server it originally connected to is taken down, as long as at least a single server remains.
|
||||
|
||||
## Command Line Options
|
||||
|
||||
The following cluster options are supported:
|
||||
|
||||
--routes [rurl-1, rurl-2] Routes to solicit and connect
|
||||
--cluster nats://host:port Cluster URL for solicited routes
|
||||
|
||||
When a NATS server routes to a specified URL, it will advertise its own cluster URL to all other servers in the route route effectively creating a routing mesh to all other servers.
|
||||
|
||||
**Note:** when using the `-routes` option, you must also specify a `-cluster` option.
|
||||
|
||||
Clustering can also be configured using the server [config file](/documentation/managing_the_server/configuration).
|
||||
|
||||
## Three Server Cluster Example
|
||||
|
||||
The following example demonstrates how to run a cluster of 3 servers on the same host. We will start with the seed server and use the `-D` command line parameter to produce debug information.
|
||||
|
||||
```sh
|
||||
nats-server -p 4222 -cluster nats://localhost:4248 -D
|
||||
```
|
||||
|
||||
Alternatively, you could use a configuration file, let's call it `seed.conf`, with a content similar to this:
|
||||
|
||||
```ascii
|
||||
# Cluster Seed Node
|
||||
|
||||
listen: 127.0.0.1:4222
|
||||
http: 8222
|
||||
|
||||
cluster {
|
||||
listen: 127.0.0.1:4248
|
||||
}
|
||||
```
|
||||
|
||||
And start the server like this:
|
||||
|
||||
```sh
|
||||
nats-server -config ./seed.conf -D
|
||||
```
|
||||
|
||||
This will produce an output similar to:
|
||||
|
||||
```sh
|
||||
[75653] 2016/04/26 15:14:47.339321 [INF] Listening for route connections on 127.0.0.1:4248
|
||||
[75653] 2016/04/26 15:14:47.340787 [INF] Listening for client connections on 127.0.0.1:4222
|
||||
[75653] 2016/04/26 15:14:47.340822 [DBG] server id is xZfu3u7usAPWkuThomoGzM
|
||||
[75653] 2016/04/26 15:14:47.340825 [INF] server is ready
|
||||
```
|
||||
|
||||
It is also possible to specify the hostname and port independently. At least the port is required. If you leave the hostname off it will bind to all the interfaces ('0.0.0.0').
|
||||
|
||||
```ascii
|
||||
cluster {
|
||||
host: 127.0.0.1
|
||||
port: 4248
|
||||
}
|
||||
```
|
||||
|
||||
Now let's start two more servers, each one connecting to the seed server.
|
||||
|
||||
```sh
|
||||
nats-server -p 5222 -cluster nats://localhost:5248 -routes nats://localhost:4248 -D
|
||||
```
|
||||
|
||||
When running on the same host, we need to pick different ports for the client connections `-p`, and for the port used to accept other routes `-cluster`. Note that `-routes` points to the `-cluster` address of the seed server (`localhost:4248`).
|
||||
|
||||
Here is the log produced. See how it connects and registers a route to the seed server (`...GzM`).
|
||||
|
||||
```sh
|
||||
[75665] 2016/04/26 15:14:59.970014 [INF] Listening for route connections on localhost:5248
|
||||
[75665] 2016/04/26 15:14:59.971150 [INF] Listening for client connections on 0.0.0.0:5222
|
||||
[75665] 2016/04/26 15:14:59.971176 [DBG] server id is 53Yi78q96t52QdyyWLKIyE
|
||||
[75665] 2016/04/26 15:14:59.971179 [INF] server is ready
|
||||
[75665] 2016/04/26 15:14:59.971199 [DBG] Trying to connect to route on localhost:4248
|
||||
[75665] 2016/04/26 15:14:59.971551 [DBG] 127.0.0.1:4248 - rid:1 - Route connection created
|
||||
[75665] 2016/04/26 15:14:59.971559 [DBG] 127.0.0.1:4248 - rid:1 - Route connect msg sent
|
||||
[75665] 2016/04/26 15:14:59.971720 [DBG] 127.0.0.1:4248 - rid:1 - Registering remote route "xZfu3u7usAPWkuThomoGzM"
|
||||
[75665] 2016/04/26 15:14:59.971731 [DBG] 127.0.0.1:4248 - rid:1 - Route sent local subscriptions
|
||||
```
|
||||
|
||||
From the seed's server log, we see that the route is indeed accepted:
|
||||
|
||||
```sh
|
||||
[75653] 2016/04/26 15:14:59.971602 [DBG] 127.0.0.1:52679 - rid:1 - Route connection created
|
||||
[75653] 2016/04/26 15:14:59.971733 [DBG] 127.0.0.1:52679 - rid:1 - Registering remote route "53Yi78q96t52QdyyWLKIyE"
|
||||
[75653] 2016/04/26 15:14:59.971739 [DBG] 127.0.0.1:52679 - rid:1 - Route sent local subscriptions
|
||||
```
|
||||
|
||||
Finally, let's start the third server:
|
||||
|
||||
```sh
|
||||
nats-server -p 6222 -cluster nats://localhost:6248 -routes nats://localhost:4248 -D
|
||||
```
|
||||
|
||||
Again, notice that we use a different client port and cluster address, but still point to the same seed server at the address `nats://localhost:4248`:
|
||||
|
||||
```sh
|
||||
[75764] 2016/04/26 15:19:11.528185 [INF] Listening for route connections on localhost:6248
|
||||
[75764] 2016/04/26 15:19:11.529787 [INF] Listening for client connections on 0.0.0.0:6222
|
||||
[75764] 2016/04/26 15:19:11.529829 [DBG] server id is IRepas80TBwJByULX1ulAp
|
||||
[75764] 2016/04/26 15:19:11.529842 [INF] server is ready
|
||||
[75764] 2016/04/26 15:19:11.529872 [DBG] Trying to connect to route on localhost:4248
|
||||
[75764] 2016/04/26 15:19:11.530272 [DBG] 127.0.0.1:4248 - rid:1 - Route connection created
|
||||
[75764] 2016/04/26 15:19:11.530281 [DBG] 127.0.0.1:4248 - rid:1 - Route connect msg sent
|
||||
[75764] 2016/04/26 15:19:11.530408 [DBG] 127.0.0.1:4248 - rid:1 - Registering remote route "xZfu3u7usAPWkuThomoGzM"
|
||||
[75764] 2016/04/26 15:19:11.530414 [DBG] 127.0.0.1:4248 - rid:1 - Route sent local subscriptions
|
||||
[75764] 2016/04/26 15:19:11.530595 [DBG] 127.0.0.1:52727 - rid:2 - Route connection created
|
||||
[75764] 2016/04/26 15:19:11.530659 [DBG] 127.0.0.1:52727 - rid:2 - Registering remote route "53Yi78q96t52QdyyWLKIyE"
|
||||
[75764] 2016/04/26 15:19:11.530664 [DBG] 127.0.0.1:52727 - rid:2 - Route sent local subscriptions
|
||||
```
|
||||
|
||||
First a route is created to the seed server (`...GzM`) and after that, a route from `...IyE` - which is the ID of the second server - is accepted.
|
||||
|
||||
The log from the seed server shows that it accepted the route from the third server:
|
||||
|
||||
```sh
|
||||
[75653] 2016/04/26 15:19:11.530308 [DBG] 127.0.0.1:52726 - rid:2 - Route connection created
|
||||
[75653] 2016/04/26 15:19:11.530384 [DBG] 127.0.0.1:52726 - rid:2 - Registering remote route "IRepas80TBwJByULX1ulAp"
|
||||
[75653] 2016/04/26 15:19:11.530389 [DBG] 127.0.0.1:52726 - rid:2 - Route sent local subscriptions
|
||||
```
|
||||
|
||||
And the log from the second server shows that it connected to the third.
|
||||
|
||||
```sh
|
||||
[75665] 2016/04/26 15:19:11.530469 [DBG] Trying to connect to route on 127.0.0.1:6248
|
||||
[75665] 2016/04/26 15:19:11.530565 [DBG] 127.0.0.1:6248 - rid:2 - Route connection created
|
||||
[75665] 2016/04/26 15:19:11.530570 [DBG] 127.0.0.1:6248 - rid:2 - Route connect msg sent
|
||||
[75665] 2016/04/26 15:19:11.530644 [DBG] 127.0.0.1:6248 - rid:2 - Registering remote route "IRepas80TBwJByULX1ulAp"
|
||||
[75665] 2016/04/26 15:19:11.530650 [DBG] 127.0.0.1:6248 - rid:2 - Route sent local subscriptions
|
||||
```
|
||||
|
||||
At this point, there is a full mesh cluster of NATS servers.
|
||||
|
||||
### Testing the Cluster
|
||||
|
||||
Now, the following should work: make a subscription to Node A then publish to Node C. You should be able to to receive the message without problems.
|
||||
|
||||
```sh
|
||||
nats-sub -s "nats://192.168.59.103:7222" hello &
|
||||
|
||||
nats-pub -s "nats://192.168.59.105:7222" hello world
|
||||
|
||||
[#1] Received on [hello] : 'world'
|
||||
|
||||
# GNATSD on Node C logs:
|
||||
[1] 2015/06/23 05:20:31.100032 [TRC] 192.168.59.103:7244 - rid:2 - <<- [MSG hello RSID:8:2 5]
|
||||
|
||||
# GNATSD on Node A logs:
|
||||
[1] 2015/06/23 05:20:31.100600 [TRC] 10.0.2.2:51007 - cid:8 - <<- [MSG hello 2 5]
|
||||
```
|
@ -4,8 +4,8 @@ The NATS server products provide a flexible configuration format that combines t
|
||||
|
||||
The config file supports the following syntax:
|
||||
|
||||
- Lines or options can be commented with `#` and `//`
|
||||
- Value assignment can use:
|
||||
- Lines can be commented with `#` and `//`
|
||||
- Values can be assigned to properties with:
|
||||
- Equals sign: `foo = 2`
|
||||
- Colon: `foo: 2`
|
||||
- Whitespace: `foo 2`
|
||||
@ -21,7 +21,7 @@ Server configurations can specify variables. Variables allow you to reference a
|
||||
Variables:
|
||||
- Are block scoped
|
||||
- Are referenced with a `$` prefix.
|
||||
- Can be resolved from the environment
|
||||
- Can be resolved from the environment variables having the same name
|
||||
|
||||
> If the environment variable value begins with a number you may have trouble resolving it depending on the server version you are running.
|
||||
|
||||
@ -39,6 +39,7 @@ authorization {
|
||||
A similar configuration, but this time, the value is in the environment:
|
||||
|
||||
```
|
||||
# TOKEN should be defined in the environment
|
||||
authorization {
|
||||
token: $TOKEN
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ The configuration flags revolve around:
|
||||
|
||||
| Flag | Description |
|
||||
| :-------------------- | :-------- |
|
||||
| `-a`, `--addr` | Host address to bind to (default: 0.0.0.0) - all interfaces. |
|
||||
| `-a`, `--addr` | Host address to bind to (default: `0.0.0.0` - all interfaces). |
|
||||
| `-p`, `--port` | NATS client port (default: 4222). |
|
||||
| `-P`, `--pid` | File to store the process ID (PID). |
|
||||
| `-m`, `--http_port` | HTTP port for monitoring dashboard (exclusive of `--https_port`). |
|
||||
@ -29,7 +29,23 @@ The configuration flags revolve around:
|
||||
|
||||
|
||||
|
||||
### Authentication Options
|
||||
|
||||
The following options control very simple authentication:
|
||||
|
||||
| Flag | Description |
|
||||
| :-------------------- | :-------- |
|
||||
| `--user` | Required _username_ for connections. |
|
||||
| `--pass` | Required _password_ for connections. |
|
||||
| `--auth` | Required _authorization token_ for connections. |
|
||||
|
||||
You can read more about [autentication configuration here](authentication.md).
|
||||
|
||||
|
||||
### Logging Options
|
||||
|
||||
The following flags are available on the server to configure logging:
|
||||
|
||||
| Flag | Description |
|
||||
| :-------------------- | :-------- |
|
||||
| `-l`, `--log` | File to redirect log output |
|
||||
@ -40,14 +56,7 @@ The configuration flags revolve around:
|
||||
| `-V`, `--trace` | Enable protocol trace log messages |
|
||||
| `-DV` | Enable both debug and protocol trace messages |
|
||||
|
||||
|
||||
### Authorization Options
|
||||
|
||||
| Flag | Description |
|
||||
| :-------------------- | :-------- |
|
||||
| `--user` | Required _username_ for connections. |
|
||||
| `--pass` | Required _password_ for connections. |
|
||||
| `--auth` | Required _authorization token_ for connections. |
|
||||
You can read more about [logging configuration here](logging.md).
|
||||
|
||||
|
||||
### TLS Options
|
||||
@ -63,6 +72,9 @@ The configuration flags revolve around:
|
||||
|
||||
### Cluster Options
|
||||
|
||||
The following flags are available on the server to configure clustering:
|
||||
|
||||
|
||||
| Flag | Description |
|
||||
| :-------------------- | :-------- |
|
||||
| `--routes` | Comma separated list of cluster URLs to solicit and connect |
|
||||
@ -71,6 +83,9 @@ The configuration flags revolve around:
|
||||
| `--cluster_advertise` | Cluster URL to advertise to other servers |
|
||||
| `--connect_retries` | For implicit routes, number of connect retries |
|
||||
|
||||
You can read more about [clustering configuration here](clustering.md).
|
||||
|
||||
|
||||
### Common Options
|
||||
|
||||
| Flag | Description |
|
||||
|
@ -19,7 +19,7 @@ Via Docker:
|
||||
> docker pull nats-server:latest
|
||||
```
|
||||
|
||||
### Installing directly Release Build
|
||||
### Installing A Release Build
|
||||
|
||||
You can find the latest release of nats-server [here](https://github.com/nats-io/nats-server/releases/latest).
|
||||
|
||||
@ -41,13 +41,13 @@ Archive: nats-server.zip
|
||||
|
||||
### Installing from the source
|
||||
|
||||
If you have go installed, installing the binary is very easy:
|
||||
If you have go installed, installing the binary is easy:
|
||||
|
||||
```
|
||||
> go get github.com/nats-io/nats-server
|
||||
```
|
||||
|
||||
This mechanism will always install the latest build on [master](https://github.com/nats-io/nats-server), which almost certainly will not be a released version. If you are a developer and want to play with the the latest, this is the easiest way of obtaining it.
|
||||
This mechanism will install a build of [master](https://github.com/nats-io/nats-server), which almost certainly will not be a released version. If you are a developer and want to play with the the latest, this is the easiest way of obtaining it.
|
||||
|
||||
|
||||
## Testing Your Installation
|
||||
|
96
nats_server/logging.md
Normal file
96
nats_server/logging.md
Normal file
@ -0,0 +1,96 @@
|
||||
|
||||
## Configuring Logging
|
||||
The NATS server provides various logging options that you can set via the command line or the configuration file.
|
||||
|
||||
|
||||
### Command Line Options
|
||||
|
||||
The following logging operations are supported:
|
||||
|
||||
-l, --log FILE File to redirect log output.
|
||||
-T, --logtime Timestamp log entries (default is true).
|
||||
-s, --syslog Enable syslog as log method.
|
||||
-r, --remote_syslog Syslog server address.
|
||||
-D, --debug Enable debugging output.
|
||||
-V, --trace Trace the raw protocol.
|
||||
-DV Debug and Trace.
|
||||
|
||||
#### Debug and trace
|
||||
|
||||
The `-DV` flag enables trace and debug for the server.
|
||||
|
||||
```sh
|
||||
nats-server -DV -m 8222 -user foo -pass bar
|
||||
```
|
||||
|
||||
#### Log file redirect
|
||||
|
||||
```sh
|
||||
nats-server -DV -m 8222 -l nats.log
|
||||
```
|
||||
|
||||
#### Timestamp
|
||||
|
||||
If `-T false` then log entries are not timestamped. Default is true.
|
||||
|
||||
#### Syslog
|
||||
|
||||
You can configure syslog with `UDP`:
|
||||
|
||||
```sh
|
||||
nats-server -s udp://localhost:514
|
||||
```
|
||||
|
||||
or `syslog:`
|
||||
|
||||
```sh
|
||||
nats-server -r syslog://<hostname>:<port>
|
||||
```
|
||||
|
||||
For example:
|
||||
|
||||
```sh
|
||||
syslog://logs.papertrailapp.com:26900
|
||||
```
|
||||
|
||||
### Using the Configuration File
|
||||
|
||||
All of these settings are available in the configuration file as well.
|
||||
|
||||
```ascii
|
||||
debug: false
|
||||
trace: true
|
||||
logtime: false
|
||||
log_file: "/tmp/nats-server.log"
|
||||
```
|
||||
|
||||
## Log Rotation with logrotate
|
||||
|
||||
NATS server does not provide tools to manage log files, but it does include mechanisms that make log rotation simple. We can use this mechanism with [logrotate](https://github.com/logrotate/logrotate); a simple standard Linux utility to rotate logs available on most distributions like Debian, Ubuntu, RedHat (CentOS), etc.
|
||||
|
||||
For example, you could configure `logrotate` with:
|
||||
|
||||
```ascii
|
||||
/path/to/nats-server.log {
|
||||
daily
|
||||
rotate 30
|
||||
compress
|
||||
missingok
|
||||
notifempty
|
||||
postrotate
|
||||
kill -SIGUSR1 `cat /var/run/nats-server.pid`
|
||||
endscript
|
||||
}
|
||||
```
|
||||
|
||||
The first line specifies the location that the subsequent lines will apply to.
|
||||
|
||||
The rest of the file specifies that the logs will rotate daily ("daily" option) and that 30 older copies will be preserved ("rotate" option). Other options are described in [logrorate documentation](https://linux.die.net/man/8/logrotate).
|
||||
|
||||
The "postrotate" section tells NATS server to reload the log files once the rotation is complete. The command ```kill -SIGUSR1 `cat /var/run/nats-server.pid` ``` does not kill the NATS server process, but instead sends it a signal causing it to reload its log files. This will cause new requests to be logged to the refreshed log file.
|
||||
|
||||
The `/var/run/nats-server.pid` file is where NATS server stores the master process's pid.
|
||||
|
||||
## Some Logging Notes
|
||||
|
||||
- The NATS Server, in verbose mode, will log the receipt of `UNSUB` messages, but this does not indicate the subscription is gone, only that the message was received. The `DELSUB` message in the log can be used to determine when the actual subscription removal has taken place.
|
182
nats_server/monitoring.md
Normal file
182
nats_server/monitoring.md
Normal file
@ -0,0 +1,182 @@
|
||||
## Monitoring
|
||||
|
||||
To monitor the NATS messaging system, `gnatsd` provides a lightweight HTTP server on a dedicated monitoring port. The monitoring server provides several endpoints, including [varz](#/varz), [connz](#/connz), [routez](#/routez), and [subsz](#/subz). All endpoints return a JSON object.
|
||||
|
||||
The NATS monitoring endpoints support JSONP and CORS, making it easy to create single page monitoring web applications.
|
||||
|
||||
## Enabling monitoring
|
||||
|
||||
To enable the monitoring server, start the NATS server with the monitoring flag `-m` and the monitoring port, or turn it on in the [configuration file](/documentation/managing_the_server/configuration).
|
||||
|
||||
-m, --http_port PORT HTTP PORT for monitoring
|
||||
-ms,--https_port PORT Use HTTPS PORT for monitoring
|
||||
|
||||
Example:
|
||||
|
||||
```sh
|
||||
$ gnatsd -m 8222
|
||||
[4528] 2015/08/19 20:09:58.572939 [INF] Starting gnatsd version 0.8.0
|
||||
[4528] 2015/08/19 20:09:58.573007 [INF] Starting http monitor on port 8222
|
||||
[4528] 2015/08/19 20:09:58.573071 [INF] Listening for client connections on 0.0.0.0:4222
|
||||
[4528] 2015/08/19 20:09:58.573090 [INF] gnatsd is ready</td>
|
||||
```
|
||||
|
||||
To test, run `gnatsd -m 8222`, then go to <a href="http://localhost:8222/" target="_blank">http://localhost:8222/</a>
|
||||
|
||||
## Monitoring endpoints
|
||||
|
||||
The following sections describe each supported monitoring endpoint: `varz`, `connz`, `routez`, and `subsz`.
|
||||
|
||||
### /varz
|
||||
|
||||
The endpoint <a href="http://localhost:8222/varz" target="_blank">http://localhost:8222/varz</a> reports various general statistics.
|
||||
|
||||
```json
|
||||
{
|
||||
"server_id": "ec933edcd2bd86bcf71d555fc8b4fb2c",
|
||||
"version": "0.6.6",
|
||||
"go": "go1.5.0",
|
||||
"host": "0.0.0.0",
|
||||
"port": 4222,
|
||||
"auth_required": false,
|
||||
"ssl_required": false,
|
||||
"max_payload": 1048576,
|
||||
"max_connections": 65536,
|
||||
"ping_interval": 120000000000,
|
||||
"ping_max": 2,
|
||||
"http_port": 8222,
|
||||
"ssl_timeout": 0.5,
|
||||
"max_control_line": 1024,
|
||||
"start": "2015-07-14T13:29:26.426805508-07:00",
|
||||
"now": "2015-07-14T13:30:59.349179963-07:00",
|
||||
"uptime": "1m33s",
|
||||
"mem": 8445952,
|
||||
"cores": 4,
|
||||
"cpu": 0,
|
||||
"connections": 39,
|
||||
"routes": 0,
|
||||
"remotes": 0,
|
||||
"in_msgs": 100000,
|
||||
"out_msgs": 100000,
|
||||
"in_bytes": 1600000,
|
||||
"out_bytes": 1600000,
|
||||
"slow_consumers": 0
|
||||
}
|
||||
```
|
||||
|
||||
### /connz
|
||||
|
||||
The endpoint <a href="http://localhost:8222/connz" target="_blank">http://localhost:8222/connz</a> reports more detailed information on current connections. It uses a paging mechanism which defaults to 1024 connections.
|
||||
|
||||
You can control these via URL arguments (limit and offset). For example: <a href="http://localhost:8222/connz?limit=1&offset=1" target="_blank">http://localhost:8222/connz?limit=1&offset=1</a>.
|
||||
|
||||
You can also report detailed subscription information on a per connection basis using subs=1. For example: <a href="http://localhost:8222/connz?limit=1&offset=1&subs=1" target="_blank">http://localhost:8222/connz?limit=1&offset=1&subs=1</a>.
|
||||
|
||||
```json
|
||||
{
|
||||
"now": "2015-07-14T13:30:59.349179963-07:00",
|
||||
"num_connections": 2,
|
||||
"offset": 0,
|
||||
"limit": 1024,
|
||||
"connections": [
|
||||
{
|
||||
"cid": 571,
|
||||
"ip": "127.0.0.1",
|
||||
"port": 61572,
|
||||
"pending_size": 0,
|
||||
"in_msgs": 0,
|
||||
"out_msgs": 0,
|
||||
"in_bytes": 0,
|
||||
"out_bytes": 0,
|
||||
"subscriptions": 1,
|
||||
"lang": "go",
|
||||
"version": "1.0.9",
|
||||
"subscriptions_list": [
|
||||
"hello.world"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cid": 574,
|
||||
"ip": "127.0.0.1",
|
||||
"port": 61577,
|
||||
"pending_size": 0,
|
||||
"in_msgs": 0,
|
||||
"out_msgs": 0,
|
||||
"in_bytes": 0,
|
||||
"out_bytes": 0,
|
||||
"subscriptions": 1,
|
||||
"lang": "ruby",
|
||||
"version": "0.5.0",
|
||||
"subscriptions_list": [
|
||||
"hello.world"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### /routez
|
||||
|
||||
The endpoint <a href="http://localhost:8222/routez" target="_blank">http://localhost:8222/routez</a> reports information on active routes for a cluster. Routes are expected to be low, so there is no paging mechanism with this endpoint.
|
||||
|
||||
The `routez` endpoint does support the `subs` argument from the `/connz` endpoint. For example: <a href="http://localhost:8222/routez?subs=1" target="_blank">http://localhost:8222/routez?subs=1</a>
|
||||
|
||||
```json
|
||||
{
|
||||
"now": "2015-07-14T13:30:59.349179963-07:00",
|
||||
"num_routes": 1,
|
||||
"routes": [
|
||||
{
|
||||
"rid": 1,
|
||||
"remote_id": "de475c0041418afc799bccf0fdd61b47",
|
||||
"did_solicit": true,
|
||||
"ip": "127.0.0.1",
|
||||
"port": 61791,
|
||||
"pending_size": 0,
|
||||
"in_msgs": 0,
|
||||
"out_msgs": 0,
|
||||
"in_bytes": 0,
|
||||
"out_bytes": 0,
|
||||
"subscriptions": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### /subsz
|
||||
|
||||
The endpoint <a href="http://localhost:8222/subz" target="_blank">http://localhost:8222/subz</a> reports detailed information about the current subscriptions and the routing data structure.
|
||||
|
||||
```json
|
||||
{
|
||||
"num_subscriptions": 3,
|
||||
"num_cache": 0,
|
||||
"num_inserts": 572,
|
||||
"num_removes": 569,
|
||||
"num_matches": 200000,
|
||||
"cache_hit_rate": 0.99999,
|
||||
"max_fanout": 0,
|
||||
"avg_fanout": 0,
|
||||
"stats_time": "2015-07-14T12:55:25.564818051-07:00"
|
||||
}
|
||||
```
|
||||
|
||||
## Creating monitoring applications
|
||||
|
||||
NATS monitoring endpoints support [JSONP](https://en.wikipedia.org/wiki/JSONP) and [CORS](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing#How_CORS_works). You can easily create single page web applications for monitoring. To do this you simply pass the `callback` query parameter to any endpoint.
|
||||
|
||||
For example:
|
||||
|
||||
```sh
|
||||
http://localhost:8222/connz?callback=cb
|
||||
```
|
||||
|
||||
Here is a JQuery example implementation:
|
||||
|
||||
```javascript
|
||||
$.getJSON('http://localhost:8222/connz?callback=?', function(data) {
|
||||
console.log(data);
|
||||
});
|
||||
|
||||
```
|
||||
|
137
nats_server/nats_top_tutorial.md
Normal file
137
nats_server/nats_top_tutorial.md
Normal file
@ -0,0 +1,137 @@
|
||||
## NATS TOP Tutorial
|
||||
|
||||
You can use [nats-top](natstop.md) to monitor in realtime NATS server connections and message statistics.
|
||||
|
||||
#### Prerequisites
|
||||
|
||||
- [Set up your Go environment](/documentation/additional_documentation/go-install/)
|
||||
- [Installed the NATS server](/documentation/managing_the_server/installing/)
|
||||
|
||||
#### 1. Install nats-top
|
||||
|
||||
```sh
|
||||
% go get github.com/nats-io/nats-top
|
||||
```
|
||||
|
||||
You may need to run the following instead:
|
||||
|
||||
```sh
|
||||
% sudo -E go get github.com/nats-io/nats-top
|
||||
```
|
||||
|
||||
#### 2. Start the NATS server with monitoring enabled
|
||||
|
||||
```sh
|
||||
% nats-server -m 8222
|
||||
```
|
||||
|
||||
#### 3. Start nats-top
|
||||
|
||||
```sh
|
||||
% nats-top
|
||||
```
|
||||
|
||||
Result:
|
||||
|
||||
```sh
|
||||
nats-server version 0.6.6 (uptime: 2m2s)
|
||||
Server:
|
||||
Load: CPU: 0.0% Memory: 6.3M Slow Consumers: 0
|
||||
In: Msgs: 0 Bytes: 0 Msgs/Sec: 0.0 Bytes/Sec: 0
|
||||
Out: Msgs: 0 Bytes: 0 Msgs/Sec: 0.0 Bytes/Sec: 0
|
||||
|
||||
Connections: 0
|
||||
HOST CID SUBS PENDING MSGS_TO MSGS_FROM BYTES_TO BYTES_FROM LANG VERSION
|
||||
```
|
||||
|
||||
#### 4. Run NATS client programs
|
||||
|
||||
Run some NATS client programs and exchange messages.
|
||||
|
||||
For the best experience, you will want to run multiple subscribers, at least 2 or 3. Refer to the [example pub-sub clients](/documentation/additional_documentation/nats-pub-sub).
|
||||
|
||||
#### 5. Check nats-top for statistics
|
||||
|
||||
```sh
|
||||
nats-server version 0.6.6 (uptime: 30m51s)
|
||||
Server:
|
||||
Load: CPU: 0.0% Memory: 10.3M Slow Consumers: 0
|
||||
In: Msgs: 56 Bytes: 302 Msgs/Sec: 0.0 Bytes/Sec: 0
|
||||
Out: Msgs: 98 Bytes: 512 Msgs/Sec: 0.0 Bytes/Sec: 0
|
||||
|
||||
Connections: 3
|
||||
HOST CID SUBS PENDING MSGS_TO MSGS_FROM BYTES_TO BYTES_FROM LANG VERSION
|
||||
::1:58651 6 1 0 52 0 260 0 go 1.1.0
|
||||
::1:58922 38 1 0 21 0 105 0 go 1.1.0
|
||||
::1:58953 39 1 0 21 0 105 0 go 1.1.0
|
||||
```
|
||||
|
||||
#### 6. Sort nats-top statistics
|
||||
|
||||
In nats-top, enter the command `o` followed by the option, such as `bytes_to`. You see that nats-top sorts the BYTES_TO column in ascending order.
|
||||
|
||||
```sh
|
||||
nats-server version 0.6.6 (uptime: 45m40s)
|
||||
Server:
|
||||
Load: CPU: 0.0% Memory: 10.4M Slow Consumers: 0
|
||||
In: Msgs: 81 Bytes: 427 Msgs/Sec: 0.0 Bytes/Sec: 0
|
||||
Out: Msgs: 154 Bytes: 792 Msgs/Sec: 0.0 Bytes/Sec: 0
|
||||
sort by [bytes_to]:
|
||||
Connections: 3
|
||||
HOST CID SUBS PENDING MSGS_TO MSGS_FROM BYTES_TO BYTES_FROM LANG VERSION
|
||||
::1:59259 83 1 0 4 0 20 0 go 1.1.0
|
||||
::1:59349 91 1 0 2 0 10 0 go 1.1.0
|
||||
::1:59342 90 1 0 0 0 0 0 go 1.1.0
|
||||
```
|
||||
|
||||
#### 7. Use different sort options
|
||||
|
||||
Use some different sort options to explore nats-top, such as:
|
||||
|
||||
`cid`, `subs`, `pending`, `msgs_to`, `msgs_from`, `bytes_to`, `bytes_from`, `lang`, `version`
|
||||
|
||||
You can also set the sort option on the command line using the `-sort` flag. For example: `nats-top -sort bytes_to`.
|
||||
|
||||
#### 8. Display the registered subscriptions.
|
||||
|
||||
In nats-top, enter the command `s` to toggle displaying connection subscriptions. When enabled, you see the subscription subject in nats-top table:
|
||||
|
||||
```sh
|
||||
nats-server version 0.6.6 (uptime: 1h2m23s)
|
||||
Server:
|
||||
Load: CPU: 0.0% Memory: 10.4M Slow Consumers: 0
|
||||
In: Msgs: 108 Bytes: 643 Msgs/Sec: 0.0 Bytes/Sec: 0
|
||||
Out: Msgs: 185 Bytes: 1.0K Msgs/Sec: 0.0 Bytes/Sec: 0
|
||||
|
||||
Connections: 3
|
||||
HOST CID SUBS PENDING MSGS_TO MSGS_FROM BYTES_TO BYTES_FROM LANG VERSION SUBSCRIPTIONS
|
||||
::1:59708 115 1 0 6 0 48 0 go 1.1.0 foo.bar
|
||||
::1:59758 122 1 0 1 0 8 0 go 1.1.0 foo
|
||||
::1:59817 124 1 0 0 0 0 0 go 1.1.0 foo
|
||||
```
|
||||
|
||||
#### 9. Quit nats-top
|
||||
|
||||
Use the `q` command to quit nats-top.
|
||||
|
||||
#### 10. Restart nats-top with a specified query
|
||||
|
||||
For example, to query for the connection with largest number of subscriptions:
|
||||
|
||||
```sh
|
||||
% nats-top -n 1 -sort subs
|
||||
```
|
||||
|
||||
Result: nats-top displays only the client connection with the largest number of subscriptions:
|
||||
|
||||
```sh
|
||||
nats-server version 0.6.6 (uptime: 1h7m0s)
|
||||
Server:
|
||||
Load: CPU: 0.0% Memory: 10.4M Slow Consumers: 0
|
||||
In: Msgs: 109 Bytes: 651 Msgs/Sec: 0.0 Bytes/Sec: 0
|
||||
Out: Msgs: 187 Bytes: 1.0K Msgs/Sec: 0.0 Bytes/Sec: 0
|
||||
|
||||
Connections: 3
|
||||
HOST CID SUBS PENDING MSGS_TO MSGS_FROM BYTES_TO BYTES_FROM LANG VERSION
|
||||
::1:59708 115 1 0 6 0 48 0 go 1.1.0
|
||||
```
|
81
nats_server/natstop.md
Normal file
81
nats_server/natstop.md
Normal file
@ -0,0 +1,81 @@
|
||||
## Statistics
|
||||
|
||||
[nats-top](https://github.com/nats-io/nats-top) is a [top](http://man7.org/linux/man-pages/man1/top.1.html)-like tool for monitoring nats-server servers.
|
||||
|
||||
The nats-top tool provides a dynamic real-time view of a NATS server. nats-top can display a variety of system summary information about the NATS server, such as subscription, pending bytes, number of messages, and more, in real time. For example:
|
||||
|
||||
```sh
|
||||
nats-top
|
||||
|
||||
nats-server version 0.6.4 (uptime: 31m42s)
|
||||
Server:
|
||||
Load: CPU: 0.8% Memory: 5.9M Slow Consumers: 0
|
||||
In: Msgs: 34.2K Bytes: 3.0M Msgs/Sec: 37.9 Bytes/Sec: 3389.7
|
||||
Out: Msgs: 68.3K Bytes: 6.0M Msgs/Sec: 75.8 Bytes/Sec: 6779.4
|
||||
|
||||
Connections: 4
|
||||
HOST CID SUBS PENDING MSGS_TO MSGS_FROM BYTES_TO BYTES_FROM LANG VERSION SUBSCRIPTIONS
|
||||
127.0.0.1:56134 2 5 0 11.6K 11.6K 1.1M 905.1K go 1.1.0 foo, hello
|
||||
127.0.1.1:56138 3 1 0 34.2K 0 3.0M 0 go 1.1.0 _INBOX.a96f3f6853616154d23d1b5072
|
||||
127.0.0.1:56144 4 5 0 11.2K 11.1K 873.5K 1.1M go 1.1.0 foo, hello
|
||||
127.0.0.1:56151 5 8 0 11.4K 11.5K 1014.6K 1.0M go 1.1.0 foo, hello
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
nats-top can be installed using `go get`. For example:
|
||||
|
||||
```sh
|
||||
go get github.com/nats-io/nats-top
|
||||
```
|
||||
|
||||
NOTE: You may have to run the above command as user `sudo` depending on your setup. If you receive an error that you cannot install nats-top because your $GOPATH is not set, when in fact it is set, use command `sudo -E go get github.com/nats-io/nats-top` to install nats-top. The `-E` flag tells sudo to preserve the current user's environment.
|
||||
|
||||
## Usage
|
||||
|
||||
Once installed, nats-top can be run with the command `nats-top` and optional arguments.
|
||||
|
||||
```sh
|
||||
nats-top [-s server] [-m monitor] [-n num_connections] [-d delay_in_secs] [-sort by]
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
Optional arguments inclde the following:
|
||||
|
||||
| Option | Description |
|
||||
|-----------------------|-----------------------------------------------|
|
||||
| `-m monitor` | Monitoring http port from nats-server. |
|
||||
| `-n num_connections` | Limit the connections requested to the server (default 1024). |
|
||||
| `-d delay_in_secs` | Screen refresh interval (default 1 second). |
|
||||
| `-sort by` | Field to use for sorting the connections (see below). |
|
||||
|
||||
## Commands
|
||||
|
||||
While in nats-top view, you can use the following commands.
|
||||
|
||||
### option
|
||||
|
||||
Use the `o<option>` command to set the primary sort key to the `<option>` value. The option value can be one of the following: `cid`, `subs`, `pending`, `msgs_to`, `msgs_from`, `bytes_to`, `bytes_from`, `lang`, `version`.
|
||||
|
||||
You can also set the sort option on the command line using the `-sort` flag. For example: `nats-top -sort bytes_to`.
|
||||
|
||||
### limit
|
||||
|
||||
Use the `n<limit>` command to set the sample size of connections to request from the server.
|
||||
|
||||
You can also set this on the command line using the `-n num_connections` flag. For example: `nats-top -n 1`.
|
||||
|
||||
Note that if `n<limit>` is used in conjunction with `-sort`, the server will respect both options allowing queries such as the following: Query for the connection with largest number of subscriptions: `nats-top -n 1 -sort subs`.
|
||||
|
||||
### s, ? and q Commands
|
||||
|
||||
Use the `s` command to toggle displaying connection subscriptions.
|
||||
|
||||
Use the `?` command to show help message with options.
|
||||
|
||||
Use the `q` command to quit nats-top.
|
||||
|
||||
### Tutorial
|
||||
|
||||
For a walkthrough with `nats-top` check out the [tutorial](/documentation/additional_documentation/nats-top).
|
227
nats_server/tls.md
Normal file
227
nats_server/tls.md
Normal file
@ -0,0 +1,227 @@
|
||||
## TLS Security
|
||||
|
||||
As of Release 0.7.0, the server can use modern TLS semantics for client connections, route connections, and the HTTPS monitoring port. To enable TLS on the client port add the TLS configuration section as follows:
|
||||
|
||||
```ascii
|
||||
# Simple TLS config file
|
||||
|
||||
listen: 127.0.0.1:4443
|
||||
|
||||
tls {
|
||||
cert_file: "./configs/certs/server-cert.pem"
|
||||
key_file: "./configs/certs/server-key.pem"
|
||||
timeout: 2
|
||||
}
|
||||
|
||||
authorization {
|
||||
user: derek
|
||||
password: $2a$11$W2zko751KUvVy59mUTWmpOdWjpEm5qhcCZRd05GjI/sSOT.xtiHyG
|
||||
timeout: 1
|
||||
}
|
||||
```
|
||||
|
||||
Note: This TLS configuration is also used for the monitor port if enabled with the `https_port` option.
|
||||
|
||||
The server **requires** a certificate and private key. Generating self signed certs and intermediary certificate authorities is beyond the scope here, but this document can be helpful in addition to Google Search:
|
||||
<a href="https://docs.docker.com/engine/articles/https/" target="_blank">https://docs.docker.com/engine/articles/https/</a>
|
||||
|
||||
The server can be run using command line arguments to enable TLS functionality.
|
||||
|
||||
```
|
||||
--tls Enable TLS, do not verify clients (default: false)
|
||||
--tlscert FILE Server certificate file
|
||||
--tlskey FILE Private key for server certificate
|
||||
--tlsverify Enable TLS, verify client certificates
|
||||
--tlscacert FILE Client certificate CA for verification
|
||||
```
|
||||
|
||||
Examples using the test certificates which are self signed for localhost and 127.0.0.1.
|
||||
|
||||
```sh
|
||||
> ./nats-server --tls --tlscert=./test/configs/certs/server-cert.pem --tlskey=./test/configs/certs/server-key.pem
|
||||
|
||||
[2935] 2016/04/26 13:34:30.685413 [INF] Starting nats-server version 0.8.0.beta
|
||||
[2935] 2016/04/26 13:34:30.685509 [INF] Listening for client connections on 0.0.0.0:4222
|
||||
[2935] 2016/04/26 13:34:30.685656 [INF] TLS required for client connections
|
||||
[2935] 2016/04/26 13:34:30.685660 [INF] Server is ready
|
||||
```
|
||||
|
||||
Notice that the log indicates that the client connections will be required to use TLS. If you run the server in Debug mode with -D or -DV, the logs will show the cipher suite selection for each connected client.
|
||||
|
||||
```sh
|
||||
[15146] 2015/12/03 12:38:37.733139 [DBG] ::1:63330 - cid:1 - Starting TLS client connection handshake
|
||||
[15146] 2015/12/03 12:38:37.751948 [DBG] ::1:63330 - cid:1 - TLS handshake complete
|
||||
[15146] 2015/12/03 12:38:37.751959 [DBG] ::1:63330 - cid:1 - TLS version 1.2, cipher suite TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
|
||||
```
|
||||
|
||||
### TLS Ciphers
|
||||
|
||||
The server requires TLS version 1.2, and sets preferences for modern cipher suites that avoid those known with vulnerabilities. The
|
||||
server's default preferences when building with Go1.5 are as follows.
|
||||
|
||||
```go
|
||||
func defaultCipherSuites() []uint16 {
|
||||
return []uint16{
|
||||
// The SHA384 versions are only in Go1.5+
|
||||
tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
|
||||
tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
|
||||
tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,
|
||||
tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,
|
||||
tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
|
||||
tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Optionally if your organization requires a specific cipher or list of ciphers, you can configure them with the `cipher_suites` option as follows:
|
||||
|
||||
```ascii
|
||||
tls {
|
||||
cert_file: "./configs/certs/server.pem"
|
||||
key_file: "./configs/certs/key.pem"
|
||||
timeout: 2
|
||||
cipher_suites: [
|
||||
"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
|
||||
"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
A list of supported cipher suites is [located here in the cipherMap variable](https://github.com/nats-io/nats-server/blob/master/server/ciphersuites.go#L21).
|
||||
|
||||
### Client TLS Mutual Authentication
|
||||
|
||||
Optionally the server can require that clients need to present certificates, and the server can be configured with a CA authority to verify the client certificates. Simply add the option `verify` the TLS configuration section as follows:
|
||||
|
||||
```ascii
|
||||
tls {
|
||||
cert_file: "./configs/certs/server-cert.pem"
|
||||
key_file: "./configs/certs/server-key.pem"
|
||||
ca_file: "./configs/certs/ca.pem"
|
||||
verify: true
|
||||
}
|
||||
```
|
||||
|
||||
If you want the server to enforce and require client certificates as well via the command line, utilize this example.
|
||||
|
||||
```sh
|
||||
> ./nats-server --tlsverify --tlscert=./test/configs/certs/server-cert.pem --tlskey=./test/configs/certs/server-key.pem --tlscacert=./test/configs/certs/ca.pem
|
||||
```
|
||||
|
||||
This option simply verifies the client's certificate has been signed by the CA specified in the `ca_file` option. However, it does not map any attribute of the client's certificate to the user's identity.
|
||||
|
||||
To have TLS Mutual Authentication map certificate attributes to the users identity, replace the option `verify` with `verify_and_map` as shown as follows:
|
||||
|
||||
```ascii
|
||||
tls {
|
||||
cert_file: "./configs/certs/server-cert.pem"
|
||||
key_file: "./configs/certs/server-key.pem"
|
||||
ca_file: "./configs/certs/ca.pem"
|
||||
# Require a client certificate and map user id from certificate
|
||||
verify_and_map: true
|
||||
}
|
||||
```
|
||||
|
||||
There are two options for certificate attributes that can be mapped to user names. The first is the email address in the Subject Alternative Name (SAN) field of the certificate. While generating a certificate with this attribute is outside the scope of this document, we will view this with OpenSSL:
|
||||
|
||||
```ascii
|
||||
$ openssl x509 -noout -text -in test/configs/certs/client-id-auth-cert.pem
|
||||
Certificate:
|
||||
-------------<truncated>-------------
|
||||
X509v3 extensions:
|
||||
X509v3 Subject Alternative Name:
|
||||
DNS:localhost, IP Address:127.0.0.1, email:derek@nats.io
|
||||
X509v3 Extended Key Usage:
|
||||
TLS Web Client Authentication
|
||||
-------------<truncated>-------------
|
||||
```
|
||||
|
||||
The configuration to authorize this user would be as follows:
|
||||
|
||||
```ascii
|
||||
authorization {
|
||||
users = [
|
||||
{user: "derek@nats.io", permissions: { publish: "foo" }}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Note: This configuration only works for the first email address if there are multiple emails in the SAN field.
|
||||
|
||||
The second option is to use the RFC 2253 Distinguished Names syntax from the certificate subject as follows:
|
||||
|
||||
```ascii
|
||||
$ openssl x509 -noout -text -in test/configs/certs/tlsauth/client2.pem
|
||||
Certificate:
|
||||
Data:
|
||||
-------------<truncated>-------------
|
||||
Subject: OU=CNCF, CN=example.com
|
||||
-------------<truncated>-------------
|
||||
```
|
||||
|
||||
The configuration to authorize this user would be as follows:
|
||||
|
||||
```ascii
|
||||
authorization {
|
||||
users = [
|
||||
{user: "CN=example.com,OU=CNCF", permissions: { publish: "foo" }}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Cluster TLS Mutual Authentication
|
||||
|
||||
When setting up clusters all servers in the cluster, if using TLS, will both verify the connecting endpoints and the server responses. So certificates are checked in both directions. Certificates can be configured only for the server's cluster identity, keeping client and server certificates separate from cluster formation.
|
||||
|
||||
```ascii
|
||||
cluster {
|
||||
listen: 127.0.0.1:4244
|
||||
|
||||
tls {
|
||||
# Route cert
|
||||
cert_file: "./configs/certs/srva-cert.pem"
|
||||
# Private key
|
||||
key_file: "./configs/certs/srva-key.pem"
|
||||
# Optional certificate authority verifying connected routes
|
||||
# Required when we have self-signed CA, etc.
|
||||
ca_file: "./configs/certs/ca.pem"
|
||||
}
|
||||
# Routes are actively solicited and connected to from this server.
|
||||
# Other servers can connect to us if they supply the correct credentials
|
||||
# in their routes definitions from above.
|
||||
routes = [
|
||||
nats-route://127.0.0.1:4246
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Using bcrypt to Protect Passwords
|
||||
|
||||
In addition to TLS functionality, the server now also supports hashing of passwords and authentication tokens using `bcrypt`. To take advantage of this, simply replace the plaintext password in the configuration with its `bcrypt` hash, and the server will automatically utilize `bcrypt` as needed.
|
||||
|
||||
A utility for creating `bcrypt` hashes is included with the nats-server distribution (`util/mkpasswd.go`). Running it with no arguments will generate a new secure password along with the associated hash. This can be used for a password or a token in the configuration.
|
||||
|
||||
```
|
||||
~/go/src/github.com/nats-io/nats-server/util> go get golang.org/x/crypto/ssh/terminal
|
||||
~/go/src/github.com/nats-io/nats-server/util> go build mkpasswd.go
|
||||
~/go/src/github.com/nats-io/nats-server/util> ./mkpasswd
|
||||
pass: #IclkRPHUpsTmACWzmIGXr
|
||||
bcrypt hash: $2a$11$3kIDaCxw.Glsl1.u5nKa6eUnNDLV5HV9tIuUp7EHhMt6Nm9myW1aS
|
||||
```
|
||||
|
||||
If you already have a password selected, you can supply the `-p` flag on the command line, enter your desired password, and a `bcrypt` hash will be generated for it:
|
||||
```
|
||||
~/go/src/github.com/nats-io/nats-server/util> ./mkpasswd -p
|
||||
Enter Password: *******
|
||||
Reenter Password: ******
|
||||
bcrypt hash: $2a$11$3kIDaCxw.Glsl1.u5nKa6eUnNDLV5HV9tIuUp7EHhMt6Nm9myW1aS
|
||||
```
|
||||
|
||||
Add the hash into the server configuration file's authorization section.
|
||||
|
||||
```
|
||||
authorization {
|
||||
user: derek
|
||||
password: $2a$11$3kIDaCxw.Glsl1.u5nKa6eUnNDLV5HV9tIuUp7EHhMt6Nm9myW1aS
|
||||
}
|
||||
```
|
86
nats_server/upgrading.md
Normal file
86
nats_server/upgrading.md
Normal file
@ -0,0 +1,86 @@
|
||||
## Cluster Upgrading
|
||||
|
||||
The basic strategy for upgrading a cluster revolves around the server's ability to gossip cluster configuration to clients and other servers. When cluster configuration changes, clients become aware of new servers automatically. In case of a disconnect, a client has a list of servers that joined the cluster in addition to the ones it knew about from its connection settings.
|
||||
|
||||
Note that since each server stores it's own permission and authentication configuration, new servers added to a cluster should provide the same users and authorization to prevent clients from getting rejected or gaining unexpected privileges.
|
||||
|
||||
For purposes of describing the scenario, let's get some fingers on keyboards, and go through the motions. Let's consider a cluster of two servers: 'A' and 'B.', and yes - clusters should be *three* to *five* servers, but for purposes of describing the behavior and cluster upgrade process, a cluster of two servers will suffice.
|
||||
|
||||
Let's build this cluster:
|
||||
|
||||
```bash
|
||||
nats-server -D -p 4222 -cluster nats://localhost:6222 -routes nats://localhost:6222,nats://localhost:6333
|
||||
```
|
||||
|
||||
The command above is starting nats-server with debug output enabled, listening for clients on port 4222, and accepting cluster connections on port 6222. The `-routes` option specifies a list of nats URLs where the server will attempt to connect
|
||||
to other servers. These URLs define the cluster ports enabled on the cluster peers.
|
||||
|
||||
Keen readers will notice a self-route. Gnatsd will ignore the self-route, but it makes for a single consistent configuration for all servers.
|
||||
|
||||
You will see the server started, we notice it emits some warnings because it cannot connect to 'localhost:6333'. The message more accurately reads:
|
||||
|
||||
```ascii
|
||||
Error trying to connect to route: dial tcp localhost:6333: connect: connection refused
|
||||
```
|
||||
|
||||
Let's fix that, by starting the second server:
|
||||
```bash
|
||||
nats-server -D -p 4333 -cluster nats://localhost:6333 -routes nats://localhost:6222,nats://localhost:6333
|
||||
```
|
||||
The second server was started on port 4333 with its cluster port on 6333. Otherwise the same as 'A.'
|
||||
|
||||
Let's get one client, so we can observe it moving between servers as servers get removed:
|
||||
```bash
|
||||
nats-sub -s nats://localhost:4222 ">"
|
||||
```
|
||||
|
||||
Nats-sub is a subscriber sample included with all NATS clients. Nats-sub subscribes to a subject and prints out any messages received. You can find the source code to the go version of nats-sub [here)(https://github.com/nats-io/go-nats/tree/master/examples). After starting the subscriber you should see a message on 'A' that a new client connected.
|
||||
|
||||
We have two servers and a client. Time to simulate our rolling upgrade. But wait, before we upgrade 'A,' let's introduce a new server 'T.' Server 'T' will join the existing cluster while we perform the upgrade. Its sole purpose is to provide an additional place where clients can go besides 'A.' and ensure we don't end up with a single server serving all the clients after the upgrade procedure. Clients will randomly select a server when connecting unless a special option is provided that disables that functionality (usually called 'DontRandomize' or 'noRandomize'). You can read more about ["Avoiding the Thundering Herd"](https://www.nats.io/documentation/writing_applications/connecting/).
|
||||
Suffice it to say that clients redistribute themselves about evenly between all servers in the cluster. In our case 1/2 of the clients on 'A' will jump over to 'B' and the remaining half to 'T.'
|
||||
|
||||
Let's start our temporary server:
|
||||
|
||||
```bash
|
||||
nats-server -D -p 4444 -cluster nats://localhost:6444 -routes nats://localhost:6222,nats://localhost:6333
|
||||
```
|
||||
|
||||
After an instant or so, clients on 'A' learn of the new cluster member that joined. On our hands-on tutorial, `nats-sub` is now aware of 3 possible servers, 'A' (specified when we started the tool) and 'B' and 'T' learned from the cluster gossip.
|
||||
|
||||
We invoke our admin powers and turn off 'A' by issuing a `CTRL+C` to the terminal on 'A,' and observe that either 'B' or 'T' reports that a new client connected. That is our `nats-sub` client.
|
||||
|
||||
We perform the upgrade process, update the binary for 'A', and restart 'A':
|
||||
|
||||
```bash
|
||||
nats-server -D -p 4222 -cluster nats://localhost:6222 -routes nats://localhost:6222,nats://localhost:6333
|
||||
```
|
||||
|
||||
We move on to upgrade 'B'. Notice that clients from 'B' reconnect to 'A' and 'T'. We upgrade and restart 'B':
|
||||
|
||||
```bash
|
||||
nats-server -D -p 4333 -cluster nats://localhost:6333 -routes nats://localhost:6222,nats://localhost:6333
|
||||
```
|
||||
|
||||
If we had more servers, we would continue the stop, update, restart rotation as we did for 'A' and 'B.' After restarting the last server, we can go ahead and turn off 'T.' Any clients on 'T' will redistribute to our permanent cluster members.
|
||||
|
||||
|
||||
### Seed Servers
|
||||
|
||||
In the examples above we started nats-server specifying two clustering routes. It is possible to allow the server gossip protocol drive it and reduce the amount of configuration. You could for example start A, B and C as follows:
|
||||
|
||||
#### A - Seed Server
|
||||
```bash
|
||||
nats-server -D -p 4222 -cluster nats://localhost:6222
|
||||
```
|
||||
|
||||
#### B
|
||||
```bash
|
||||
nats-server -D -p 4333 -cluster nats://localhost:6333 -routes nats://localhost:6222
|
||||
```
|
||||
|
||||
#### C
|
||||
```bash
|
||||
nats-server -D -p 4444 -cluster nats://localhost:6444 -routes nats://localhost:6222
|
||||
```
|
||||
|
||||
Once they connect to the 'seed server', the will learn about all the other servers and connect to each other forming the full mesh.
|
Loading…
x
Reference in New Issue
Block a user