Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ChooseLimiterCapacity ¶
Choose a limiter capacity that ensures that the action gated by the limiter will be limited to within a few percent of `rateHz * window` for any window of the given size.
This is not be possible for all rates and windows. In that case, an error will be returned.
func NewThrottledBucket ¶
func NewThrottledBucket( opThrottle Throttle, egressThrottle Throttle, wrapped gcs.Bucket) (b gcs.Bucket)
Create a bucket that limits the rate at which it calls the wrapped bucket using opThrottle, and limits the bandwidth with which it reads from the wrapped bucket using egressThrottle.
Types ¶
type Throttle ¶
type Throttle interface { // Return the maximum number of tokens that can be requested in a call to // Wait. Capacity() (c uint64) // Acquire the given number of tokens from the underlying token bucket, then // sleep until when it says to wake. If the context is cancelled before then, // return early with an error. // // REQUIRES: tokens <= capacity Wait(ctx context.Context, tokens uint64) (err error) }
A simple interface for limiting the rate of some event. Unlike TokenBucket, does not allow the user control over what time means.
Safe for concurrent access.
func NewThrottle ¶
Click to show internal directories.
Click to hide internal directories.