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 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(currentMap, newMap map[string]*types.TargetConfig) *TargetOperation
Click to show internal directories.
Click to hide internal directories.