limit

package
v0.10.9 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTimeout = errors.New("limiter acquire timeout")
	ErrClosed  = errors.New("limiter closed")
)

Functions

This section is empty.

Types

type Limiter

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

Limiter support update limit number dynamically

func NewLimiter

func NewLimiter(initLimit int64) (l *Limiter)

func (*Limiter) Acquire

func (l *Limiter) Acquire(timeout time.Duration) (err error)

Acquire will wait for an available resource. timeout eq 0 means no timeout limit. Return ErrTimeout if no resource available after timeout duration. Return ErrClosed if this Limiter is closed.

func (*Limiter) Close

func (l *Limiter) Close()

func (*Limiter) LimitNum

func (l *Limiter) LimitNum() int64

func (*Limiter) Release

func (l *Limiter) Release()

Release resources.

func (*Limiter) RunningNum

func (l *Limiter) RunningNum() int64

func (*Limiter) SetLimit

func (l *Limiter) SetLimit(num int64)

func (*Limiter) WaitingNum

func (l *Limiter) WaitingNum() int64

Jump to

Keyboard shortcuts

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