kikinteractive/backoff

Name: backoff

Owner: Kik Interactive

Description: The exponential backoff algorithm in Go (Golang).

Created: 2015-08-11 14:48:07.0

Updated: 2017-05-21 17:21:43.0

Pushed: 2015-08-16 09:10:33.0

Homepage: https://godoc.org/github.com/cenkalti/backoff

Size: 108

Language: Go

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

backoff

GoDoc Build Status

This is a Go port of the exponential backoff algorithm from google-http-java-client.

Exponential backoff is an algorithm that uses feedback to multiplicatively decrease the rate of some process, in order to gradually find an acceptable rate. The retries exponentially increase and stop increasing when a certain threshold is met.

Install
et github.com/cenkalti/backoff
Example

Simple retry helper that uses exponential back-off algorithm:

ation := func() error {
// An operation that might fail


:= backoff.Retry(operation, backoff.NewExponentialBackOff())
rr != nil {
// handle error


peration is successfull

Ticker example:

ation := func() error {
// An operation that may fail


 backoff.NewExponentialBackOff()
er := backoff.NewTicker(b)

err error

icks will continue to arrive when the previous operation is still running,
o operations that take a while to fail could run in quick succession.
t = range ticker.C {
if err = operation(); err != nil {
    log.Println(err, "will retry...")
    continue
}

ticker.Stop()
break


rr != nil {
// Operation has failed.


peration is successfull.

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.