MCPcopy Index your code
hub / github.com/cloudflare/cloudflared / BackoffTimer

Method BackoffTimer

retry/backoffhandler.go:70–85  ·  view source on GitHub ↗

BackoffTimer returns a channel that sends the current time when the exponential backoff timeout expires. Returns nil if the maximum number of retries have been used.

()

Source from the content-addressed store, hash-verified

68// BackoffTimer returns a channel that sends the current time when the exponential backoff timeout expires.
69// Returns nil if the maximum number of retries have been used.
70func (b *BackoffHandler) BackoffTimer() <-chan time.Time {
71 if !b.resetDeadline.IsZero() && b.Clock.Now().After(b.resetDeadline) {
72 b.retries = 0
73 b.resetDeadline = time.Time{}
74 }
75 if b.retries >= b.maxRetries {
76 if !b.retryForever {
77 return nil
78 }
79 } else {
80 b.retries++
81 }
82 maxTimeToWait := b.GetBaseTime() * (1 << b.retries)
83 timeToWait := time.Duration(rand.Int63n(maxTimeToWait.Nanoseconds())) // #nosec G404
84 return b.Clock.After(timeToWait)
85}
86
87// Backoff is used to wait according to exponential backoff. Returns false if the
88// maximum number of retries have been used or if the underlying context has been cancelled.

Callers 4

BackoffMethod · 0.95
RunMethod · 0.80
ServeMethod · 0.80

Calls 3

GetBaseTimeMethod · 0.95
IsZeroMethod · 0.80
DurationMethod · 0.80

Tested by 1