buck

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: GPL-3.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

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

Bucket implements a token bucket rate limiter.

func New

func New(burst int) *Bucket

New is like Init but also allocates

func (*Bucket) Init

func (b *Bucket) Init(burst int)

Init initializes an existing Bucket with the given burst capacity.

func (Bucket) Refill

func (b Bucket) Refill(ctx context.Context, rate time.Duration)

Refill adds tokens to the bucket at the specified rate until the context is cancelled.

func (Bucket) Wait

func (b Bucket) Wait(ctx context.Context) error

Wait blocks until a token is available or the context is cancelled.

Jump to

Keyboard shortcuts

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