From 775f1a77ea4a38f329b2c06872ef35c7c65aa77f Mon Sep 17 00:00:00 2001 From: Andy Walker Date: Mon, 14 May 2018 23:55:19 -0400 Subject: [PATCH] Clarify that it is safe for concurrency --- README.md | 2 +- retry.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d1ab3e8..403f9eb 100644 --- a/README.md +++ b/README.md @@ -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). diff --git a/retry.go b/retry.go index b43a072..02cc990 100644 --- a/retry.go +++ b/retry.go @@ -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