limiter

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTicket = "not to use this"

Variables

View Source
var (
	ErrUnexpectedBlocking = errors.New("unexpected blocking, queuer may be lost")
	ErrShutdownQueue      = errors.New("queue has been shutdown")
	ErrFullQueue          = errors.New("queue is full")
)

Functions

This section is empty.

Types

type Limiter

type Limiter interface {
	AcquireTicket(ctx context.Context, tickets ...string) (Reason, error)
	ReleaseTicket(ctx context.Context, tickets ...string)
	Start(ctx context.Context) error
}

func NewLimiter

func NewLimiter(maxQueueSize int, maxWaitTime time.Duration) Limiter

type Reason

type Reason int
const (
	Checkin Reason = iota
	CheckinTimeout
	UnexpectedBlocking
	ShutdownQueue
	FullQueue
)

Jump to

Keyboard shortcuts

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