ratelimit

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2017 License: BSD-3-Clause Imports: 4 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrTooManyRequests

type ErrTooManyRequests struct {
	Cooloff time.Duration
}

func (*ErrTooManyRequests) Error

func (e *ErrTooManyRequests) Error() string

type Provider

type Provider interface {
	// Limit returns the policy based rate limit for the given actor performing the action on the path.
	Limit(actor, action, path string) (RateLimit, error)
	// Allow returns true if the rate limit policy allows the given actor to perform the action on the path.
	Allow(actor, action, path string) (bool, error)
	Ping() error
	Close()
}

type RateLimit

type RateLimit struct {
	Limit  int
	Period time.Duration
}

RateLimit encodes a maximum number of repititions allowed over a time interval.

func FromString

func FromString(value string) (r RateLimit, err error)

FromString parses a rate limit string in the form of "<limit>/<duration>".

func (RateLimit) String

func (r RateLimit) String() string

Jump to

Keyboard shortcuts

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