maxconnections

package
v3.7.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2017 License: Apache-2.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	OverloadHandler http.Handler
	// contains filtered or unexported fields
}

Handler implements the http.Handler interface.

func New

func New(limiter Limiter, h http.Handler) *Handler

New returns an http.Handler that uses limiter to control h invocation. If limiter prohibits starting a new handler, OverloadHandler will be invoked.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Limiter

type Limiter interface {
	// Start decides whether a new job can be started. The decision may be
	// returned after a delay if the limiter wants to throttle jobs.
	Start(context.Context) bool

	// Done must be called when a job is finished.
	Done()
}

A Limiter controls starting of jobs.

func NewLimiter

func NewLimiter(maxRunning, maxInQueue int, maxWaitInQueue time.Duration) Limiter

NewLimiter return a limiter that allows no more than maxRunning jobs at the same time. It can enqueue up to maxInQueue jobs awaiting to be run, and a job may wait in the queue no more than maxWaitInQueue.

Jump to

Keyboard shortcuts

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