mirror of
https://github.com/taigrr/nats.docs
synced 2025-01-18 04:03:23 -08:00
Change example jitter values since those are the defaults now
Document that libraries will use default values if the ReconnectJitter option is not specified. Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
This commit is contained in:
parent
7a2e69f844
commit
ddb252b578
@ -78,13 +78,13 @@ nc.close();
|
|||||||
{% endtab %}
|
{% endtab %}
|
||||||
{% endtabs %}
|
{% endtabs %}
|
||||||
|
|
||||||
Some libraries will allow you to specify some random jitter to add to the reconnect wait specified above.
|
Some libraries will allow you to specify some random jitter to add to the reconnect wait specified above. If not specified, the library will default to 100 milliseconds for non TLS connections and 1 second for TLS connections. After all servers in the list have been tried, the library will get a random value between 0 and the reconnect jitter, and add that to the reconnect wait option.
|
||||||
|
|
||||||
{% tabs %}
|
{% tabs %}
|
||||||
{% tab title="Go" %}
|
{% tab title="Go" %}
|
||||||
```go
|
```go
|
||||||
// Set some jitter up to 100 millisecond for non TLS connections and 1 second for TLS connections.
|
// Set some jitter to add to the reconnect wait duration: up to 500 milliseconds for non TLS connections and up to 2 seconds for TLS connections.
|
||||||
nc, err := nats.Connect("demo.nats.io", nats.ReconnectJitter(100*time.Millisecond, 1*time.Second))
|
nc, err := nats.Connect("demo.nats.io", nats.ReconnectJitter(500*time.Millisecond, 2*time.Second))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user