make the reconnect delay interruptible by the session context
This commit is contained in:
+8
-2
@@ -316,8 +316,14 @@ func (w *session) reset(ctx context.Context) bool {
|
||||
default:
|
||||
}
|
||||
|
||||
// refresh session
|
||||
time.Sleep(w.config.ReconnectDelay)
|
||||
// refresh session timeout
|
||||
timer := time.NewTimer(w.config.ReconnectDelay)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
timer.Stop()
|
||||
return false
|
||||
case <-timer.C:
|
||||
}
|
||||
w.restartCount.Add(1)
|
||||
return true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user