瀏覽代碼

vendor: golang.org/x/time 3af7569d3a1e776fc2a3c1cec133b43105ea9c2e

full diff: https://github.com/golang/time/compare/555d28b269f0569763d25dbe1a237ae74c6bcc82...3af7569d3a1e776fc2a3c1cec133b43105ea9c2e

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 4 年之前
父節點
當前提交
e1ae2d28fb
共有 2 個文件被更改,包括 8 次插入6 次删除
  1. 1 1
      vendor.conf
  2. 7 5
      vendor/golang.org/x/time/rate/rate.go

+ 1 - 1
vendor.conf

@@ -152,7 +152,7 @@ github.com/cloudflare/cfssl                         5d63dbd981b5c408effbb58c442d
 github.com/fernet/fernet-go                         9eac43b88a5efb8651d24de9b68e87567e029736
 github.com/fernet/fernet-go                         9eac43b88a5efb8651d24de9b68e87567e029736
 github.com/google/certificate-transparency-go       37a384cd035e722ea46e55029093e26687138edf # v1.0.20
 github.com/google/certificate-transparency-go       37a384cd035e722ea46e55029093e26687138edf # v1.0.20
 golang.org/x/crypto                                 0c34fe9e7dc2486962ef9867e3edb3503537209f
 golang.org/x/crypto                                 0c34fe9e7dc2486962ef9867e3edb3503537209f
-golang.org/x/time                                   555d28b269f0569763d25dbe1a237ae74c6bcc82
+golang.org/x/time                                   3af7569d3a1e776fc2a3c1cec133b43105ea9c2e
 github.com/hashicorp/go-memdb                       cb9a474f84cc5e41b273b20c6927680b2a8776ad
 github.com/hashicorp/go-memdb                       cb9a474f84cc5e41b273b20c6927680b2a8776ad
 github.com/hashicorp/go-immutable-radix             826af9ccf0feeee615d546d69b11f8e98da8c8f1 git://github.com/tonistiigi/go-immutable-radix.git
 github.com/hashicorp/go-immutable-radix             826af9ccf0feeee615d546d69b11f8e98da8c8f1 git://github.com/tonistiigi/go-immutable-radix.git
 github.com/hashicorp/golang-lru                     7f827b33c0f158ec5dfbba01bb0b14a4541fd81d # v0.5.3
 github.com/hashicorp/golang-lru                     7f827b33c0f158ec5dfbba01bb0b14a4541fd81d # v0.5.3

+ 7 - 5
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.
 // The methods AllowN, ReserveN, and WaitN consume n tokens.
 type Limiter struct {
 type Limiter struct {
-	limit Limit
-	burst int
-
 	mu     sync.Mutex
 	mu     sync.Mutex
+	limit  Limit
+	burst  int
 	tokens float64
 	tokens float64
 	// last is the last time the limiter's tokens field was updated
 	// last is the last time the limiter's tokens field was updated
 	last time.Time
 	last time.Time
@@ -76,6 +75,8 @@ func (lim *Limiter) Limit() Limit {
 // Burst values allow more events to happen at once.
 // Burst values allow more events to happen at once.
 // A zero Burst allows no events, unless limit == Inf.
 // A zero Burst allows no events, unless limit == Inf.
 func (lim *Limiter) Burst() int {
 func (lim *Limiter) Burst() int {
+	lim.mu.Lock()
+	defer lim.mu.Unlock()
 	return lim.burst
 	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.
 // 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.
 // 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:
 // Usage example:
 //   r := lim.ReserveN(time.Now(), 1)
 //   r := lim.ReserveN(time.Now(), 1)
 //   if !r.OK() {
 //   if !r.OK() {
@@ -229,7 +230,7 @@ func (lim *Limiter) WaitN(ctx context.Context, n int) (err error) {
 	lim.mu.Unlock()
 	lim.mu.Unlock()
 
 
 	if n > burst && limit != Inf {
 	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
 	// Check if ctx is already cancelled
 	select {
 	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.
 // advance calculates and returns an updated state for lim resulting from the passage of time.
 // lim is not changed.
 // 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) {
 func (lim *Limiter) advance(now time.Time) (newNow time.Time, newLast time.Time, newTokens float64) {
 	last := lim.last
 	last := lim.last
 	if now.Before(last) {
 	if now.Before(last) {