A package for Optimistic Concurrency Control
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”. 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:
- Exponential Backoff
- Fibonacci (TBD)
- Equal Jitter (TBD)
- Full Jitter (TBD)
- Decorr (TBD)
- Custom Backoff (TBD)
- See the AWS Blog on Exponential Backoff and Jitter for more example information on the abovealgorithms
To install backoff, use go get
:
go get github.com/defaltd/backoff
Import the backoff
package into your code using this template:
package main
import (
"fmt"
"backoff"
)
func SayHello() {
service := backoff.New(&backoff.Policy{
Algorithm: backoff.AlgorithmExponential,
})
service.ExecuteAction(func() error { return client.MakeAPICall("Hello World"); })
}
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.