@@ -23,6 +23,7 @@ const (
2323 defaultWriteTimeout = time .Duration (0 ) // Write() will not time out
2424 defaultBufferLimit = 8 * 1024 * 1024
2525 defaultRetryWait = 500
26+ defaultMaxRetryWait = 60000
2627 defaultMaxRetry = 13
2728 defaultReconnectWaitIncreRate = 1.5
2829 // Default sub-second precision value to false since it is only compatible
@@ -40,6 +41,7 @@ type Config struct {
4041 BufferLimit int `json:"buffer_limit"`
4142 RetryWait int `json:"retry_wait"`
4243 MaxRetry int `json:"max_retry"`
44+ MaxRetryWait int `json:"max_retry_wait"`
4345 TagPrefix string `json:"tag_prefix"`
4446 AsyncConnect bool `json:"async_connect"`
4547 MarshalAsJSON bool `json:"marshal_as_json"`
@@ -89,6 +91,9 @@ func New(config Config) (f *Fluent, err error) {
8991 if config .MaxRetry == 0 {
9092 config .MaxRetry = defaultMaxRetry
9193 }
94+ if config .MaxRetryWait == 0 {
95+ config .MaxRetryWait = defaultMaxRetryWait
96+ }
9297 if config .AsyncConnect {
9398 f = & Fluent {Config : config , reconnecting : true }
9499 go f .reconnect ()
@@ -293,6 +298,9 @@ func (f *Fluent) reconnect() {
293298 panic ("fluent#reconnect: failed to reconnect!" )
294299 }
295300 waitTime := f .Config .RetryWait * e (defaultReconnectWaitIncreRate , float64 (i - 1 ))
301+ if waitTime > f .Config .MaxRetryWait {
302+ waitTime = f .Config .MaxRetryWait
303+ }
296304 time .Sleep (time .Duration (waitTime ) * time .Millisecond )
297305 }
298306}
0 commit comments