bandwidth

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket added in v0.6.0

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

Bucket implements a thread-safe leaky bucket rate limiter.

func NewBucket added in v0.6.0

func NewBucket(limit int64, interval time.Duration) (*Bucket, error)

NewBucket creates a new rate limiter with the specified limit and interval.

func (*Bucket) Wait added in v0.6.0

func (rl *Bucket) Wait(n int64)

Wait blocks until n tokens are available. It allows waiting for amounts larger than the limit.

type Limiter

type Limiter struct {
	*Bucket
}

Limiter wrapper around standard rate.Limiter.

func NewLimiter

func NewLimiter(limit int64) (*Limiter, error)

NewLimiter returns new bandwidth limiter.

func (*Limiter) Wait

func (l *Limiter) Wait(n int)

Wait blocks until limiter permits n events to happen.

Jump to

Keyboard shortcuts

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