limiter

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Limiter

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

func NewLimiter

func NewLimiter(capacity int) *Limiter

NewLimiter initializes a new limiter with the specified capacity

func (*Limiter) Capacity

func (l *Limiter) Capacity() int

Capacity returns the current capacity of the rate limiter

func (*Limiter) Obtain

func (l *Limiter) Obtain(ctx context.Context, priority int) error

Obtain blocks until a token is available or the context is cancelled

func (*Limiter) Release

func (l *Limiter) Release()

Release explicitly releases a token

func (*Limiter) ReleaseAfterDelay

func (l *Limiter) ReleaseAfterDelay(delay time.Duration)

ReleaseAfterDelay releases the limiter after the specified delay

func (*Limiter) SetCapacity

func (l *Limiter) SetCapacity(newCapacity int)

SetCapacity updates the rate limiter's capacity

Jump to

Keyboard shortcuts

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