queueing

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2017 License: MIT Imports: 4 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(h http.Handler, limit, queueLimit uint, queueTimeout time.Duration) http.Handler

Types

type Queue

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

func NewQueue

func NewQueue(limit, queueLimit uint) *Queue

NewQueue creates a new queue limit specifies number of requests run concurrently queueLimit specifies maximum number of requests that can be queued if the number of requests is above the limit

func (*Queue) Acquire

func (s *Queue) Acquire(timeout time.Duration) (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