Skip to content

vimeo/go-retry

Folders and files

NameName
Last commit message
Last commit date
Mar 5, 2025
Feb 12, 2020
Feb 12, 2020
Sep 14, 2020
Feb 13, 2020
Feb 12, 2020
Mar 5, 2025
Mar 5, 2025
Aug 12, 2022
Aug 12, 2022
Mar 5, 2025
Aug 12, 2022
Aug 12, 2022
Sep 29, 2020

Repository files navigation

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.