throttler

package
v1.28.1 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2017 License: MIT Imports: 2 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Throttler

type Throttler struct {
	// contains filtered or unexported fields
}

Throttler holds the context for a throttler instance.

func New

func New(refillTokens uint64, refillInterval time.Duration) *Throttler

New instantiates a new Throttler object - refillTokens: number of tokens to issue every refillInterval (below) - refillInterval: interval at which 'refillTokens' should be issued

func (*Throttler) Allow

func (t *Throttler) Allow() bool

Allow checks to see if a particular request should be allowed; ie, it would returns true if we are under the throttling threshold, otherwise false.

func (*Throttler) AllowN

func (t *Throttler) AllowN(n uint64) bool

AllowN checks to see if we will be allowed to do a batch of 'n' tokens; it would return true if we are under the throttling threshold, otherwise false.

Jump to

Keyboard shortcuts

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