dialer

package
v0.0.0-...-8b501b0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMaxRetriesExceeded = errors.New("max number of dial retries exceeded")

ErrMaxRetriesExceeded is returned by the retrying dialer to indicate that a connection was not possible after the configured number of max attempts.

Functions

This section is empty.

Types

type DialFunc

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

DialFunc describes any function that can be invoked to dial a remote host.

type RetryingDialer

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

RetryingDialer wraps a DialFunc with an exponential back-off retry mechanism.

func NewRetryingDialer

func NewRetryingDialer(ctx context.Context, clk clock.Clock, dialFunc DialFunc, maxAttempts int) *RetryingDialer

NewRetryingDialer returns a new dialer that wraps dialFunc with a retry layer that waits between attempts using an exponential back-off algorithm. Dial attempts will be aborted if the attempts exceed maxAttempts or the provided context is cancelled.

func (*RetryingDialer) Dial

func (d *RetryingDialer) Dial(network, address string) (conn net.Conn, err error)

Dial a remote host.

Jump to

Keyboard shortcuts

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