multidialer

package
v0.0.0-...-bd27a7b Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

This is a simple mechanism to provide HA without relying on external components. It doesn't provide load balancing or any other advanced features, if a connection fails it just simple try with the next server in the pool. The retry logic is kept on the clients.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewResolver

func NewResolver(alternateHosts []string) *resolver

NewResolver returns a hosts pool to control the dialer destination

Types

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 {
	// contains filtered or unexported fields
}

Dialer opens connections through Dial. It iterates over a list of hosts that can be updated externally until it succeeds.

func NewDialer

func NewDialer(dial DialFunc) *Dialer

NewDialer creates a new Dialer instance.

func NewDialerWithAlternateHosts

func NewDialerWithAlternateHosts(dial DialFunc, alternateHosts []string) *Dialer

NewDialerWithAlternateHosts 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 alternateHosts is not nil, it will be used to retry failed connections.

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 connection trying to connect serially over the list of ready hosts in the pool

func (*Dialer) Start

func (d *Dialer) Start(ctx context.Context, clientset kubernetes.Interface)

Jump to

Keyboard shortcuts

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