Source File
tries.go
Belonging Package
github.com/cenkalti/backoff/v4
package backoff
import
/*
WithMaxRetries creates a wrapper around another BackOff, which will
return Stop if NextBackOff() has been called too many times since
the last time Reset() was called
Note: Implementation is not thread-safe.
*/
func ( BackOff, uint64) BackOff {
return &backOffTries{delegate: , maxTries: }
}
type backOffTries struct {
delegate BackOff
maxTries uint64
numTries uint64
}
func ( *backOffTries) () time.Duration {
if .maxTries == 0 {
return Stop
}
if .maxTries > 0 {
if .maxTries <= .numTries {
return Stop
}
.numTries++
}
return .delegate.NextBackOff()
}
func ( *backOffTries) () {
.numTries = 0
.delegate.Reset()
}
The pages are generated with Golds v0.6.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |