Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultConfig = Config{
MaxRetries: 10,
}
DefaultConfig is the configuration which is used by default
Functions ¶
This section is empty.
Types ¶
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
// Config returns the Config the rate limiter uses
Config() Config
// 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)
// 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.