Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send heartbeat OPTIONS message less frequent and enable keep alive #169

Merged
merged 2 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading