ratelimit

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2016 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrLimited = errors.New("rate limit exceeded")

ErrLimited is returned in the request path when the rate limiter is triggered and the request is rejected.

Functions

func NewTokenBucketLimiter

func NewTokenBucketLimiter(tb *ratelimit.Bucket) endpoint.Middleware

NewTokenBucketLimiter returns an endpoint.Middleware that acts as a rate limiter based on a token-bucket algorithm. Requests that would exceed the maximum request rate are simply rejected with an error.

func NewTokenBucketThrottler

func NewTokenBucketThrottler(tb *ratelimit.Bucket, sleep func(time.Duration)) endpoint.Middleware

NewTokenBucketThrottler returns an endpoint.Middleware that acts as a request throttler based on a token-bucket algorithm. Requests that would exceed the maximum request rate are delayed via the parameterized sleep function. By default you may pass time.Sleep.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL