ratelimiter

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

README

ratelimiter

-- import "github.com/Clever/sphinx/ratelimiter"

Usage

var NilStatus = Status{
	Capacity:  1,
	Reset:     time.Now(),
	Remaining: 1,
	Name:      "Unknown",
}

NilStatus for when acting as passive proxy

type RateLimiter
type RateLimiter interface {
	Add(request common.Request) ([]Status, error)
}

RateLimiter rate limits requests based on given configuration and limits.

func New
func New(config config.Config) (RateLimiter, error)

New returns a new RateLimiter based on the given configuration.

type Status
type Status struct {
	Capacity  uint
	Reset     time.Time
	Remaining uint
	Name      string
}

Status contains the status of a limit.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NilStatus = Status{
	Capacity:  1,
	Reset:     time.Now(),
	Remaining: 1,
	Name:      "Unknown",
}

NilStatus for when acting as passive proxy

Functions

This section is empty.

Types

type RateLimiter

type RateLimiter interface {
	Add(request common.Request) ([]Status, error)
}

RateLimiter rate limits requests based on given configuration and limits.

func New

func New(config config.Config) (RateLimiter, error)

New returns a new RateLimiter based on the given configuration.

type Status

type Status struct {
	Capacity  uint
	Reset     time.Time
	Remaining uint
	Name      string
}

Status contains the status of a limit.

Jump to

Keyboard shortcuts

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