You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Zero dependencies. Memory-bounded. No goroutine leaks. No panics.**
9
9
10
-
*Because 99.99% uptime means your retry logic can't be the failure point.*
10
+
*Hard guarantees: Bounded memory (1000 errors max). No allocations in hot path. Context-aware cancellation.*
11
11
12
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.
13
13
14
-
**Key improvements:**
15
-
- ⚡ Zero external dependencies
16
-
- 🔒 Memory-bounded error accumulation
17
-
- 🛡️ Integer overflow protection in backoff
18
-
- 🎯 Enhanced readability and debuggability
19
-
- 📊 Predictable behavior under load
14
+
**Production guarantees:**
15
+
- Memory bounded: Max 1000 errors stored (configurable via maxErrors constant)
16
+
- No goroutine leaks: Uses caller's goroutine exclusively
17
+
- Integer overflow safe: Backoff capped at 2^62 to prevent wraparound
18
+
- Context-aware: Cancellation checked before each attempt
19
+
- No panics: All edge cases return errors
20
+
- Predictable jitter: Uses math/rand/v2 for consistent performance
21
+
- Zero allocations after init in success path
20
22
21
23
## Quick Start
22
24
23
-
### Basic Retry with Error Handling
25
+
### Simple Retry
24
26
25
27
```go
26
-
import (
27
-
"net/http"
28
-
"github.com/codeGROOVE-dev/retry-go"
29
-
)
28
+
// Retry a flaky operation up to 10 times (default)
29
+
err:= retry.Do(func() error {
30
+
returndoSomethingFlaky()
31
+
})
32
+
```
30
33
31
-
// Retry API call with exponential backoff + jitter
**[matryer/try](https://github.com/matryer/try)** - Popular but non-standard API, missing production features.
125
-
126
-
**[rafaeljesus/retry-go](https://github.com/rafaeljesus/retry-go)** - Similar design but lacks error-specific limits and comprehensive context handling.
127
-
128
-
**This fork** builds on avast/retry-go's solid foundation with correctness fixes and resource optimizations.
91
+
| Scenario | Behavior | Limit |
92
+
|----------|----------|-------|
93
+
| Error accumulation | Old errors dropped after limit | 1000 errors |
0 commit comments