Documentation
¶
Overview ¶
Package provider abstracts external configuration sources (env, CLI, KV, Vault, ...). Providers are second-class citizens of the reload pipeline: their output is merged into the same map[string]any that file discovery produces, after which the merged document is decoded into the user's strongly-typed *T.
The Provider/Event interface itself lives in fastconf/contracts; this package re-exports it (see aliases.go) and ships the built-in Env/CLI/ File implementations.
Index ¶
Constants ¶
const ( PriorityStatic = contracts.PriorityStatic PriorityOverlay = contracts.PriorityOverlay PriorityKV = contracts.PriorityKV PriorityK8s = contracts.PriorityK8s PriorityEnv = contracts.PriorityEnv PriorityCLI = contracts.PriorityCLI )
Re-exported priority constants.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CLIProvider ¶
type CLIProvider struct {
// contains filtered or unexported fields
}
CLIProvider exposes a pre-parsed map (typically built by the user from command-line flags) as the highest-priority static provider. Users wire it up in main() after their flag parsing completes — fastconf does not own the flag set.
func (*CLIProvider) Watch ¶
func (p *CLIProvider) Watch(_ context.Context) (<-chan Event, error)
Watch implements Provider. CLI is fundamentally static for the process lifetime.
func (*CLIProvider) WithPriority ¶
func (p *CLIProvider) WithPriority(prio int) *CLIProvider
WithPriority overrides the default priority.
type EnvProvider ¶
type EnvProvider struct {
// contains filtered or unexported fields
}
EnvProvider reads process environment variables matching a prefix and translates them into a nested map. Conventions:
- Prefix is stripped.
- "__" (double underscore) introduces a nesting level. Single underscore is preserved as part of the key (handles names like APP_FEATURE_FLAGS).
- Keys are lower-cased.
- Values are coerced to bool / int64 / float64 / string in that order.
Example: APP_DATABASE__POOL=20 with prefix "APP_" produces {"database":{"pool":int64(20)}}.
func NewEnv ¶
func NewEnv(prefix string) *EnvProvider
NewEnv builds an EnvProvider with the given prefix (e.g. "APP_") and the default Env priority.
func (*EnvProvider) Watch ¶
func (p *EnvProvider) Watch(_ context.Context) (<-chan Event, error)
Watch implements Provider. Env is not watched.
func (*EnvProvider) WithPriority ¶
func (p *EnvProvider) WithPriority(prio int) *EnvProvider
WithPriority overrides the default priority.
type FileProvider ¶
type FileProvider struct {
// contains filtered or unexported fields
}
FileProvider loads a single auxiliary file (yaml/json) outside the main conf.d/ tree — useful for site-specific overrides like /etc/myapp/override.yaml.
func NewFile ¶
func NewFile(path string, priority int) *FileProvider
NewFile builds a FileProvider. Codec is inferred from the file extension.