Skip to content

Commit e3e2be9

Browse files
authored
Merge pull request #18 from codeGROOVE-dev/master
README improvements
2 parents 34331e7 + 205c444 commit e3e2be9

File tree

1 file changed

+21
-23
lines changed

1 file changed

+21
-23
lines changed

README.md

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@
55
[![Go Report Card](https://goreportcard.com/badge/github.com/codeGROOVE-dev/retry?style=flat-square)](https://goreportcard.com/report/github.com/codeGROOVE-dev/retry)
66
[![Go Reference](https://pkg.go.dev/badge/github.com/codeGROOVE-dev/retry.svg)](https://pkg.go.dev/github.com/codeGROOVE-dev/retry)
77

8-
**Zero dependencies. Memory-bounded. No goroutine leaks. No panics.**
9-
10-
*Hard guarantees: Bounded memory (1000 errors max). No allocations in hot path. Context-aware cancellation.*
11-
12-
Actively maintained fork of [avast/retry-go](https://github.com/avast/retry-go) focused on correctness and resource efficiency. 100% API compatible drop-in replacement.
8+
Modern fork of [avast/retry-go/v4](https://github.com/avast/retry-go) focused on correctness, reliability and efficiency. 100% API-compatible drop-in replacement.
139

1410
**Production guarantees:**
1511
- Memory bounded: Max 1000 errors stored (configurable via maxErrors constant)
@@ -22,6 +18,12 @@ Actively maintained fork of [avast/retry-go](https://github.com/avast/retry-go)
2218

2319
## Quick Start
2420

21+
### Installation
22+
23+
```bash
24+
go get github.com/codeGROOVE-dev/retry
25+
```
26+
2527
### Simple Retry
2628

2729
```go
@@ -86,31 +88,27 @@ retry.AttemptsForError(1, sql.ErrTxDone) // One retry for tx errors
8688
retry.AttemptsForError(5, ErrServiceUnavailable) // More retries for 503s
8789
```
8890

89-
## Failure Modes & Limits
91+
## Changes from avast/retry-go/v4
9092

91-
| Scenario | Behavior | Limit |
92-
|----------|----------|-------|
93-
| Error accumulation | Old errors dropped after limit | 1000 errors |
94-
| Attempt overflow | Stops retrying | uint max (~4B) |
95-
| Backoff overflow | Capped at max duration | 2^62 ns |
96-
| Context cancelled | Returns immediately | No retries |
97-
| Timer returns nil | Returns error | Fail safe |
98-
| Panic in retryable func | Propagates panic | No swallowing |
93+
This fork will always be a 100% compatible drop-in replacement. There are some minor tweaks that have been made though:
9994

100-
## Installation
95+
New APIs added:
10196

102-
Requires Go 1.22 or higher.
97+
- `UntilSucceeded() Option` - Convenience wrapper for Attempts(0) (infinite retries)
98+
- `FullJitterBackoffDelay() Strategy` - New delay type with full jitter exponential backoff
99+
- `WrapContextErrorWithLastError() Option` - Wraps context errors with last function error
100+
- `IfFunc Type` - New stutter-proof name (RetryIfFunc is now an alias)
103101

104-
```bash
105-
go get github.com/codeGROOVE-dev/retry
106-
```
102+
Safety improvements:
103+
104+
- Memory bounded: Max 1000 errors (prevents OOM)
105+
- Uses `math/rand/v2` (no lock contention)
106+
- Overflow protection: Backoff capped at 2^62
107+
- Enhanced validation and nil checks
108+
- Better context cancellation with `context.Cause()`
107109

108110
## Documentation
109111

110112
- [API Docs](https://pkg.go.dev/github.com/codeGROOVE-dev/retry)
111113
- [Examples](https://github.com/codeGROOVE-dev/retry/tree/master/examples)
112114
- [Tests](https://github.com/codeGROOVE-dev/retry/tree/master/retry_test.go)
113-
114-
---
115-
116-
*Production retry logic that just works.*

0 commit comments

Comments
 (0)