overflow

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 28, 2021 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LimitListener

func LimitListener(l net.Listener, n int, options LimitListenerOptions) net.Listener

LimitListener returns a Listener that accepts at most n simultaneous connections from the provided Listener.

Types

type Counter

type Counter interface {
	Inc()
}

Counter should be a prometheus.Counter or equivalent.

type Gauge

type Gauge interface {
	Inc()
	Dec()
}

Gauge should be a prometheus.Gauge or equivalent.

type LimitListenerOptions

type LimitListenerOptions struct {
	// RejectionHandler is used to turn away connections while the limit is reached.
	// If RejectionHandler is nil, the default behavior is that LimitListener will immediately close the connection.
	// If RejectionHandler is not nil, it is responsible for closing the rejected connection.
	// RejectionHandler is called in the goroutine that called LimitListener.Accept.
	RejectionHandler func(net.Conn)

	// RejectedConnections is incremented each time a connection is rejected due to the limit being reached.
	RejectedConnections Counter

	// AcceptedConnections is incremented each time a connection is returned to the Accept() caller.
	AcceptedConnections Counter

	// ActiveConnections is incremented each time a connection is returned to the Accept() caller,
	// and decremented when the connection is closed.
	ActiveConnections Gauge
}

Jump to

Keyboard shortcuts

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