ratelimiter

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JOnceTakeCount = 1
	JOncePutCount  = 1
)
View Source
const (
	OnceTakeCount = 1
	OncePutCount  = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type JRateLimiter

type JRateLimiter struct {
	ratelimit.Bucket
}

func NewJRateLimiter

func NewJRateLimiter(fillInterval time.Duration, capacity int64) (*JRateLimiter, 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 NewJRateLimiterWithQuantum

func NewJRateLimiterWithQuantum(fillInterval time.Duration, capacity, quantum int64) (*JRateLimiter, error)

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

func (*JRateLimiter) JLimit

func (l *JRateLimiter) JLimit() bool

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