rename worker Backoff const cap_ → maxDelay
- SHA
98861741a2d3ac4564793afb81a26879b7b77921- Parents
-
b6ae85d - Tree
5a2f0a1
9886174
98861741a2d3ac4564793afb81a26879b7b77921b6ae85d
5a2f0a1| Status | File | + | - |
|---|---|---|---|
| M |
internal/worker/types.go
|
6 | 6 |
internal/worker/types.gomodified@@ -108,20 +108,20 @@ func Backoff(attempts int, jitter func() float64) time.Duration { | ||
| 108 | 108 | attempts = 1 |
| 109 | 109 | } |
| 110 | 110 | const ( |
| 111 | - base = 30 * time.Second | |
| 112 | - cap_ = time.Hour | |
| 111 | + base = 30 * time.Second | |
| 112 | + maxDelay = time.Hour | |
| 113 | 113 | ) |
| 114 | 114 | // Compute base * 2^(attempts-1), guarding against overflow. |
| 115 | 115 | d := base |
| 116 | 116 | for i := 1; i < attempts; i++ { |
| 117 | 117 | d *= 2 |
| 118 | - if d >= cap_ { | |
| 119 | - d = cap_ | |
| 118 | + if d >= maxDelay { | |
| 119 | + d = maxDelay | |
| 120 | 120 | break |
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | - if d > cap_ { | |
| 124 | - d = cap_ | |
| 123 | + if d > maxDelay { | |
| 124 | + d = maxDelay | |
| 125 | 125 | } |
| 126 | 126 | if jitter != nil { |
| 127 | 127 | // jitter() in [0,1) → multiplier in [0.8, 1.2) |