ratelimit

package
v0.0.0-...-572ac14 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2014 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const Type = "ratelimit"

Variables

This section is empty.

Functions

func CliFlags

func CliFlags() []cli.Flag

func FromCli

func FromCli(c *cli.Context) (plugin.Middleware, error)

Constructs the middleware from the command line

func FromOther

func FromOther(rate RateLimit) (plugin.Middleware, error)

func GetSpec

func GetSpec() *plugin.MiddlewareSpec

Spec is an entry point of a plugin and will be called to register this middleware plugin withing vulcand

Types

type RateLimit

type RateLimit struct {
	PeriodSeconds int    // Period in seconds, e.g. 3600 to set up hourly rates
	Burst         int64  // Burst count, allowes some extra variance for requests exceeding the average rate
	Variable      string // Variable defines how the limiting should be done. e.g. 'client.ip' or 'request.header.X-My-Header'
	Requests      int    // Allowed average requests
}

Rate controls how many requests per period of time is allowed for a location. Existing implementation is based on the token bucket algorightm http://en.wikipedia.org/wiki/Token_bucket

func NewRateLimit

func NewRateLimit(requests int, variable string, burst int64, periodSeconds int) (*RateLimit, error)

func (*RateLimit) NewMiddleware

func (r *RateLimit) NewMiddleware() (middleware.Middleware, error)

Returns vulcan library compatible middleware

func (*RateLimit) String

func (rl *RateLimit) String() string

Jump to

Keyboard shortcuts

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