Skip to content

Commit

Permalink
Merge pull request #169 from sylwiaszunejko/heartbeat
Browse files Browse the repository at this point in the history
Send heartbeat OPTIONS message less frequent and enable keep alive
  • Loading branch information
avelanarius authored May 9, 2024
2 parents 04e6e93 + c953389 commit 46c0e71
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ type ClusterConfig struct {
// Default reconnection policy to use for reconnecting before trying to mark host as down.
ReconnectionPolicy ReconnectionPolicy

// The keepalive period to use, enabled if > 0 (default: 0)
// The keepalive period to use, enabled if > 0 (default: 15 seconds)
// SocketKeepalive is used to set up the default dialer and is ignored if Dialer or HostDialer is provided.
SocketKeepalive time.Duration

Expand Down Expand Up @@ -290,6 +290,7 @@ func NewCluster(hosts ...string) *ClusterConfig {
ReconnectInterval: 60 * time.Second,
ConvictionPolicy: &SimpleConvictionPolicy{},
ReconnectionPolicy: &ConstantReconnectionPolicy{MaxRetries: 3, Interval: 1 * time.Second},
SocketKeepalive: 15 * time.Second,
WriteCoalesceWaitTime: 200 * time.Microsecond,
}

Expand Down
2 changes: 1 addition & 1 deletion conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ func (c *Conn) heartBeat(ctx context.Context) {
switch resp.(type) {
case *supportedFrame:
// Everything ok
sleepTime = 5 * time.Second
sleepTime = 30 * time.Second
failures = 0
case error:
// TODO: should we do something here?
Expand Down
2 changes: 1 addition & 1 deletion control.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (c *controlConn) heartBeat() {
switch resp.(type) {
case *supportedFrame:
// Everything ok
sleepTime = 5 * time.Second
sleepTime = 30 * time.Second
continue
case error:
goto reconn
Expand Down

0 comments on commit 46c0e71

Please sign in to comment.