Documentation ¶
Overview ¶
Package etcd provides a config getter for etcd v3 key/value stores.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Getter ¶
type Getter struct { config.GetterAsOption // contains filtered or unexported fields }
Getter represents a getter from an etcd v3 key/value store. It is assumed that the relevant configuration is located within a section of the etcd keyspace with a fixed key prefix, e.g. /my/app/config/.
func New ¶
New creates a new etcd getter for the given prefix, and loads the configuration. The prefix defines the root of the configuration in the etcd space. The ctx covers the initial loading of configuration.
func (*Getter) Close ¶
Close closes the getters connection to the server. This automatically closes any active watchers. The current configuration snapshot can still be accessed via Get.
func (*Getter) NewWatcher ¶
func (g *Getter) NewWatcher(done <-chan struct{}) config.GetterWatcher
NewWatcher creates a watcher goroutine if watcher was enabled during construction.
type Option ¶
type Option func(*Getter)
Option is a function which modifies an Etcd getter at construction time.
func WithClient ¶
WithClient sets the etcd client. The default is constructed from the clientConfig.
func WithClientConfig ¶
WithClientConfig sets the configuration of the etcd client. The default is an empty config with one endpoint - "localhost:2379".
func WithEndpoint ¶
WithEndpoint sets the endpoint URL of the client port of the etcd server. The default endpoint is "localhost:2379".
func WithKeyReplacer ¶
WithKeyReplacer sets the replacer used to map from etcd space to config space. The default replaces '/' in the etcd space with '.' in the config space.
func WithListSplitter ¶
WithListSplitter splits slice fields stored as strings in the etcd space. The default splitter separates on ",".
func WithWatcher ¶
func WithWatcher() Option
WithWatcher is an Option that enables watching of the etcd. This is an option to ensure it can only set at construction time, so the watcher is a singleton.