graceful backoffs on connection retries

このコミットが含まれているのは:
Dan Ballard 2019-03-25 13:01:24 -07:00
コミット 7640fc1c0d
2個のファイルの変更9行の追加4行の削除

ファイルの表示

@ -99,7 +99,9 @@ func (m *Manager) GetPeerServerConnectionForOnion(host string) (psc *PeerServerC
// AttemptReconnections repeatedly attempts to reconnect with failed peers and servers.
func (m *Manager) AttemptReconnections() {
timeout := time.Duration(0) // first pass right away
maxTimeout := time.Minute * 5
// nearly instant first run, next few runs will prolly be too quick to have any FAILED and will gracefully slow to MAX after that
timeout := time.Millisecond * 500
for {
select {
@ -120,8 +122,11 @@ func (m *Manager) AttemptReconnections() {
}
m.lock.Unlock()
// Launch Another Run In 30 Seconds
timeout = time.Duration(30 * time.Second)
if timeout < maxTimeout {
timeout = timeout * 2
} else {
timeout = maxTimeout
}
case <-m.breakChannel:
return
}

ファイルの表示

@ -102,7 +102,7 @@ func (psc *PeerServerConnection) SendGroupMessage(gm *protocol.GroupMessage) err
errCount := 0
for errCount < 5 {
time.Sleep(time.Second * 1)
time.Sleep(time.Second * time.Duration(errCount+1)) // back off retry
err = psc.connection.Do(func() error {
channel := psc.connection.Channel("im.cwtch.server.send", channels.Outbound)
if channel == nil {