Skip to content

Commit 85acf8d

Browse files
committed
rate: remove Go 1.6 support, use std context
This is part of the general cleanup effort now that App Engine requires Go 1.9+. Related: CL 145677, CL 148277, CL 145202, CL 143717, CL 146837. Change-Id: I831415f7484acb823cf8ac20db05a4a001df4c35 Reviewed-on: https://go-review.googlesource.com/c/148417 Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent fbb02b2 commit 85acf8d

File tree

3 files changed

+3
-55
lines changed

3 files changed

+3
-55
lines changed

rate/rate.go

+3-13
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
package rate
77

88
import (
9+
"context"
910
"fmt"
1011
"math"
1112
"sync"
@@ -212,27 +213,16 @@ func (lim *Limiter) ReserveN(now time.Time, n int) *Reservation {
212213
return &r
213214
}
214215

215-
// contextContext is a temporary(?) copy of the context.Context type
216-
// to support both Go 1.6 using golang.org/x/net/context and Go 1.7+
217-
// with the built-in context package. If people ever stop using Go 1.6
218-
// we can remove this.
219-
type contextContext interface {
220-
Deadline() (deadline time.Time, ok bool)
221-
Done() <-chan struct{}
222-
Err() error
223-
Value(key interface{}) interface{}
224-
}
225-
226216
// Wait is shorthand for WaitN(ctx, 1).
227-
func (lim *Limiter) wait(ctx contextContext) (err error) {
217+
func (lim *Limiter) Wait(ctx context.Context) (err error) {
228218
return lim.WaitN(ctx, 1)
229219
}
230220

231221
// WaitN blocks until lim permits n events to happen.
232222
// It returns an error if n exceeds the Limiter's burst size, the Context is
233223
// canceled, or the expected wait time exceeds the Context's Deadline.
234224
// The burst limit is ignored if the rate limit is Inf.
235-
func (lim *Limiter) waitN(ctx contextContext, n int) (err error) {
225+
func (lim *Limiter) WaitN(ctx context.Context, n int) (err error) {
236226
if n > lim.burst && lim.limit != Inf {
237227
return fmt.Errorf("rate: Wait(n=%d) exceeds limiter's burst %d", n, lim.burst)
238228
}

rate/rate_go16.go

-21
This file was deleted.

rate/rate_go17.go

-21
This file was deleted.

0 commit comments

Comments
 (0)