limiter

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: MIT Imports: 3 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConcurrencyLimiter

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

func NewConcurrencyLimiter

func NewConcurrencyLimiter(handler http.Handler, concurrencyLimit int) *ConcurrencyLimiter

NewConcurrencyLimiter creates NewConcurrencyLimiter with a Handler() function that returns a handler which limits the active number of active, concurrent requests.

If the concurrency limit is less than, or equal to 0, then it will just return the handler passed to it.

The Met() function will return true if the concurrency limit is exceeded within the handler at the time of the call.

func (*ConcurrencyLimiter) Handler added in v1.1.0

func (cl *ConcurrencyLimiter) Handler() http.Handler

func (*ConcurrencyLimiter) Met added in v1.1.0

func (cl *ConcurrencyLimiter) Met() bool

func (*ConcurrencyLimiter) ServeHTTP

func (cl *ConcurrencyLimiter) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Limiter added in v1.2.2

type Limiter interface {
	Met() bool
}

Limiter is an interface that can be used to check if a limit has been met.

Jump to

Keyboard shortcuts

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