Documentation ¶
Overview ¶
Package limit implements various rate limiters. In the current stage (2023-03-13) limiters can only be used when for waiting until request limits permit operations. In the future, we might add support for limiters that can be used to limit incoming traffic for services.
Because of limitations in the testing process of the rate limiters be aware that the limiter package is currently BETA and can change anytime.
Index ¶
- Constants
- func NewFixedWindowLimiter(backend Incrementer, clock clock.Clock, config FixedWindowConfig, ...) *fixedWindow
- func NewMetricMiddlewareWithInterfaces(metricWriter metric.Writer) *metricMiddleware
- type Factory
- type FixedWindowConfig
- type Incrementer
- type Invocation
- type Limiter
- type LimiterWithMiddleware
- func NewFixedWindowDdb(ctx context.Context, config cfg.Config, logger log.Logger, ...) (LimiterWithMiddleware, error)
- func NewFixedWindowRedis(ctx context.Context, config cfg.Config, logger log.Logger, c FixedWindowConfig) (LimiterWithMiddleware, error)
- func NewFixedWindowRedisWithInterfaces(clock clock.Clock, redis redis.Client, config FixedWindowConfig, ...) LimiterWithMiddleware
- type Middleware
- type MiddlewareFactory
Constants ¶
View Source
const ( MetricNameRateLimitRelease = "rate-limit-release" MetricNameRateLimitTake = "rate-limit-take" MetricNameRateLimitThrottle = "rate-limit-throttle" MetricNameRateLimitError = "rate-limit-error" )
Variables ¶
This section is empty.
Functions ¶
func NewFixedWindowLimiter ¶
func NewFixedWindowLimiter(backend Incrementer, clock clock.Clock, config FixedWindowConfig, builder *invocationBuilder) *fixedWindow
Types ¶
type Incrementer ¶
type Invocation ¶
type Limiter ¶
func NewUnlimited ¶
func NewUnlimited() Limiter
type LimiterWithMiddleware ¶
type LimiterWithMiddleware interface { Limiter WithMiddleware(...MiddlewareFactory) }
func NewFixedWindowDdb ¶
func NewFixedWindowRedis ¶
func NewFixedWindowRedis(ctx context.Context, config cfg.Config, logger log.Logger, c FixedWindowConfig) (LimiterWithMiddleware, error)
func NewFixedWindowRedisWithInterfaces ¶
func NewFixedWindowRedisWithInterfaces(clock clock.Clock, redis redis.Client, config FixedWindowConfig, builder *invocationBuilder) LimiterWithMiddleware
type Middleware ¶
type Middleware interface { OnTake(ctx context.Context, i Invocation) OnRelease(ctx context.Context, i Invocation) OnError(ctx context.Context, i Invocation) OnThrottle(ctx context.Context, i Invocation) }
func ChainMiddleware ¶
func ChainMiddleware(fs ...MiddlewareFactory) Middleware
func NewMetricMiddleware ¶
func NewMetricMiddleware() Middleware
type MiddlewareFactory ¶
type MiddlewareFactory func() Middleware
func NewLoggingMiddleware ¶
func NewLoggingMiddleware(logger log.Logger) MiddlewareFactory
Click to show internal directories.
Click to hide internal directories.