From 10ae2129f9ccdec035f0a072a9eb2be4425788c7 Mon Sep 17 00:00:00 2001 From: Ivan Kozlovic Date: Wed, 13 May 2020 17:05:41 -0600 Subject: [PATCH] Release v1.10.0 Signed-off-by: Ivan Kozlovic --- README.md | 14 +++++++++++++- nats.go | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c059c2539..5eb7c9686 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ When using or transitioning to Go modules support: ```bash # Go client latest or explicit version go get github.com/nats-io/nats.go/@latest -go get github.com/nats-io/nats.go/@v1.9.2 +go get github.com/nats-io/nats.go/@v1.10.0 # For latest NATS Server, add /v2 at the end go get github.com/nats-io/nats-server/v2 @@ -325,6 +325,18 @@ nc, err := nats.Connect(servers) // This example means 10 seconds total per backend. nc, err = nats.Connect(servers, nats.MaxReconnects(5), nats.ReconnectWait(2 * time.Second)) +// You can also add some jitter for the reconnection. +// This call will add up to 500 milliseconds for non TLS connections and 2 seconds for TLS connections. +// If not specified, the library defaults to 100 milliseconds and 1 second, respectively. +nc, err = nats.Connect(servers, nats.ReconnectJitter(500*time.Millisecond, 2*time.Second)) + +// You can also specify a custom reconnect delay handler. If set, the library will invoke it when it has tried +// all URLs in its list. The value returned will be used as the total sleep time, so add your own jitter. +// The library will pass the number of times it went through the whole list. +nc, err = nats.Connect(servers, nats.CustomReconnectDelay(func(attempts int) time.Duration { + return someBackoffFunction(attempts) +})) + // Optionally disable randomization of the server pool nc, err = nats.Connect(servers, nats.DontRandomize()) diff --git a/nats.go b/nats.go index 06f961a3d..d0d569cc4 100644 --- a/nats.go +++ b/nats.go @@ -45,7 +45,7 @@ import ( // Default Constants const ( - Version = "1.9.3" + Version = "1.10.0" DefaultURL = "nats://127.0.0.1:4222" DefaultPort = 4222 DefaultMaxReconnect = 60