discovery

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalYAMLWithInlineConfigs

func MarshalYAMLWithInlineConfigs(in interface{}) (interface{}, error)

MarshalYAMLWithInlineConfigs helps implement yaml.Marshal for structs that have a Configs field that should be inlined.

func Name

func Name(n string) func(*Manager)

Name sets the name of the manager.

func RegisterConfig

func RegisterConfig(config Config)

RegisterConfig registers the given Config type for YAML marshaling and unmarshaling.

func RegisterMetrics

func RegisterMetrics()

func UnmarshalYAMLWithInlineConfigs

func UnmarshalYAMLWithInlineConfigs(out interface{}, unmarshal func(interface{}) error) error

UnmarshalYAMLWithInlineConfigs helps implement yaml.Unmarshal for structs that have a Configs field that should be inlined.

Types

type Config

type Config interface {
	// Name returns the name of the discovery mechanism.
	Name() string

	// NewDiscoverer returns a Discoverer for the Config
	// with the given DiscovererOptions.
	NewDiscoverer(DiscovererOptions) (Discoverer, error)
}

A Config provides the configuration and constructor for a Discoverer.

type Configs

type Configs []Config

Configs is a slice of Config values that uses custom YAML marshaling and unmarshaling to represent itself as a mapping of the Config values grouped by their types.

func (Configs) MarshalYAML

func (c Configs) MarshalYAML() (interface{}, error)

MarshalYAML implements yaml.Marshaler.

func (*Configs) SetDirectory

func (c *Configs) SetDirectory(dir string)

SetDirectory joins any relative file paths with dir.

func (*Configs) UnmarshalYAML

func (c *Configs) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements yaml.Unmarshaler.

type Discoverer

type Discoverer interface {
	// Run hands a channel to the discovery provider (Consul, DNS, etc.) through which
	// it can send updated target groups. It must return when the context is canceled.
	// It should not close the update channel on returning.
	Run(ctx context.Context, up chan<- []*targetgroup.Group)
}

Discoverer provides information about target groups. It maintains a set of sources from which TargetGroups can originate. Whenever a discovery provider detects a potential change, it sends the TargetGroup through its channel.

Discoverer does not know if an actual change happened. It does guarantee that it sends the new TargetGroup whenever a change happens.

Discoverers should initially send a full set of all discoverable TargetGroups.

type DiscovererOptions

type DiscovererOptions struct {
	Logger logrus.FieldLogger
}

DiscovererOptions provides options for a Discoverer.

type Manager

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

Manager maintains a set of discovery providers and sends each update to a map channel. Targets are grouped by the target set name.

func NewManager

func NewManager(logger logrus.FieldLogger, options ...func(*Manager)) *Manager

NewManager is the Discovery Manager constructor.

func (*Manager) ApplyConfig

func (m *Manager) ApplyConfig(cfg map[string]Configs) error

ApplyConfig checks if discovery provider with supplied config is already running and keeps them as is. Remaining providers are then stopped and new required providers are started using the provided config.

func (*Manager) Run

func (m *Manager) Run() error

Run starts the background processing.

func (*Manager) StartCustomProvider

func (m *Manager) StartCustomProvider(ctx context.Context, name string, worker Discoverer)

StartCustomProvider is used for sdtool. Only use this if you know what you're doing.

func (*Manager) Stop

func (m *Manager) Stop()

func (*Manager) SyncCh

func (m *Manager) SyncCh() <-chan map[string][]*targetgroup.Group

SyncCh returns a read only channel used by all the clients to receive target updates.

type StaticConfig

type StaticConfig []*targetgroup.Group

A StaticConfig is a Config that provides a static list of targets.

func (StaticConfig) Name

func (StaticConfig) Name() string

Name returns the name of the service discovery mechanism.

func (StaticConfig) NewDiscoverer

func (c StaticConfig) NewDiscoverer(DiscovererOptions) (Discoverer, error)

NewDiscoverer returns a Discoverer for the Config.

type StaticProvider

type StaticProvider struct {
	TargetGroups []*targetgroup.Group
}

StaticProvider holds a list of target groups that never change.

func (*StaticProvider) Run

func (sd *StaticProvider) Run(ctx context.Context, ch chan<- []*targetgroup.Group)

Run implements the Worker interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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