Documentation
¶
Overview ¶
Package provider defines the config source abstraction.
Providers load configuration from various sources (file, consul, etcd, etc.) and support watching for changes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileProvider ¶
type FileProvider struct {
// contains filtered or unexported fields
}
FileProvider loads config from a local file and watches for changes.
func NewFileProvider ¶
func NewFileProvider(path string) (*FileProvider, error)
NewFileProvider creates a provider that reads from a local file.
func (*FileProvider) Close ¶
func (p *FileProvider) Close() error
Close stops watching and releases resources.
type Provider ¶
type Provider interface {
// Type returns the provider type for logging/debugging.
Type() Type
// Load reads raw config bytes from the source.
Load(ctx context.Context) ([]byte, error)
// Watch starts watching for changes and signals via the returned channel.
// The channel receives a value when config changes.
// Cancel the context to stop watching.
// Returns nil channel if watching is not supported.
Watch(ctx context.Context) (<-chan struct{}, error)
// Close releases any resources held by the provider.
Close() error
}
Provider abstracts config sources.
Implementations must be safe for concurrent use.
func New ¶
func New(opts ProviderConfig) (Provider, error)
New creates a Provider based on ProviderConfig.
type ProviderConfig ¶
type ProviderConfig struct {
// Type specifies the provider type (file, consul, etcd, zookeeper).
Type Type
// Path is the config path (file path or key path).
Path string
// Endpoints for remote providers (consul, etcd, zookeeper).
Endpoints []string
}
ProviderConfig configures provider creation.
Click to show internal directories.
Click to hide internal directories.