-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Adding TCP keepalives support for the broker's connection #408
Conversation
@@ -12,6 +12,10 @@ type Config struct { | |||
DialTimeout time.Duration // How long to wait for the initial connection to succeed before timing out and returning an error (default 30s). | |||
ReadTimeout time.Duration // How long to wait for a response before timing out and returning an error (default 30s). | |||
WriteTimeout time.Duration // How long to wait for a transmit to succeed before timing out and returning an error (default 30s). | |||
|
|||
// KeepAlive specifies the keep-alive period for an active network connection. | |||
// If zero, keep-alives are not enabled. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"not enabled" == "disabled"
Also, please mention that the default is 0 (disabled).
A few nits, but generally LGTM. You're welcome to add a line to the changelog if you wish. |
@@ -78,6 +79,7 @@ func TestClientDoesntCachePartitionsForTopicsWithErrors(t *testing.T) { | |||
seedBroker.Returns(metadataResponse) | |||
|
|||
config := NewConfig() | |||
config.Net.KeepAlive = 12 * time.Millisecond |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure whether this is a useful addition given that we don't actually test it.
LGTM apart from the nitpicks. |
@wvanbergen or @eapache - Does the new config setting need a validator ? https://github.com/Shopify/sarama/blob/master/config.go#L187 The other nits were addressed. :) |
Assuming that a setting <0 is incoherent then yes, a validator is important - good catch! |
Adding TCP keepalives support for the broker's connection
Addresses issue #407
Our Google Compute Engine applications have a couple of under utilized topics/partitions that only receive messages once an hour or so. Google Compute Engine's networking automatically kills any connection thats been idle for more than 10mins. This causes the Sarama clients on GCE to return this error
read tcp 10.10.10.10:9093: i/o timeout
.From Google Compute Engine's Docs:
Keepalive Refs:
PS thanks for all the hard work! You guys rock!