标签:
func e(x, y float64) int { return int(math.Pow(x, y)) } func (f *Fluent) reconnect() { go func() { for i := 0; ; i++ { err := f.connect() if err == nil { f.mu.Lock() f.reconnecting = false f.mu.Unlock() break } else { if i == f.Config.MaxRetry { panic("fluent#reconnect: failed to reconnect!") } waitTime := f.Config.RetryWait * e(defaultReconnectWaitIncreRate, float64(i-1)) time.Sleep(time.Duration(waitTime) * time.Millisecond) } } }() }
sleep时间按照指数倍增长
标签:
原文地址:http://my.oschina.net/u/932809/blog/491492