ratelimit

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2021 License: MIT Imports: 3 Imported by: 56

README

Ratelimit

Algorithms

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrLimitExceed is returned when the rate limiter is
	// triggered and the request is rejected due to limit exceeded.
	ErrLimitExceed = errors.New("rate limit exceeded")
)

Functions

This section is empty.

Types

type Done

type Done func(DoneInfo)

Done is done function.

type DoneInfo

type DoneInfo struct {
	Err error
}

DoneInfo is done info.

type Group

type Group struct {
	New func() Limiter
	// contains filtered or unexported fields
}

Group .

func (*Group) Do

func (g *Group) Do(name string, fn func() error, fbs ...func(error) error) error

Do runs your function in a synchronous manner, blocking until either your function succeeds or an error is returned, including circuit errors.

func (*Group) Get

func (g *Group) Get(name string) Limiter

Get .

type Limiter

type Limiter interface {
	Allow() (Done, error)
}

Limiter is a rate limiter.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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