-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https://golang.org/cl/41194 updatd the x/time/rate package to use the standard library's context package for golang/go#16745 but App Engine is stuck 14 months in the past and can only run Go 1.6, which lacks context. This CL restores Go 1.6 support. The Go build system stopped testing packages against Go 1.6 once Go 1.8 came out, so just disable the tests for Go 1.6 rather than jumping through hoops to make them work. Change-Id: I271dcd492dd0ca53961340d63b26facb5dbdf025 Reviewed-on: https://go-review.googlesource.com/41624 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Chris Broadfoot <cbro@golang.org>
- Loading branch information
Showing
4 changed files
with
60 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright 2017 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// +build !go1.7 | ||
|
||
package rate | ||
|
||
import "golang.org/x/net/context" | ||
|
||
// Wait is shorthand for WaitN(ctx, 1). | ||
func (lim *Limiter) Wait(ctx context.Context) (err error) { | ||
return lim.waitN(ctx, 1) | ||
} | ||
|
||
// WaitN blocks until lim permits n events to happen. | ||
// It returns an error if n exceeds the Limiter's burst size, the Context is | ||
// canceled, or the expected wait time exceeds the Context's Deadline. | ||
func (lim *Limiter) WaitN(ctx context.Context, n int) (err error) { | ||
return lim.waitN(ctx, n) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright 2017 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// +build go1.7 | ||
|
||
package rate | ||
|
||
import "context" | ||
|
||
// Wait is shorthand for WaitN(ctx, 1). | ||
func (lim *Limiter) Wait(ctx context.Context) (err error) { | ||
return lim.waitN(ctx, 1) | ||
} | ||
|
||
// WaitN blocks until lim permits n events to happen. | ||
// It returns an error if n exceeds the Limiter's burst size, the Context is | ||
// canceled, or the expected wait time exceeds the Context's Deadline. | ||
func (lim *Limiter) WaitN(ctx context.Context, n int) (err error) { | ||
return lim.waitN(ctx, n) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters