ratelim

package
v2.0.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RateLim

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

RateLim allows to logically cap the maximum number of functions. It returns a slice of error strings that happened during execution.

func New

func New(limit int) (*RateLim, error)

New returns a new RateLim.

func (*RateLim) Exec

func (rl *RateLim) Exec(f func() error)

Exec executes f when a slot is available within the defined maximum limit.

func (*RateLim) Wait

func (rl *RateLim) Wait() []string

Wait will block until all executing functions finish, and return all error strings that happened during executions. RateLim can't be reused after this call.

Jump to

Keyboard shortcuts

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