MCPcopy Index your code
hub / github.com/dgraph-io/dgraph / ExponentialRetry

Function ExponentialRetry

x/x.go:628–641  ·  view source on GitHub ↗

ExponentialRetry runs the given function until it succeeds or can no longer be retried.

(maxRetries int, waitAfterFailure time.Duration,
	f func() error)

Source from the content-addressed store, hash-verified

626
627// ExponentialRetry runs the given function until it succeeds or can no longer be retried.
628func ExponentialRetry(maxRetries int, waitAfterFailure time.Duration,
629 f func() error) error {
630 var err error
631 for retry := maxRetries; retry > 0; retry-- {
632 if err = f(); err == nil {
633 return nil
634 }
635 if waitAfterFailure > 0 {
636 time.Sleep(waitAfterFailure)
637 waitAfterFailure *= 2
638 }
639 }
640 return err
641}
642
643// RetryUntilSuccess runs the given function until it succeeds or can no longer be retried.
644func RetryUntilSuccess(maxRetries int, waitAfterFailure time.Duration,

Callers 2

commitOrAbortMethod · 0.92
RunWithoutTempMethod · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected