From dd1ef1584654bc170c9db8dd895fdc8313de30d1 Mon Sep 17 00:00:00 2001 From: Derek Collison Date: Thu, 13 Dec 2018 05:48:01 -0800 Subject: [PATCH] Added MaxPingsOutstanding, fixes #414 Signed-off-by: Derek Collison --- nats.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/nats.go b/nats.go index c02fc5f36..6dfe57972 100644 --- a/nats.go +++ b/nats.go @@ -633,7 +633,7 @@ func MaxReconnects(max int) Option { } } -// PingInterval is an Option to set the period for client ping commands +// PingInterval is an Option to set the period for client ping commands. func PingInterval(t time.Duration) Option { return func(o *Options) error { o.PingInterval = t @@ -641,7 +641,16 @@ func PingInterval(t time.Duration) Option { } } -// ReconnectBufSize sets the buffer size of messages kept while busy reconnecting +// MaxPingsOutstanding is an Option to set the maximum number of ping requests +// that can go un-answered by the server before closing the connection. +func MaxPingsOutstanding(max int) Option { + return func(o *Options) error { + o.MaxPingsOut = max + return nil + } +} + +// ReconnectBufSize sets the buffer size of messages kept while busy reconnecting. func ReconnectBufSize(size int) Option { return func(o *Options) error { o.ReconnectBufSize = size