connrotation

package
v0.28.14 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: Apache-2.0 Imports: 3 Imported by: 150

Documentation

Overview

Package connrotation implements a connection dialer that tracks and can close all created connections.

This is used for credential rotation of long-lived connections, when there's no way to re-authenticate on a live connection.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionTracker added in v0.21.0

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

ConnectionTracker keeps track of opened connections

func NewConnectionTracker added in v0.21.0

func NewConnectionTracker() *ConnectionTracker

NewConnectionTracker returns a connection tracker for use with NewDialerWithTracker

func (*ConnectionTracker) CloseAll added in v0.21.0

func (c *ConnectionTracker) CloseAll()

CloseAll forcibly closes all tracked connections.

Note: new connections may get created before CloseAll returns.

func (*ConnectionTracker) Track added in v0.21.0

func (c *ConnectionTracker) Track(conn net.Conn) net.Conn

Track adds the connection to the list of tracked connections, and returns a wrapped copy of the connection that stops tracking the connection when it is closed.

type DialFunc

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

DialFunc is a shorthand for signature of net.DialContext.

type Dialer

type Dialer struct {
	*ConnectionTracker
	// contains filtered or unexported fields
}

Dialer opens connections through Dial and tracks them.

func NewDialer

func NewDialer(dial DialFunc) *Dialer

NewDialer creates a new Dialer instance. Equivalent to NewDialerWithTracker(dial, nil).

func NewDialerWithTracker added in v0.21.0

func NewDialerWithTracker(dial DialFunc, tracker *ConnectionTracker) *Dialer

NewDialerWithTracker creates a new Dialer instance.

If dial is not nil, it will be used to create new underlying connections. Otherwise net.DialContext is used. If tracker is not nil, it will be used to track new underlying connections. Otherwise NewConnectionTracker() is used.

func (*Dialer) Dial

func (d *Dialer) Dial(network, address string) (net.Conn, error)

Dial creates a new tracked connection.

func (*Dialer) DialContext

func (d *Dialer) DialContext(ctx context.Context, network, address string) (net.Conn, error)

DialContext creates a new tracked connection.

Jump to

Keyboard shortcuts

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