Documentation
¶
Overview ¶
Package etcd implements the provider.Provider interface for etcd configuration backends. It uses etcd's native Watch API with prefix-based watching for efficient event-driven dynamic configuration updates. A single watch call monitors all keys under a common prefix.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider implements the poya Provider interface using etcd's native Watch API.
func New ¶
func New(client *clientv3.Client) *Provider
New creates an etcd provider from a fully-configured etcd client. The caller owns the client and configures every connection option (endpoints, TLS, auth, dial timeout, etc.) directly on clientv3. The provider does not close the client; call clientv3.Client.Close yourself when done, or use Provider.Close which delegates to it.
func (*Provider) Watch ¶
func (p *Provider) Watch(ctx context.Context, keys []string, onChange func(key string, value string)) error
Watch monitors all keys under a common prefix using a single etcd Watch call. It extracts the longest common prefix from the provided keys, watches that prefix, and calls onChange for each key that changes. If the watch is dropped (compaction, a broken connection, the channel closing) it re-reads the current values and re-establishes the watch with exponential backoff, returning only when the context is cancelled.