https://github.com/matthewpi/backoff
Context-aware exponential backoff
https://github.com/matthewpi/backoff
backoff context exponential go golang
Last synced: about 1 year ago
JSON representation
Context-aware exponential backoff
- Host: GitHub
- URL: https://github.com/matthewpi/backoff
- Owner: matthewpi
- License: mit
- Created: 2024-05-08T20:19:49.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-05-15T19:20:57.000Z (about 2 years ago)
- Last Synced: 2025-01-23T10:44:19.539Z (over 1 year ago)
- Topics: backoff, context, exponential, go, golang
- Language: Go
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Backoff
[![Godoc Reference][pkg.go.dev_img]][pkg.go.dev]
[![Pipeline Status][pipeline_img ]][pipeline ]
Go package that provides a context-aware exponential backoff.
[pkg.go.dev]: https://pkg.go.dev/github.com/matthewpi/backoff
[pkg.go.dev_img]: https://img.shields.io/badge/%E2%80%8B-reference-007d9c?logo=go&logoColor=white&style=flat-square
[pipeline]: https://github.com/matthewpi/backoff/actions/workflows/test.yml
[pipeline_img]: https://img.shields.io/github/actions/workflow/status/matthewpi/backoff/ci.yaml?style=flat-square&label=tests
## Usage
```go
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`](./example_test.go)
## Installation
```bash
go get github.com/matthewpi/backoff
```