Skip to content

Latest commit

 

History

History
31 lines (24 loc) · 878 Bytes

README.md

File metadata and controls

31 lines (24 loc) · 878 Bytes

go-retry

GoDoc

go-retry is a package that helps facilitate retry logic with jittered exponential backoff. It provides a convenient interface for configuring various parameters. See below for more information.

Example

func makeNetworkCall(ctx context.Context) {
    defaultBackoff := retry.DefaultBackoff()

    // try at most 5 times
    getErr := retry.Retry(ctx, defaultBackoff, 5, func(ctx context.Context) error {
        response, err := http.Get("https://my.favorite.service")
        if err != nil {
            return err
        }
        // do something with response...
    })

    if getErr != nil {
        // get failed, even after all the retries
    }
}

Copyright Vimeo.