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 NewDelayingLimiter Uses

func NewDelayingLimiter(limit Waiter) endpoint.Middleware

NewDelayingLimiter returns an endpoint.Middleware that acts as a request throttler. Requests that would exceed the maximum request rate are delayed via the Waiter function

func NewErroringLimiter Uses

func NewErroringLimiter(limit Allower) endpoint.Middleware

NewErroringLimiter returns an endpoint.Middleware that acts as a rate limiter. Requests that would exceed the maximum request rate are simply rejected with an error.

type Allower Uses

type Allower interface {
    Allow() bool
}

Allower dictates whether or not a request is acceptable to run. The Limiter from "golang.org/x/time/rate" already implements this interface, one is able to use that in NewErroringLimiter without any modifications.

type AllowerFunc Uses

type AllowerFunc func() bool

AllowerFunc is an adapter that lets a function operate as if it implements Allower

func (AllowerFunc) Allow Uses

func (f AllowerFunc) Allow() bool

Allow makes the adapter implement Allower

type Waiter Uses

type Waiter interface {
    Wait(ctx context.Context) error
}

Waiter dictates how long a request must be delayed. The Limiter from "golang.org/x/time/rate" already implements this interface, one is able to use that in NewDelayingLimiter without any modifications.

type WaiterFunc Uses

type WaiterFunc func(ctx context.Context) error

WaiterFunc is an adapter that lets a function operate as if it implements Waiter

func (WaiterFunc) Wait Uses

func (f WaiterFunc) Wait(ctx context.Context) error

Wait makes the adapter implement Waiter

Package ratelimit imports 3 packages (graph) and is imported by 21 packages. Updated 2017-10-22. Refresh now. Tools for package owners.