Skip to content

Latest commit

 

History

History
33 lines (24 loc) · 591 Bytes

File metadata and controls

33 lines (24 loc) · 591 Bytes

PkgGoDev

Backoff

This package provides a retry mechanism for functions.

The API is very minimalistic, yet gives options for customization.

Usage

package main

import (
    "fmt"
    "time"

    "github.com/krhubert/backoff"
)

func fn() (string, error) {
    return "out", nil
}

func main() {
    out, err := backoff.Retry2(context.Background(), fn)
    if err != nil {
        fmt.Fprint(os.Stderr, "Failed", err)
        os.Exit(1)
    }
    fmt.Println(out)
}