smira / go-statsd

Go statsd client library with zero allocation overhead, great performance and reconnects
MIT License
109 stars 18 forks source link

What is the major difference between ReconnectInterval and RetryTimeout ? Both seems to be same type of property for a statsd client #24

Closed mjmanav4 closed 4 years ago

mjmanav4 commented 4 years ago
// ReconnectInterval controls UDP socket reconnects
//
// Reconnecting is important to follow DNS changes, e.g. in
// dynamic container environments like K8s where statsd server
// instance might be relocated leading to new IP address.
//
// By default reconnects are disabled
func ReconnectInterval(interval time.Duration) Option {
    return func(c *ClientOptions) {
        c.ReconnectInterval = interval
    }
}

// RetryTimeout controls how often client should attempt reconnecting
// to statsd server on failure
//
// Default value is 5 seconds
func RetryTimeout(timeout time.Duration) Option {
    return func(c *ClientOptions) {
        c.RetryTimeout = timeout
    }
}
smira commented 4 years ago

ReconnectInterval is totally optional, it breaks and re-establishes new UPD connection every X seconds. If your statsd server runs on static IP, you probably don't even need that (or you can set it to arbitrary high value). But if your stasd server might change its IP over time, you need this setting, as UDP socket won't ever notice IP address change, and reconnecting is a way to catch up with DNS changes.

RetryTimeout controls how often client keeps reconnecting when connection fails (e.g. DNS is unresolvable).

So these are two different settings.