resttunnel

package
v0.0.0-...-d0d75a4 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBucketCircularAlias = xerrors.New("Bucket references itself")

ErrBucketCircularAlias is raised when a bucket references itself down a stack.

View Source
var ErrBucketDoesNotExist = xerrors.New("Bucket does not exist")

ErrBucketDoesNotExist is raised when attempting to fetch a bucket that does not exist.

Functions

This section is empty.

Types

type Bucket

type Bucket struct {
	Mu sync.RWMutex

	Name  string
	Alias string

	// When handling the bucket lock, make sure you check the global bucket if it has
	// been defined.
	Global string

	Limit     *int32
	Duration  *int64
	ResetsAt  *int64
	Available *int32
}

Bucket represents a ratelimit bucket.

func CreateBucket

func CreateBucket(name string, limit int32, duration time.Duration, alias string, global string) (b *Bucket)

CreateBucket creates a new bucket.

func (*Bucket) Exhaust

func (b *Bucket) Exhaust(reset int64)

Exhaust removes all available calls and modifies the ResetAfter.

func (*Bucket) Lock

func (b *Bucket) Lock() (hit bool)

Lock waits until a bucket is ready.

Jump to

Keyboard shortcuts

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