track

package
v0.0.0-...-6f2370f Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TLSDialWithDialer

func TLSDialWithDialer(dialer Dialer, network, addr string, config *tls.Config) (*tls.Conn, error)

TLSDialWithDialer connects to the given network address using dialer.Dial and then initiates a TLS handshake, returning the resulting TLS connection. Any timeout or deadline given in the dialer apply to connection and TLS handshake as a whole.

TLSDialWithDialer interprets a nil configuration as equivalent to the zero configuration; see the documentation of Config for the defaults.

Types

type ByteTracker

type ByteTracker interface {

	// BytesReadWritten should only ever be called when the caller knows
	// that no more mutations to the bytes read or written happens past the
	// point of calling. In the context of an HTTP request and its associated
	// socket. It's possible that a connection with the same ByteTracker may be
	// reused. If this is the case, the caller is responsible for calling
	// ResetBytes.
	BytesReadWritten() (read uint64, written uint64)

	// BytesReadWrittenReset can be safely called multiple times as it resets the
	// read and written count per call.
	BytesReadWrittenReset() (read uint64, written uint64)
	ResetBytes()
}

ByteTracker represents a type that is capable of tracking bytes read and written over a period of time

type Conn

type Conn interface {
	net.Conn
	ByteTracker
}

Conn wraps a net.Conn and tracks reads and writes

func NewConn

func NewConn(conn net.Conn) Conn

NewConn returns a new Conn based off of a net.Conn

type DialContext

type DialContext func(ctx context.Context, network, address string) (net.Conn, error)

type Dialer

type Dialer interface {
	ByteTracker
	// contains filtered or unexported methods
}

Dialer represents a net.Dialer that can track bytes read/written

func NewDefaultDialer

func NewDefaultDialer() Dialer

NewDefaultDialer returns a Dialer based on a default net.Dialer

type HTTPClient

type HTTPClient struct {
	*http.Client
	HTTPRoundTripper
}

HTTPClient wraps an http.Client and tracks reads and writes

func NewDefaultHTTPClient

func NewDefaultHTTPClient() HTTPClient

NewDefaultHTTPClient returns a new HTTPClient based on a default http.Client

type HTTPRoundTripper

type HTTPRoundTripper interface {
	http.RoundTripper
	ByteTracker
	CloseIdleConnections()
	WrapDialContext(dialCtx func(next DialContext) DialContext)
}

HTTPRoundTripper wraps an http.RoundTripper and tracks reads and writes

func NewDefaultHTTPRoundTripper

func NewDefaultHTTPRoundTripper() HTTPRoundTripper

NewDefaultHTTPRoundTripper returns a new HTTPRoundTripper based on a default net.Dialer and http.Transport

func NewHTTPRoundTripper

func NewHTTPRoundTripper(
	innerTransport *http.Transport,
	innerDialer *net.Dialer,
) HTTPRoundTripper

NewHTTPRoundTripper returns a new HTTPRoundTripper wrapping the given http.Transport and net.Dialer

Jump to

Keyboard shortcuts

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