Skip to content

Commit

Permalink
remove unnecessary seed
Browse files Browse the repository at this point in the history
Signed-off-by: Lixia (Sylvia) Lei <[email protected]>
  • Loading branch information
Wwwsylvia committed Sep 2, 2024
1 parent 6c86405 commit 62b3113
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions registry/remote/retry/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ type Backoff func(attempt int, resp *http.Response) time.Duration
// value is used as the backoff duration.
func ExponentialBackoff(backoff time.Duration, factor, jitter float64) Backoff {
return func(attempt int, resp *http.Response) time.Duration {
hashSeed := seedFromMapHash()
timeSeed := uint64(time.Now().UnixNano())
rand := rand.New(rand.NewPCG(hashSeed, timeSeed))
var h maphash.Hash
h.SetSeed(maphash.MakeSeed())
rand := rand.New(rand.NewPCG(h.Sum64(), 0))

// check Retry-After
if resp != nil && resp.StatusCode == http.StatusTooManyRequests {
Expand All @@ -113,13 +113,6 @@ func ExponentialBackoff(backoff time.Duration, factor, jitter float64) Backoff {
}
}

// seedFromMapHash returns a seed generated by maphash.
func seedFromMapHash() uint64 {
var h maphash.Hash
h.SetSeed(maphash.MakeSeed())
return h.Sum64()
}

// GenericPolicy is a generic retry policy.
type GenericPolicy struct {
// Retryable is a predicate that returns true if the request should be
Expand Down

0 comments on commit 62b3113

Please sign in to comment.