discovery

package
v0.0.0-...-21cfbab Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: Apache-2.0, Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrServiceNotReady = errors.New("Kubernetes service missing IP or port")
View Source
var ErrTriedAllAddrs = fmt.Errorf("tried all available discovered addresses")

Functions

This section is empty.

Types

type AddressLoader

type AddressLoader interface {
	LoadTyphaAddrs() (ts []Typha, err error)
	CachedTyphaAddrs() []Typha
}

type ConnectionAttemptTracker

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

ConnectionAttemptTracker deals with the fact that the list of available Typha instances may change during a connection attempt. Each call to NextAddr refreshes the list of available Typha addresses (if needed) and then returns the first entry in the list that has not been returned before. If the list is static, NextAddr() will effectively just iterate through the static list.

func NewConnAttemptTracker

func NewConnAttemptTracker(d AddressLoader) *ConnectionAttemptTracker

func (*ConnectionAttemptTracker) NextAddr

func (d *ConnectionAttemptTracker) NextAddr() (Typha, error)

type Discoverer

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

func New

func New(opts ...Option) *Discoverer

func (*Discoverer) AddPostDiscoveryFilter

func (d *Discoverer) AddPostDiscoveryFilter(f func(typhaAddresses []Typha) ([]Typha, error))

func (*Discoverer) CachedTyphaAddrs

func (d *Discoverer) CachedTyphaAddrs() []Typha

func (*Discoverer) LoadTyphaAddrs

func (d *Discoverer) LoadTyphaAddrs() (ts []Typha, err error)

LoadTyphaAddrs tries to discover the best address(es) to use to connect to Typha.

If an AddrOverride is supplied then that takes precedence, otherwise, LoadTyphaAddrs will try to lookup one of the backend endpoints of the typha service (using the K8sServiceName and K8sNamespace fields).

Returns nil if typha is not enabled (i.e. fields are empty). If typha is enabled, this will return a non-empty slice or an error.

func (*Discoverer) TyphaEnabled

func (d *Discoverer) TyphaEnabled() bool

type Option

type Option func(opts *Discoverer)

func WithAddrOverride

func WithAddrOverride(addr string) Option

func WithInClusterKubeClient

func WithInClusterKubeClient() Option

WithInClusterKubeClient enables auto-connection to Kubernetes using the in-cluster client config. this is disabled by default to avoid creating an extra Kubernetes client that is then discarded.

func WithKubeClient

func WithKubeClient(client kubernetes.Interface) Option

func WithKubeService

func WithKubeService(namespaceName, serviceName string) Option

func WithKubeServicePortNameOverride

func WithKubeServicePortNameOverride(portName string) Option

func WithNodeAffinity

func WithNodeAffinity(nodeName string) Option

WithNodeAffinity help discovery preference by supplying nodeName to determine which endpoints are local to node

func WithPostDiscoveryFilter

func WithPostDiscoveryFilter(f func(typhaAddresses []Typha) ([]Typha, error)) Option

type Typha

type Typha struct {
	Addr     string
	IP       string
	NodeName *string
}

Jump to

Keyboard shortcuts

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