Path: blob/main/pkg/metrics/instance/configstore/store.go
5363 views
// Package configstore abstracts the concepts of where instance files get1// retrieved.2package configstore34import (5"context"67"github.com/grafana/agent/pkg/metrics/instance"8)910// Store is some interface to retrieving instance configurations.11type Store interface {12// List gets the list of config names.13List(ctx context.Context) ([]string, error)1415// Get gets an individual config by name.16Get(ctx context.Context, key string) (instance.Config, error)1718// Put applies a new instance Config to the store.19// If the config already exists, created will be false to indicate an20// update.21Put(ctx context.Context, c instance.Config) (created bool, err error)2223// Delete deletes a config from the store.24Delete(ctx context.Context, key string) error2526// All retrieves the entire list of instance configs currently27// in the store. A filtering "keep" function can be provided to ignore some28// configs, which can significantly speed up the operation in some cases.29All(ctx context.Context, keep func(key string) bool) (<-chan instance.Config, error)3031// Watch watches for changed instance Configs.32// All callers of Watch receive the same Channel.33//34// It is not guaranteed that Watch will emit all store events, and Watch35// should only be used for best-effort quick convergence with the remote36// store. Watch should always be paired with polling All.37Watch() <-chan WatchEvent3839// Close closes the store.40Close() error41}4243// WatchEvent is returned by Watch. The Key is the name of the config that was44// added, updated, or deleted. If the Config was deleted, Config will be nil.45type WatchEvent struct {46Key string47Config *instance.Config48}495051