-
Notifications
You must be signed in to change notification settings - Fork 654
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
39 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"id": "df6f67ad-cf63-4eb4-8c3c-35f3cc763f09", | ||
"type": "feature", | ||
"description": "Add no-op rate limiting implementation `ratelimit.None`, which allows disabling of client-side retry quota behavior.", | ||
"modules": [ | ||
"." | ||
] | ||
} |
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,20 @@ | ||
package ratelimit | ||
|
||
import "context" | ||
|
||
// None implements a no-op rate limiter which effectively disables client-side | ||
// rate limiting (also known as "retry quotas"). | ||
// | ||
// GetToken does nothing and always returns a nil error. The returned | ||
// token-release function does nothing, and always returns a nil error. | ||
// | ||
// AddTokens does nothing and always returns a nil error. | ||
var None = &none{} | ||
|
||
type none struct{} | ||
|
||
func (*none) GetToken(ctx context.Context, cost uint) (func() error, error) { | ||
return func() error { return nil }, nil | ||
} | ||
|
||
func (*none) AddTokens(v uint) error { return nil } |
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