diff --git a/nats.go b/nats.go index f91445842..81f51335f 100644 --- a/nats.go +++ b/nats.go @@ -331,10 +331,12 @@ type Options struct { // MaxReconnect sets the number of reconnect attempts that will be // tried before giving up. If negative, then it will never give up // trying to reconnect. + // Defaults to 60. MaxReconnect int // ReconnectWait sets the time to backoff after attempting a reconnect // to a server that we were already connected to previously. + // Defaults to 2s. ReconnectWait time.Duration // CustomReconnectDelayCB is invoked after the library tried every @@ -347,16 +349,20 @@ type Options struct { // ReconnectJitter sets the upper bound for a random delay added to // ReconnectWait during a reconnect when no TLS is used. + // Defaults to 100ms. ReconnectJitter time.Duration // ReconnectJitterTLS sets the upper bound for a random delay added to // ReconnectWait during a reconnect when TLS is used. + // Defaults to 1s. ReconnectJitterTLS time.Duration // Timeout sets the timeout for a Dial operation on a connection. + // Defaults to 2s. Timeout time.Duration // DrainTimeout sets the timeout for a Drain Operation to complete. + // Defaults to 30s. DrainTimeout time.Duration // FlusherTimeout is the maximum time to wait for write operations @@ -365,10 +371,12 @@ type Options struct { // PingInterval is the period at which the client will be sending ping // commands to the server, disabled if 0 or negative. + // Defaults to 2m. PingInterval time.Duration // MaxPingsOut is the maximum number of pending ping commands that can // be awaiting a response before raising an ErrStaleConnection error. + // Defaults to 2. MaxPingsOut int // ClosedCB sets the closed handler that is called when a client will @@ -401,12 +409,14 @@ type Options struct { // ReconnectBufSize is the size of the backing bufio during reconnect. // Once this has been exhausted publish operations will return an error. + // Defaults to 8388608 bytes (8MB). ReconnectBufSize int // SubChanLen is the size of the buffered channel used between the socket // Go routine and the message delivery for SyncSubscriptions. // NOTE: This does not affect AsyncSubscriptions which are // dictated by PendingLimits() + // Defaults to 65536. SubChanLen int // UserJWT sets the callback handler that will fetch a user's JWT. @@ -861,6 +871,7 @@ func NoEcho() Option { } // ReconnectWait is an Option to set the wait time between reconnect attempts. +// Defaults to 2s. func ReconnectWait(t time.Duration) Option { return func(o *Options) error { o.ReconnectWait = t @@ -869,6 +880,7 @@ func ReconnectWait(t time.Duration) Option { } // MaxReconnects is an Option to set the maximum number of reconnect attempts. +// Defaults to 60. func MaxReconnects(max int) Option { return func(o *Options) error { o.MaxReconnect = max @@ -877,6 +889,7 @@ func MaxReconnects(max int) Option { } // ReconnectJitter is an Option to set the upper bound of a random delay added ReconnectWait. +// Defaults to 100ms and 1s, respectively. func ReconnectJitter(jitter, jitterForTLS time.Duration) Option { return func(o *Options) error { o.ReconnectJitter = jitter @@ -895,6 +908,7 @@ func CustomReconnectDelay(cb ReconnectDelayHandler) Option { } // PingInterval is an Option to set the period for client ping commands. +// Defaults to 2m. func PingInterval(t time.Duration) Option { return func(o *Options) error { o.PingInterval = t @@ -904,6 +918,7 @@ func PingInterval(t time.Duration) Option { // MaxPingsOutstanding is an Option to set the maximum number of ping requests // that can go unanswered by the server before closing the connection. +// Defaults to 2. func MaxPingsOutstanding(max int) Option { return func(o *Options) error { o.MaxPingsOut = max @@ -912,6 +927,7 @@ func MaxPingsOutstanding(max int) Option { } // ReconnectBufSize sets the buffer size of messages kept while busy reconnecting. +// Defaults to 8388608 bytes (8MB). func ReconnectBufSize(size int) Option { return func(o *Options) error { o.ReconnectBufSize = size @@ -920,6 +936,7 @@ func ReconnectBufSize(size int) Option { } // Timeout is an Option to set the timeout for Dial on a connection. +// Defaults to 2s. func Timeout(t time.Duration) Option { return func(o *Options) error { o.Timeout = t @@ -936,6 +953,7 @@ func FlusherTimeout(t time.Duration) Option { } // DrainTimeout is an Option to set the timeout for draining a connection. +// Defaults to 30s. func DrainTimeout(t time.Duration) Option { return func(o *Options) error { o.DrainTimeout = t @@ -1078,6 +1096,7 @@ func Nkey(pubKey string, sigCB SignatureHandler) Option { // SyncQueueLen will set the maximum queue len for the internal // channel used for SubscribeSync(). +// Defaults to 65536. func SyncQueueLen(max int) Option { return func(o *Options) error { o.SubChanLen = max