throttle

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 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 Option

type Option func(*Throttler)

Option is an option

func SetQueueLen

func SetQueueLen(n uint64) Option

SetQueueLen sets queue length

func SetWorkerNum

func SetWorkerNum(n uint64) Option

SetWorkerNum sets worker number

type Throttler

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

Throttler struct

func New

func New(tps uint64, opts ...Option) *Throttler

New creates an instance of throttler

func (*Throttler) Allow

func (t *Throttler) Allow() bool

Allow returns true if action is not throttled, returns false if is throttled.

func (*Throttler) Start

func (t *Throttler) Start(ctx context.Context)

Start starts the throttler

Jump to

Keyboard shortcuts

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