add randomness to reconnections
This commit is contained in:
1 parent
ff21aad59e
commit
c36c561e35
6 files changed
+59
-72
No files matched your search
@@ -22,11 +22,9 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
TmAPIBase = tmapi.APIBase
|
||||
TmOrigin = tmapi.Origin
|
||||
TmPingPeriod = 5 * time.Second
|
||||
telemostReconnectInitialDelay = time.Second
|
||||
telemostReconnectMaxDelay = 16 * time.Second
|
||||
TmAPIBase = tmapi.APIBase
|
||||
TmOrigin = tmapi.Origin
|
||||
TmPingPeriod = 5 * time.Second
|
||||
)
|
||||
|
||||
type TelemostHeadlessJoiner struct {
|
||||
@@ -169,19 +167,7 @@ func (j *TelemostHeadlessJoiner) runOnce() error {
|
||||
}
|
||||
|
||||
func (j *TelemostHeadlessJoiner) waitBeforeRetry(attempt int) bool {
|
||||
delay := telemostReconnectInitialDelay << attempt
|
||||
if delay > telemostReconnectMaxDelay || delay <= 0 {
|
||||
delay = telemostReconnectMaxDelay
|
||||
}
|
||||
j.logFn("telemost-joiner: waiting %s before reconnect", delay)
|
||||
timer := time.NewTimer(delay)
|
||||
defer timer.Stop()
|
||||
select {
|
||||
case <-timer.C:
|
||||
return !j.isClosed()
|
||||
case <-j.stopCh:
|
||||
return false
|
||||
}
|
||||
return waitReconnectBackoff(attempt, j.logFn, "telemost-joiner", j.stopCh, j.isClosed)
|
||||
}
|
||||
|
||||
func (j *TelemostHeadlessJoiner) resetSessionState() {
|
||||
|
||||
Reference in new issue
Block a user