Skip to content

Commit

Permalink
Clarify that it is safe for concurrency
Browse files Browse the repository at this point in the history
  • Loading branch information
flowchartsman committed May 15, 2018
1 parent d2f827b commit 775f1a7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

**retry** is a simple retrier for golang with exponential backoff and context support.

It exists mainly because I found the other libraries either too heavy in implementation or too tedious to use. **retry** is simple and opinionated; it retries your code with an expoential backoff and it lets you bail early. It does not implement constant backoff or any alternative jitter schemes.
It exists mainly because I found the other libraries either too heavy in implementation or too tedious to use. **retry** is simple and opinionated; it retries your code with an expoential backoff and it lets you bail early. It does not implement constant backoff or any alternative jitter schemes. Retrier objects are intended to be re-used, which means you define them once and then run functions with them whenever you want, as many times as you want. It is safe for concurrent use.

If you're mostly doing HTTP work and you are comfortable with the requirements of converting everything to *io.ReadSeeker*, I highly recommend [hashicorp/go-retryablehttp](https://github.com/hashicorp/go-retryablehttp) (which I didn't use because I didn't want to cache my large POSTs) or [facebookgo/httpcontrol](https://github.com/facebookgo/httpcontrol) (which I didn't use because it only retries GETs).

Expand Down
3 changes: 2 additions & 1 deletion retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ const (
)

// Retrier retries code blocks with or without context using an exponential
// backoff algorithm with jitter
// backoff algorithm with jitter. It is intended to be used as a retry policy,
// which means it is safe to create and use concurrently.
type Retrier struct {
maxTries int
initialDelay int
Expand Down

0 comments on commit 775f1a7

Please sign in to comment.