mirror of
https://github.com/taigrr/nats.docs
synced 2025-01-18 04:03:23 -08:00
Cleaned up how examples are handled to reduce thrashing in git
Examples are no longer in the final html as solo files, only in their container file
This commit is contained in:
105
_examples/no_echo.html
Normal file
105
_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>
|
||||
Reference in New Issue
Block a user