etcd

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 20, 2026 License: MIT Imports: 5 Imported by: 0

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 Config

type Config struct {
	Endpoints   []string      // etcd endpoints, e.g. []string{"localhost:2379"}
	DialTimeout time.Duration // timeout for establishing connection
}

Config holds etcd-specific configuration.

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(cfg Config) (*Provider, error)

New creates a new etcd provider connected to the given endpoints.

func (*Provider) Close

func (p *Provider) Close() error

Close disconnects from etcd.

func (*Provider) Get

func (p *Provider) Get(ctx context.Context, key string) (string, error)

Get retrieves the current value for a key from etcd.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL