From 6d25af0cd7389b31d2d2d9f244eb38779e1b912b Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Mon, 21 Jun 2021 12:12:24 +0200 Subject: [PATCH] vendor: golang.org/x/time 3af7569d3a1e776fc2a3c1cec133b43105ea9c2e full diff: https://github.com/golang/time/compare/555d28b269f0569763d25dbe1a237ae74c6bcc82...3af7569d3a1e776fc2a3c1cec133b43105ea9c2e Signed-off-by: Sebastiaan van Stijn --- vendor.conf | 2 +- vendor/golang.org/x/time/rate/rate.go | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/vendor.conf b/vendor.conf index 14c02566c8..ef2b99b618 100755 --- a/vendor.conf +++ b/vendor.conf @@ -82,7 +82,7 @@ golang.org/x/sync 036812b2e83c0ddf193dd5a34e03 golang.org/x/sys d19ff857e887eacb631721f188c7d365c2331456 golang.org/x/term f5c789dd3221ff39d752ac54467d762de7cfbec6 golang.org/x/text 23ae387dee1f90d29a23c0e87ee0b46038fbed0e # v0.3.3 -golang.org/x/time 555d28b269f0569763d25dbe1a237ae74c6bcc82 +golang.org/x/time 3af7569d3a1e776fc2a3c1cec133b43105ea9c2e google.golang.org/genproto 3f1135a288c9a07e340ae8ba4cc6c7065a3160e8 google.golang.org/grpc f495f5b15ae7ccda3b38c53a1bfcde4c1a58a2bc # v1.27.1 gopkg.in/inf.v0 d2d2541c53f18d2a059457998ce2876cc8e67cbf # v0.9.1 diff --git a/vendor/golang.org/x/time/rate/rate.go b/vendor/golang.org/x/time/rate/rate.go index 563f70429a..a98fe77827 100644 --- a/vendor/golang.org/x/time/rate/rate.go +++ b/vendor/golang.org/x/time/rate/rate.go @@ -53,10 +53,9 @@ func Every(interval time.Duration) Limit { // // The methods AllowN, ReserveN, and WaitN consume n tokens. type Limiter struct { - limit Limit - burst int - mu sync.Mutex + limit Limit + burst int tokens float64 // last is the last time the limiter's tokens field was updated last time.Time @@ -76,6 +75,8 @@ func (lim *Limiter) Limit() Limit { // Burst values allow more events to happen at once. // A zero Burst allows no events, unless limit == Inf. func (lim *Limiter) Burst() int { + lim.mu.Lock() + defer lim.mu.Unlock() return lim.burst } @@ -196,7 +197,7 @@ func (lim *Limiter) Reserve() *Reservation { // ReserveN returns a Reservation that indicates how long the caller must wait before n events happen. // The Limiter takes this Reservation into account when allowing future events. -// ReserveN returns false if n exceeds the Limiter's burst size. +// The returned Reservation’s OK() method returns false if n exceeds the Limiter's burst size. // Usage example: // r := lim.ReserveN(time.Now(), 1) // if !r.OK() { @@ -229,7 +230,7 @@ func (lim *Limiter) WaitN(ctx context.Context, n int) (err error) { lim.mu.Unlock() if n > burst && limit != Inf { - return fmt.Errorf("rate: Wait(n=%d) exceeds limiter's burst %d", n, lim.burst) + return fmt.Errorf("rate: Wait(n=%d) exceeds limiter's burst %d", n, burst) } // Check if ctx is already cancelled select { @@ -359,6 +360,7 @@ func (lim *Limiter) reserveN(now time.Time, n int, maxFutureReserve time.Duratio // advance calculates and returns an updated state for lim resulting from the passage of time. // lim is not changed. +// advance requires that lim.mu is held. func (lim *Limiter) advance(now time.Time) (newNow time.Time, newLast time.Time, newTokens float64) { last := lim.last if now.Before(last) {