discovery

package
v0.31.1 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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(opts 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.

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<- []Group) error
}

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 log.Logger
}

DiscovererOptions provides options for a Discoverer.

type Group added in v0.10.0

type Group interface {
	// Source is an identifier that describes a group of targets.
	Source() string
	// Labels is a set of labels that is common across all targets in the group.
	Labels() model.LabelSet
	// NumberOfTargets returns the number of targets in the group.
	NumberOfTargets() int

	String() string
}

Group is a set of target(s) with a common label set (production, test, staging etc.).

type Manager

type Manager struct {

	// Some Discoverers(eg. kubernetes) send only the updates for a given target group
	// so we use map[tg.Source]*Group to know which group to update.
	Targets map[poolKey]map[string]Group
	// 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 log.Logger, reg prometheus.Registerer, options ...func(*Manager)) *Manager

NewManager is the Discovery Manager constructor.

func (*Manager) ApplyConfig

func (m *Manager) ApplyConfig(ctx context.Context, cfg map[string]Configs) error

ApplyConfig removes all running discovery providers and starts new ones using the provided config.

func (*Manager) Run

func (m *Manager) Run(ctx context.Context) 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) SyncCh

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

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

type MultiTargetGroup added in v0.20.0

type MultiTargetGroup struct {

	// Targets is a map of PIDs identified by a label set. Each target is
	// uniquely identifiable in the group by its address label.
	Targets map[int]model.LabelSet
	// contains filtered or unexported fields
}

func (MultiTargetGroup) Labels added in v0.20.0

func (tg MultiTargetGroup) Labels() model.LabelSet

func (MultiTargetGroup) NumberOfTargets added in v0.20.0

func (tg MultiTargetGroup) NumberOfTargets() int

func (MultiTargetGroup) Source added in v0.20.0

func (tg MultiTargetGroup) Source() string

func (MultiTargetGroup) String added in v0.20.0

func (tg MultiTargetGroup) String() string

type PodConfig

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

func NewPodConfig

func NewPodConfig(nodeName, socketPath string) *PodConfig

func (*PodConfig) Name

func (c *PodConfig) Name() string

func (*PodConfig) NewDiscoverer

func (c *PodConfig) NewDiscoverer(d DiscovererOptions) (Discoverer, error)

type PodDiscoverer

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

func (*PodDiscoverer) Run

func (g *PodDiscoverer) Run(ctx context.Context, up chan<- []Group) error

type SingleTargetGroup added in v0.20.0

type SingleTargetGroup struct {

	// Target entry process for this group (e.g. container or systemd unit).
	// This is used to match processes to other metadata.
	Target int
	// contains filtered or unexported fields
}

func (SingleTargetGroup) Labels added in v0.20.0

func (tg SingleTargetGroup) Labels() model.LabelSet

func (SingleTargetGroup) NumberOfTargets added in v0.20.0

func (tg SingleTargetGroup) NumberOfTargets() int

func (SingleTargetGroup) Source added in v0.20.0

func (tg SingleTargetGroup) Source() string

func (SingleTargetGroup) String added in v0.20.0

func (tg SingleTargetGroup) String() string

type StaticConfig

type StaticConfig []Group

type SystemdConfig

type SystemdConfig struct{}

func NewSystemdConfig

func NewSystemdConfig() *SystemdConfig

func (*SystemdConfig) Name

func (c *SystemdConfig) Name() string

func (*SystemdConfig) NewDiscoverer

func (c *SystemdConfig) NewDiscoverer(d DiscovererOptions) (Discoverer, error)

type SystemdDiscoverer

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

func (*SystemdDiscoverer) Run

func (d *SystemdDiscoverer) Run(ctx context.Context, up chan<- []Group) error

Directories

Path Synopsis
Package systemd provides access to systemd via D-Bus using Unix domain sockets as a transport.
Package systemd provides access to systemd via D-Bus using Unix domain sockets as a transport.

Jump to

Keyboard shortcuts

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