listener

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewListener

func NewListener(listenAddress string, listenPort, connectionsLimit int,
	tlsConfig *tls.Config, drainTimeout time.Duration, log *tl.Logger) (net.Listener, error)

NewListener creates a new network listener which obeys to the configuration max connection limit, monitors connections with prometheus metrics, and is able to be gracefully drained

The way this works is by creating a listener and wrapping it with a netutil.LimitListener to set a limit.

This limiter will simply block waiting for resources to become available whenever clients go above the limit.

To simplify settings limits the listener is wrapped with yet another object which observes the connections to set a gauge with the current number of connections (with operates with sampling through scrapes), and a set of counter metrics for connections accepted, rejected and closed.

Types

type Listener

type Listener struct {
	net.Listener
	// contains filtered or unexported fields
}

Listener is the Trickster net.Listener implmementation

func (*Listener) Accept

func (l *Listener) Accept() (net.Conn, error)

Accept implements Listener.Accept

func (*Listener) CertSwapper

func (l *Listener) CertSwapper() *sw.CertSwapper

CertSwapper returns the CertSwapper reference from the Listener

func (*Listener) RouteSwapper

func (l *Listener) RouteSwapper() *ph.SwitchHandler

RouteSwapper returns the RouteSwapper reference from the Listener

type ListenerGroup

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

ListenerGroup is a collection of listeners

func NewListenerGroup

func NewListenerGroup() *ListenerGroup

NewListenerGroup returns a new ListenerGroup

func (*ListenerGroup) DrainAndClose

func (lg *ListenerGroup) DrainAndClose(listenerName string, drainWait time.Duration) error

DrainAndClose drains and closes the named listener

func (*ListenerGroup) Get

func (lg *ListenerGroup) Get(name string) *Listener

Get returns the listener if it exists

func (*ListenerGroup) StartListener

func (lg *ListenerGroup) StartListener(listenerName, address string, port int, connectionsLimit int,
	tlsConfig *tls.Config, router http.Handler, wg *sync.WaitGroup, tracers tracing.Tracers,
	exitOnError bool, drainTimeout time.Duration, log *tl.Logger) error

StartListener starts a new HTTP listener and adds it to the listener group

func (*ListenerGroup) StartListenerRouter

func (lg *ListenerGroup) StartListenerRouter(listenerName, address string, port int, connectionsLimit int,
	tlsConfig *tls.Config, path string, handler http.Handler, wg *sync.WaitGroup,
	tracers tracing.Tracers, exitOnError bool, drainTimeout time.Duration, log *tl.Logger) error

StartListenerRouter starts a new HTTP listener with a new router, and adds it to the listener group

func (*ListenerGroup) UpdateFrontendRouters

func (lg *ListenerGroup) UpdateFrontendRouters(mainRouter http.Handler, adminRouter http.Handler)

UpdateFrontendRouters will swap out the routers across the named Listeners with the provided ones

func (*ListenerGroup) UpdateRouter

func (lg *ListenerGroup) UpdateRouter(routerName string, router http.Handler)

UpdateRouter will swap out the router for the ListenerGroup with the provided name

Jump to

Keyboard shortcuts

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