ratelimit

package
v0.8.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2015 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromCli

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

FromCli constructs a middleware instance from the command line parameters.

func FromOther

func FromOther(o 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 {
	// Period in seconds, e.g. 3600 to set up hourly rates
	PeriodSeconds int64
	// Allowed average requests
	Requests int64
	// Burst count, allowes some extra variance for requests exceeding the average rate
	Burst int64
	// Variable defines how the limiting should be done. e.g. 'client.ip' or 'request.header.X-My-Header'
	Variable string
	// RateVar defines the source of rates configuration that should be used to
	// process a particular request. E.g. 'request.header.X-Rates'
	RateVar string
	// contains filtered or unexported fields
}

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 (*RateLimit) NewHandler

func (r *RateLimit) NewHandler(next http.Handler) (http.Handler, 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