queueing

package
v4.3.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTimeout = 30 * time.Second
)

Variables

View Source
var ErrQueueingTimedout = &errQueueingTimedout{errors.New("queueing timedout")}
View Source
var ErrTooManyRequests = &errTooManyRequests{errors.New("too many requests queued")}

Functions

func QueueRequests

func QueueRequests(name string, h http.Handler, limit, queueLimit uint, queueTimeout time.Duration) http.Handler

QueueRequests creates a new request queue name specifies the name of queue, used to label Prometheus metrics

Don't call QueueRequests twice with the same name argument!

h specifies a http.Handler which will handle the queue requests limit specifies number of requests run concurrently queueLimit specifies maximum number of requests that can be queued queueTimeout specifies the time limit of storing the request in the queue

Types

type Queue

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

func (*Queue) Acquire

func (s *Queue) Acquire() (err error)

Acquire takes one slot from the Queue and returns when a request should be processed it allows up to (limit) of requests running at a time it allows to queue up to (queue-limit) requests

func (*Queue) Release

func (s *Queue) Release()

Release marks the finish of processing of requests It triggers next request to be processed if it's in queue

Jump to

Keyboard shortcuts

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