Documentation ¶
Index ¶
- Variables
- type AddressLoader
- type ConnectionAttemptTracker
- type Discoverer
- type Option
- func WithAddrOverride(addr string) Option
- func WithInClusterKubeClient() Option
- func WithKubeClient(client kubernetes.Interface) Option
- func WithKubeService(namespaceName, serviceName string) Option
- func WithKubeServicePortNameOverride(portName string) Option
- func WithNodeAffinity(nodeName string) Option
- func WithPostDiscoveryFilter(f func(typhaAddresses []Typha) ([]Typha, error)) Option
- type Typha
Constants ¶
This section is empty.
Variables ¶
var ErrServiceNotReady = errors.New("Kubernetes service missing IP or port")
var ErrTriedAllAddrs = fmt.Errorf("tried all available discovered addresses")
Functions ¶
This section is empty.
Types ¶
type AddressLoader ¶
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 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 WithNodeAffinity ¶
WithNodeAffinity help discovery preference by supplying nodeName to determine which endpoints are local to node