{"repo":"avast/retry-go","free":true,"listed":false,"github":"https://github.com/avast/retry-go","clone":"git clone https://github.com/avast/retry-go.git","description":"Simple golang library for retry mechanism","language":"Go","stars":2950,"topics":["golang","go","retry","retry-library","hacktoberfest"],"license":"MIT","category":"dev-tools","readme_excerpt":"retry Simple library for retry mechanism Slightly inspired by Try::Tiny::Retry SYNOPSIS HTTP GET with retry: url := \"http://example.com\" var body []byte err := retry.New( retry.Attempts(5), retry.Delay(100 time.Millisecond), ).Do( func() error { resp, err := http.Get(url) if err != nil { return err } defer resp.Body.Close() body, err = ioutil.ReadAll(resp.Body) if err != nil { return err } return nil }, ) if err != nil { // handle error } fmt.Println(string(body)) HTTP GET with retry with data: url := \"http://example.com\" body, err := retry.DoWithData(retry.New(), func() ([]byte, error) { resp, err := http.Get(url) if err != nil { return nil, err } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { return nil, err } return body, nil }, ) if err != nil { // handle error } fmt.Println(string(body)) Reusable retrier for high-frequency retry operations: // Create retrier once, reuse many times retrier := retry.New( retry.Attempts(5), retry.Delay(100 time.Millisecond), ) // Minimal allocations in happy path for { err := retrier.Do( func() error { return doWork() }, ) if err != nil { // handle error } } More examples SEE ALSO codeGROOVE-dev/retry - Modern fork of avast/retry-go/v4 focused on correctness, reliability and efficiency. 100% API-compatible drop-in replacement. Looks really good. giantswarm/retry-go - slightly complicated interface. sethgrid/pester - only http retry for http calls with retries and backoff cenkalti/backoff - Go port of the expo","default_branch":null,"files":null,"tree":[],"storefront":"/r/avast","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/avast/retry-go/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."}