go-conntrack – github.com/mwitkow/go-conntrack Index | Files | Directories

package conntrack

import "github.com/mwitkow/go-conntrack"

Index

Functions

func DialNameFromContext

func DialNameFromContext(ctx context.Context) string

DialNameFromContext returns the name of the dialer from the context of the DialContext func, if any.

func DialNameToContext

func DialNameToContext(ctx context.Context, dialerName string) context.Context

DialNameToContext returns a context that will contain a dialer name override.

func DialWithDialContextFunc

func DialWithDialContextFunc(parentDialerFunc dialerContextFunc) dialerOpt

DialWithDialContextFunc allows you to override func gets used for the actual dialing. The default is `net.Dialer.DialContext`.

func DialWithDialer

func DialWithDialer(parentDialer *net.Dialer) dialerOpt

DialWithDialer allows you to override the `net.Dialer` instance used to actually conduct the dials.

func DialWithName

func DialWithName(name string) dialerOpt

DialWithName sets the name of the dialer for tracking and monitoring. This is the name for the dialer (default is `default`), but for `NewDialContextFunc` can be overwritten from the Context using `DialNameToContext`.

func DialWithTracing

func DialWithTracing() dialerOpt

DialWithTracing turns *on* the /debug/events tracing of the dial calls.

func DialWithoutMonitoring

func DialWithoutMonitoring() dialerOpt

DialWithoutMonitoring turns *off* Prometheus monitoring for this dialer.

func NewDialContextFunc

func NewDialContextFunc(optFuncs ...dialerOpt) func(context.Context, string, string) (net.Conn, error)

NewDialContextFunc returns a `DialContext` function that tracks outbound connections. The signature is compatible with `http.Tranport.DialContext` and is meant to be used there.

func NewDialFunc

func NewDialFunc(optFuncs ...dialerOpt) func(string, string) (net.Conn, error)

NewDialFunc returns a `Dial` function that tracks outbound connections. The signature is compatible with `http.Tranport.Dial` and is meant to be used there for Go < 1.7.

func NewListener

func NewListener(inner net.Listener, optFuncs ...listenerOpt) net.Listener

NewListener returns the given listener wrapped in connection tracking listener.

func PreRegisterDialerMetrics

func PreRegisterDialerMetrics(dialerName string)

preRegisterDialerMetrics pre-populates Prometheus labels for the given dialer name, to avoid Prometheus missing labels issue.

func TrackWithName

func TrackWithName(name string) listenerOpt

TrackWithName sets the name of the Listener for use in tracking and monitoring.

func TrackWithRetries

func TrackWithRetries(b backoff.Backoff) listenerOpt

TrackWithRetries enables retrying of temporary Accept() errors, with the given backoff between attempts. Concurrent accept calls that receive temporary errors have independent backoff scaling.

func TrackWithTcpKeepAlive

func TrackWithTcpKeepAlive(keepalive time.Duration) listenerOpt

TrackWithTcpKeepAlive makes sure that any `net.TCPConn` that get accepted have a keep-alive. This is useful for HTTP servers in order for, for example laptops, to not use up resources on the server while they don't utilise their connection. A value of 0 disables it.

func TrackWithTracing

func TrackWithTracing() listenerOpt

TrackWithTracing turns *on* the /debug/events tracing of the live listener connections.

func TrackWithoutMonitoring

func TrackWithoutMonitoring() listenerOpt

TrackWithoutMonitoring turns *off* Prometheus monitoring for this listener.

Source Files

dialer_reporter.go dialer_wrapper.go listener_reporter.go listener_wrapper.go

Directories

PathSynopsis
connhelpers
example
Version
v0.0.0-20190716064945-2f068394615f (latest)
Published
Jul 16, 2019
Platform
windows/amd64
Imports
10 packages
Last checked
3 weeks ago

Tools for package owners.