Skip to content

Context-aware exponential backoff

License

Notifications You must be signed in to change notification settings

matthewpi/backoff

Repository files navigation

Backoff

Godoc Reference Pipeline Status

Go package that provides a context-aware exponential backoff.

Usage

b := backoff.New(3, 2, 1*time.Second, 5*time.Second)

// Avoid generating a new context every time Next is called.
ctx := context.Background()
for b.Next(ctx) {
  // Do something.
  //
  // break if successful, continue on failure
}

ref; example_test.go

Installation

go get github.com/matthewpi/backoff