diff options
| author | 2025-04-28 11:20:24 +0000 | |
|---|---|---|
| committer | 2025-04-28 11:20:24 +0000 | |
| commit | 436765a6a2ddf400b6e06c9a7c3283b1351fcbcd (patch) | |
| tree | c1a0e969c23a74eaca258c709db1776763d576dd /vendor/github.com/minio/minio-go/v7/retry-continous.go | |
| parent | [chore] Update build to use new woodpecker dind container, bump version numbe... (diff) | |
| download | gotosocial-436765a6a2ddf400b6e06c9a7c3283b1351fcbcd.tar.xz | |
bump dependencies: minio-go, go-sqlite3, goldmark, otel, x/image/webp (#4075)
Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4075
Co-authored-by: kim <grufwub@gmail.com>
Co-committed-by: kim <grufwub@gmail.com>
Diffstat (limited to 'vendor/github.com/minio/minio-go/v7/retry-continous.go')
| -rw-r--r-- | vendor/github.com/minio/minio-go/v7/retry-continous.go | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/vendor/github.com/minio/minio-go/v7/retry-continous.go b/vendor/github.com/minio/minio-go/v7/retry-continous.go index 81fcf16f1..21e9fd455 100644 --- a/vendor/github.com/minio/minio-go/v7/retry-continous.go +++ b/vendor/github.com/minio/minio-go/v7/retry-continous.go @@ -17,12 +17,14 @@ package minio -import "time" +import ( + "iter" + "math" + "time" +) // newRetryTimerContinous creates a timer with exponentially increasing delays forever. -func (c *Client) newRetryTimerContinous(baseSleep, maxSleep time.Duration, jitter float64, doneCh chan struct{}) <-chan int { - attemptCh := make(chan int) - +func (c *Client) newRetryTimerContinous(baseSleep, maxSleep time.Duration, jitter float64) iter.Seq[int] { // normalize jitter to the range [0, 1.0] if jitter < NoJitter { jitter = NoJitter @@ -44,26 +46,20 @@ func (c *Client) newRetryTimerContinous(baseSleep, maxSleep time.Duration, jitte if sleep > maxSleep { sleep = maxSleep } - if jitter != NoJitter { + if math.Abs(jitter-NoJitter) > 1e-9 { sleep -= time.Duration(c.random.Float64() * float64(sleep) * jitter) } return sleep } - go func() { - defer close(attemptCh) + return func(yield func(int) bool) { var nextBackoff int for { - select { - // Attempts starts. - case attemptCh <- nextBackoff: - nextBackoff++ - case <-doneCh: - // Stop the routine. + if !yield(nextBackoff) { return } + nextBackoff++ time.Sleep(exponentialBackoffWait(nextBackoff)) } - }() - return attemptCh + } } |
