Skip to content

Commit

Permalink
Reset fail timer on success
Browse files Browse the repository at this point in the history
  • Loading branch information
sergystepanov committed Dec 1, 2024
1 parent 56e3ce3 commit 9caf45a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
13 changes: 3 additions & 10 deletions pkg/network/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
2 changes: 1 addition & 1 deletion pkg/worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (w *Worker) Start(done chan struct{}) {
w.cord.SendLibrary(w)
w.cord.SendPrevSessions(w)
<-wait
retry.SuccessCheck()
retry.Success()
}
}
}()
Expand Down

0 comments on commit 9caf45a

Please sign in to comment.