{"repo":"cenkalti/backoff","free":true,"listed":false,"github":"https://github.com/cenkalti/backoff","clone":"git clone https://github.com/cenkalti/backoff.git","description":"⏱ The exponential backoff algorithm in Go","language":"Go","stars":4051,"topics":["golang"],"license":"MIT","category":"api-integrations-sdks","readme_excerpt":"Exponential Backoff [![GoDoc][godoc image]][godoc] This is a Go port of the exponential backoff algorithm from [Google's HTTP Client Library for Java][google-http-java-client]. [Exponential backoff][exponential backoff wiki] 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 Note the /v7 at the end of the import path. Usage For most cases, wrap the operation you want to retry in Retry : Retry runs the operation at least once and keeps retrying with exponential backoff until it succeeds, returns a Permanent error, or a limit is reached. See [example test.go][example] for a fuller example, and the [package docs][godoc] for the available options ( WithBackOff , WithMaxTries , WithMaxElapsedTime , WithNotify ). If Retry does not fit your needs, copy it from [retry.go][retry-src] and adapt it. Handling errors On failure, Retry always returns a RetryError . It carries the last operation error ( LastErr ) and the reason retrying stopped ( Cause ). Inspect it with errors.Is , or reach the struct with AsRetryError : Mark an error non-retriable with backoff.Permanent(err) ; Retry stops immediately and returns a RetryError whose Cause is ErrPermanent and whose LastErr is err . Bounding total time Two independent limits cap how long Retry runs, and they behave differently: - A context deadline ( context.WithT","default_branch":null,"files":null,"tree":[],"storefront":"/r/cenkalti","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/cenkalti/backoff/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}