kit: github.com/go-kit/kit/ratelimit Index | Files

package ratelimit

import "github.com/go-kit/kit/ratelimit"

Index

Package Files

token_bucket.go

Variables

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.

func NewTokenBucketLimiter Uses

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 Uses

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.

Package ratelimit imports 5 packages (graph) and is imported by 10 packages. Updated 2017-03-04. Refresh now. Tools for package owners.