discovery

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2021 License: Apache-2.0 Imports: 10 Imported by: 4

Documentation

Overview

Package discovery defines interfaces for service discovery.

Package discovery manages and runs service discovery and saves target configuration files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Factory

type Factory interface {
	// Create creates a new Source ready for collection.
	Create() (Source, error)
}

Factory defines the interface for creating new Source instances.

type Manager

type Manager struct {
	Timeout time.Duration
	// contains filtered or unexported fields
}

Manager executes service discovery then serializes and writes targets to disk.

func NewManager

func NewManager(timeout time.Duration) *Manager

NewManager creates a new manager instance. When calling Run, each registered service should take no longer than Timeout.

func (*Manager) Count

func (m *Manager) Count() int

Count returns the number of services registered.

func (*Manager) Register

func (m *Manager) Register(s Service, output string)

Register accepts a new service. Future calls to Run will discover targets from this service and write them to the file named by output.

func (*Manager) Run

func (m *Manager) Run(ctx context.Context, interval time.Duration)

Run executes discovery for all registered services every interval period. Run returns once ctx is canceled.

type Service

type Service interface {
	// Discover identifies and returns StaticConfig targets from a third-party
	// service.
	Discover(ctx context.Context) ([]StaticConfig, error)
}

Service collects target configurations for the discovery Manager.

type Source

type Source interface {
	// Collect retrieves all targets from a source.
	Collect() error

	// Save writes the targets to the named file.
	Save() error
}

Source defines the interface for collecting targets from various services. New services should implement this interface.

type StaticConfig

type StaticConfig struct {
	// Targets is a list of targets identified by a label set. Each target is
	// uniquely identifiable in the group by its address label.
	Targets []string `json:"targets"`

	// Labels is a set of keys/values that are common across all targets in the
	// StaticConfig.
	Labels map[string]string `json:"labels,omitempty"`
}

StaticConfig represents a set of targets and associated labels. StaticConfig serializes to the "file_sd_config" format. https://prometheus.io/docs/prometheus/latest/configuration/configuration/#<file_sd_config>

Jump to

Keyboard shortcuts

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