Documentation ¶
Overview ¶
Package configstore abstracts the concepts of where instance files get retrieved.
Index ¶
- Variables
- func GetCodec() codec.Codec
- type API
- func (api *API) Collect(mm chan<- prometheus.Metric)
- func (api *API) DeleteConfiguration(rw http.ResponseWriter, r *http.Request)
- func (api *API) Describe(ch chan<- *prometheus.Desc)
- func (api *API) GetConfiguration(rw http.ResponseWriter, r *http.Request)
- func (api *API) ListConfigurations(rw http.ResponseWriter, r *http.Request)
- func (api *API) PutConfiguration(rw http.ResponseWriter, r *http.Request)
- func (api *API) WireAPI(r *mux.Router)
- type Mock
- func (s *Mock) All(ctx context.Context, keep func(key string) bool) (<-chan instance.Config, error)
- func (s *Mock) Close() error
- func (s *Mock) Delete(ctx context.Context, key string) error
- func (s *Mock) Get(ctx context.Context, key string) (instance.Config, error)
- func (s *Mock) List(ctx context.Context) ([]string, error)
- func (s *Mock) Put(ctx context.Context, c instance.Config) (created bool, err error)
- func (s *Mock) Watch() <-chan WatchEvent
- type NotExistError
- type NotUniqueError
- type Remote
- func (r *Remote) All(ctx context.Context, keep func(key string) bool) (<-chan instance.Config, error)
- func (r *Remote) ApplyConfig(cfg kv.Config, enable bool) error
- func (r *Remote) Close() error
- func (r *Remote) Delete(ctx context.Context, key string) error
- func (r *Remote) Get(ctx context.Context, key string) (instance.Config, error)
- func (r *Remote) List(ctx context.Context) ([]string, error)
- func (r *Remote) Put(ctx context.Context, c instance.Config) (bool, error)
- func (r *Remote) Watch() <-chan WatchEvent
- type Store
- type Validator
- type WatchEvent
Constants ¶
This section is empty.
Variables ¶
var ErrNotConnected = fmt.Errorf("not connected to store")
ErrNotConnected is used when a store operation was called but no connection to the store was active.
Functions ¶
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API is an HTTP API to interact with a configstore.
func (*API) Collect ¶
func (api *API) Collect(mm chan<- prometheus.Metric)
Collect implements prometheus.Collector.
func (*API) DeleteConfiguration ¶
func (api *API) DeleteConfiguration(rw http.ResponseWriter, r *http.Request)
DeleteConfiguration deletes a configuration.
func (*API) Describe ¶
func (api *API) Describe(ch chan<- *prometheus.Desc)
Describe implements prometheus.Collector.
func (*API) GetConfiguration ¶
func (api *API) GetConfiguration(rw http.ResponseWriter, r *http.Request)
GetConfiguration gets an individual configuration.
func (*API) ListConfigurations ¶
func (api *API) ListConfigurations(rw http.ResponseWriter, r *http.Request)
ListConfigurations returns a list of configurations.
func (*API) PutConfiguration ¶
func (api *API) PutConfiguration(rw http.ResponseWriter, r *http.Request)
PutConfiguration creates or updates a configuration.
type Mock ¶
type Mock struct { ListFunc func(ctx context.Context) ([]string, error) GetFunc func(ctx context.Context, key string) (instance.Config, error) PutFunc func(ctx context.Context, c instance.Config) (created bool, err error) DeleteFunc func(ctx context.Context, key string) error AllFunc func(ctx context.Context, keep func(key string) bool) (<-chan instance.Config, error) WatchFunc func() <-chan WatchEvent CloseFunc func() error }
Mock is a Mock Store. Useful primarily for testing.
type NotExistError ¶
type NotExistError struct {
Key string
}
NotExistError is used when a config doesn't exist.
type NotUniqueError ¶
type NotUniqueError struct {
ScrapeJob string
}
NotUniqueError is used when two scrape jobs have the same name.
type Remote ¶
type Remote struct {
// contains filtered or unexported fields
}
Remote loads instance files from a remote KV store. The KV store can be swapped out in real time.
func NewRemote ¶
func NewRemote(l log.Logger, reg prometheus.Registerer, cfg kv.Config, enable bool) (*Remote, error)
NewRemote creates a new Remote store that uses a Key-Value client to store and retrieve configs. If enable is true, the store will be immediately connected to. Otherwise, it can be lazily loaded by enabling later through a call to Remote.ApplyConfig.
func (*Remote) All ¶
func (r *Remote) All(ctx context.Context, keep func(key string) bool) (<-chan instance.Config, error)
All retrieves the set of all configs in the store.
func (*Remote) ApplyConfig ¶
ApplyConfig applies the config for a kv client.
func (*Remote) Delete ¶
Delete deletes a config from the KV store. It returns NotExistError if the config doesn't exist.
func (*Remote) Watch ¶
func (r *Remote) Watch() <-chan WatchEvent
Watch watches the Store for changes.
type Store ¶
type Store interface { // List gets the list of config names. List(ctx context.Context) ([]string, error) // Get gets an individual config by name. Get(ctx context.Context, key string) (instance.Config, error) // Put applies a new instance Config to the store. // If the config already exists, created will be false to indicate an // update. Put(ctx context.Context, c instance.Config) (created bool, err error) // Delete deletes a config from the store. Delete(ctx context.Context, key string) error // All retrieves the entire list of instance configs currently // in the store. A filtering "keep" function can be provided to ignore some // configs, which can significantly speed up the operation in some cases. All(ctx context.Context, keep func(key string) bool) (<-chan instance.Config, error) // Watch watches for changed instance Configs. // All callers of Watch receive the same Channel. // // It is not guaranteed that Watch will emit all store events, and Watch // should only be used for best-effort quick convergence with the remote // store. Watch should always be paired with polling All. Watch() <-chan WatchEvent // Close closes the store. Close() error }
Store is some interface to retrieving instance configurations.
type Validator ¶
Validator valides a config before putting it into the store. Validator is allowed to mutate the config and will only be given a copy.
type WatchEvent ¶
WatchEvent is returned by Watch. The Key is the name of the config that was added, updated, or deleted. If the Config was deleted, Config will be nil.