limiter

package
v2.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2023 License: MIT Imports: 1 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 {
	Current        int32
	MaxConcurrency int32
}

Limiter 并发限制

func New

func New(maxConcurrency int32) *Limiter

New create a concurrency limiter with MaxConcurrency=maxConcurrency

func (*Limiter) Decr

func (limiter *Limiter) Decr(v int32) (int32, bool)

Decr decrease/release current concurrency.

func (*Limiter) GetCurrent added in v2.3.0

func (limiter *Limiter) GetCurrent() int32

GetCurrent get current concurrency

func (*Limiter) Incr

func (limiter *Limiter) Incr(v int32) (int32, bool)

Incr increase current concurrency, if (-1, false) returned, reject request.

Jump to

Keyboard shortcuts

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