https://github.com/stephnr/backoff
Multiple backoff algorithms exposed as a service in Go (Golang)
https://github.com/stephnr/backoff
backoff golang
Last synced: about 1 year ago
JSON representation
Multiple backoff algorithms exposed as a service in Go (Golang)
- Host: GitHub
- URL: https://github.com/stephnr/backoff
- Owner: stephnr
- License: mit
- Created: 2018-04-29T08:53:17.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-01T17:37:23.000Z (about 8 years ago)
- Last Synced: 2025-02-06T04:14:01.884Z (over 1 year ago)
- Topics: backoff, golang
- Language: Go
- Size: 16.6 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Backoff
 [](https://coveralls.io/github/defaltd/backoff?branch=master) [](https://godoc.org/github.com/defaltd/backoff) [](https://goreportcard.com/report/github.com/defaltd/backoff)
A package for Optimistic Concurrency Control
## Summary
This project is an improvement of the backoff package implemented by cenkalti/backoff. This package provides support for various other backoff algorithms and exposes them in a service-like fashion for use.
Backoff Algorithms such as Exponential Backoff are all part of a branch of computer science known as [“Optimistic Concurrency Control”](https://en.wikipedia.org/wiki/Optimistic_concurrency_control). The focus of these algorithms is to use feedback cycles and process staggering to determine an acceptable time at which a process can successfully complete its intended goal.
Supported Algorithms:
- [x] [Exponential Backoff](https://en.wikipedia.org/wiki/Exponential_backoff)
- [ ] Fibonacci (TBD)
- [ ] Equal Jitter (TBD)
- [ ] Full Jitter (TBD)
- [ ] Decorr (TBD)
- [ ] Custom Backoff (TBD)
* See the AWS Blog on [Exponential Backoff and Jitter](https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/) for more example information on the abovealgorithms
# Installation & Usage
To install backoff, use `go get`:
```
go get github.com/defaltd/backoff
```
Import the `backoff` package into your code using this template:
```go
package main
import (
"fmt"
"backoff"
)
func SayHello() {
service := backoff.New(&backoff.Policy{
Algorithm: backoff.AlgorithmExponential,
})
service.ExecuteAction(func() error { return client.MakeAPICall("Hello World"); })
}
```
# Contributing
Please feel free to contribute by submitting issues, fork the repository and send pull requests!
When submitting an issue, we ask that you please include a complete test function that demonstrates the issue.