Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
Config is the configuration for the rate limiter
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig is the configuration which is used by default
type ConfigOpt ¶
type ConfigOpt func(config *Config)
ConfigOpt can be used to supply optional parameters to NewLimiter
func WithLogger ¶
WithLogger applies a custom logger to the rest rate limiter
func WithMaxRetries ¶
WithMaxRetries tells the rest rate limiter to retry the request up to the specified number of times if it encounters a 429 response
type Limiter ¶
type Limiter interface { // Logger returns the logger the rate limiter uses Logger() log.Logger // MaxRetries returns the maximum number of retries the client should do MaxRetries() int // Close closes the rate limiter and awaits all pending requests to finish. You can use a cancelling context to abort the waiting Close(ctx context.Context) // Reset resets the rate limiter to its initial state Reset() // WaitBucket waits for the given bucket to be available for new requests & locks it WaitBucket(ctx context.Context, route *route.CompiledAPIRoute) error // UnlockBucket unlocks the given bucket and calculates the rate limit for the next request UnlockBucket(route *route.CompiledAPIRoute, headers http.Header) error }
Limiter can be used to supply your own rate limit implementation
func NewLimiter ¶
NewLimiter return a new default implementation of a rest rate limiter
Click to show internal directories.
Click to hide internal directories.