limit

package
v0.0.0-...-303e327 Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrLimited = errors.New("limit exceeded")

ErrLimited limited error for non-blocking

Functions

This section is empty.

Types

type Limiter

type Limiter interface {
	// returns how many holder are running
	// return -1 if u donot want to implement this
	Running() int

	// Acquire by this keys, returns error if no available resource
	// Panic if key is unhashable type necessarily
	Acquire(keys ...interface{}) error

	// Release this keys holder
	// Panic if not acquire yet necessarily
	// Panic if key is unhashable type necessarily
	Release(keys ...interface{})
}

Limiter to limit all by key

type ResettableLimiter

type ResettableLimiter interface {
	Limiter

	// Reset the available resource
	Reset(n int)
}

ResettableLimiter resetable limiter

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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