Reset fail timer on success

This commit is contained in:
Sergey Stepanov 2024-12-01 18:20:54 +03:00
parent 56e3ce328e
commit 9caf45af78
No known key found for this signature in database
GPG key ID: A56B4929BAA8556B
2 changed files with 4 additions and 11 deletions

View file

@ -13,14 +13,7 @@ func NewRetry() Retry {
return Retry{t: retry}
}
func (r *Retry) Fail() *Retry { r.fail = true; time.Sleep(r.t); return r }
func (r *Retry) Failed() bool { return r.fail }
func (r *Retry) Multiply(x int) { r.t *= time.Duration(x) }
func (r *Retry) SuccessCheck() {
if r.fail {
return
}
r.t = retry
r.fail = false
}
func (r *Retry) Fail() *Retry { r.fail = true; time.Sleep(r.t); return r }
func (r *Retry) Multiply(x int) { r.t *= time.Duration(x) }
func (r *Retry) Success() { r.t = retry; r.fail = false }
func (r *Retry) Time() time.Duration { return r.t }

View file

@ -126,7 +126,7 @@ func (w *Worker) Start(done chan struct{}) {
w.cord.SendLibrary(w)
w.cord.SendPrevSessions(w)
<-wait
retry.SuccessCheck()
retry.Success()
}
}
}()