ratelimit

package
v0.0.0-...-e5281c0 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2013 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicRateLimiter

type BasicRateLimiter struct {
	Backend backend.Backend
}

func (*BasicRateLimiter) GetRetrySeconds

func (rl *BasicRateLimiter) GetRetrySeconds(rates map[string][]*command.Rate) (retrySeconds int, err error)

Checks whether any of the given rates

func (*BasicRateLimiter) UpdateStats

func (rl *BasicRateLimiter) UpdateStats(requestBytes int64, rates map[string][]*command.Rate) error

type RateLimiter

type RateLimiter interface {
	// This function checks if any of the rates is exceeded, in case if any of the rates is
	// exceeded, returns positive retry seconds specifying when it would make sense to retry.
	// Note that retry seconds does not guarantee that request will succeed after given seconds,
	// it just guarantiees that request would not succeed if tried before the given amount of seconds.
	// This is more a convenience for clients, so they can stop wasting excessive cycles.
	GetRetrySeconds(rates map[string][]*command.Rate) (retrySeconds int, err error)
	// Update stats within internal backend
	UpdateStats(requestBytes int64, rates map[string][]*command.Rate) error
}

Limits the requests based on stats stored in the backend, updates the stats

Jump to

Keyboard shortcuts

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