loaders

package
v0.38.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Loaders = map[string]Initializer{}
View Source
var LoadersTypes = []string{
	"file",
	"consul",
	"docker",
	"http",
}

Functions

func DecodeConfig

func DecodeConfig(src, dst interface{}) error

func Register

func Register(name string, initFn Initializer)

Types

type Initializer

type Initializer func() TargetLoader

type Option

type Option func(TargetLoader)

func WithActions

func WithActions(acts map[string]map[string]interface{}) Option

func WithRegistry

func WithRegistry(reg *prometheus.Registry) Option

func WithTargetsDefaults

func WithTargetsDefaults(fn func(tc *types.TargetConfig) error) Option

type TargetLoader

type TargetLoader interface {
	// Init initializes the target loader given the config, logger and options
	Init(ctx context.Context, cfg map[string]interface{}, l *log.Logger, opts ...Option) error
	// RunOnce runs the loader only once, returning a map of target configs
	RunOnce(ctx context.Context) (map[string]*types.TargetConfig, error)
	// Start starts the target loader, running periodic polls or a long watch.
	// It returns a channel of TargetOperation from which the function caller can
	// receive the added/removed target configs
	Start(context.Context) chan *TargetOperation
	// RegsiterMetrics registers the loader metrics with the provided registry
	RegisterMetrics(*prometheus.Registry)
	// WithActions passes the actions configuration to the target loader
	WithActions(map[string]map[string]interface{})
	// WithTargetsDefaults passes a callback function that sets the target config defaults
	WithTargetsDefaults(func(tc *types.TargetConfig) error)
}

TargetLoader discovers a set of target configurations for gNMIc to run RPCs against. RunOnce should return a map of target configs and is meant to be used with Unary RPCs. Start runs a goroutine in the background that updates added/removed target configs on the returned channel.

type TargetOperation

type TargetOperation struct {
	Add map[string]*types.TargetConfig
	Del []string
}

func Diff

func Diff(m1, m2 map[string]*types.TargetConfig) *TargetOperation

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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