ratelimiter

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2021 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OnceTakeCount = 1
	OncePutCount  = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type RateLimiter

type RateLimiter struct {
	ratelimit.Bucket
}

func NewRateLimiter

func NewRateLimiter(fillInterval time.Duration, capacity int64) (*RateLimiter, error)

returns a new token bucket that fills at the rate of one token every fillInterval, up to the given maximum capacity.Both arguments must be positive. The bucket is initially full.

func NewRateLimiterWithQuantum

func NewRateLimiterWithQuantum(fillInterval time.Duration, capacity, quantum int64) (*RateLimiter, error)

allows the specification of the quantum size - quantum tokens are added every fillInterval.

func (*RateLimiter) Limit

func (l *RateLimiter) Limit() bool

Jump to

Keyboard shortcuts

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