Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LimitListener ¶
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 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 }
Click to show internal directories.
Click to hide internal directories.