Debian Codegraph @

retrier/README.md

raw
1 retrier
2 =======
3
4 [![Golang CI](https://github.com/eapache/go-resiliency/actions/workflows/golang-ci.yml/badge.svg)](https://github.com/eapache/go-resiliency/actions/workflows/golang-ci.yml)
5 [![GoDoc](https://godoc.org/github.com/eapache/go-resiliency/retrier?status.svg)](https://godoc.org/github.com/eapache/go-resiliency/retrier)
6 [![Code of Conduct](https://img.shields.io/badge/code%20of%20conduct-active-blue.svg)](https://eapache.github.io/conduct.html)
7
8 The retriable resiliency pattern for golang.
9
10 Creating a retrier takes two parameters:
11 - the times to back-off between retries (and implicitly the number of times to
12 retry)
13 - the classifier that determines which errors to retry
14
15 ```go
16 r := retrier.New(retrier.ConstantBackoff(3, 100*time.Millisecond), nil)
17
18 err := r.Run(func() error {
19 // do some work
20 return nil
21 })
22
23 if err != nil {
24 // handle the case where the work failed three times
25 }
26 ```