Documentation
¶
Overview ¶
Package feeders provides configuration feeders for reading data from various sources including environment variables, JSON, YAML, TOML files, and .env files.
Index ¶
- Variables
- type AffixedEnvFeeder
- type DotEnvFeeder
- type EnvFeeder
- type Feeder
- type InstanceAwareEnvFeeder
- func (f *InstanceAwareEnvFeeder) Feed(structure interface{}) error
- func (f *InstanceAwareEnvFeeder) FeedInstances(instances interface{}) error
- func (f *InstanceAwareEnvFeeder) FeedKey(instanceKey string, structure interface{}) error
- func (f *InstanceAwareEnvFeeder) SetVerboseDebug(enabled bool, logger interface{ ... })
- type InstancePrefixFunc
- type JSONFeeder
- type TenantAffixedEnvFeeder
- type TomlFeeder
- type YamlFeeder
Constants ¶
This section is empty.
Variables ¶
var ErrDotEnvInvalidLineFormat = fmt.Errorf("invalid .env line format")
parseEnvLine parses a single line from the .env file
var ErrEnvEmptyPrefixAndSuffix = errors.New("env: prefix or suffix cannot be empty")
ErrEnvEmptyPrefixAndSuffix indicates that both prefix and suffix cannot be empty
var ErrEnvInvalidStructure = errors.New("env: invalid structure")
ErrEnvInvalidStructure indicates that the provided structure is not valid for environment variable processing
var ErrFieldCannotBeSet = errors.New("field cannot be set")
ErrFieldCannotBeSet indicates that a field cannot be set
var (
ErrInstancesMustBeMap = fmt.Errorf("instances must be a map")
)
Static errors for err113 compliance
Functions ¶
This section is empty.
Types ¶
type AffixedEnvFeeder ¶
type AffixedEnvFeeder struct {
Prefix string
Suffix string
// contains filtered or unexported fields
}
AffixedEnvFeeder is a feeder that reads environment variables with a prefix and/or suffix
func NewAffixedEnvFeeder ¶
func NewAffixedEnvFeeder(prefix, suffix string) AffixedEnvFeeder
NewAffixedEnvFeeder creates a new AffixedEnvFeeder with the specified prefix and suffix
func (AffixedEnvFeeder) Feed ¶
func (f AffixedEnvFeeder) Feed(structure interface{}) error
Feed reads environment variables and populates the provided structure
func (*AffixedEnvFeeder) SetVerboseDebug ¶ added in v1.3.3
func (f *AffixedEnvFeeder) SetVerboseDebug(enabled bool, logger interface{ Debug(msg string, args ...any) })
SetVerboseDebug enables or disables verbose debug logging
type DotEnvFeeder ¶
type DotEnvFeeder struct {
Path string
// contains filtered or unexported fields
}
DotEnvFeeder is a feeder that reads .env files with optional verbose debug logging
func NewDotEnvFeeder ¶
func NewDotEnvFeeder(filePath string) *DotEnvFeeder
NewDotEnvFeeder creates a new DotEnvFeeder that reads from the specified .env file
func (*DotEnvFeeder) Feed ¶ added in v1.3.3
func (f *DotEnvFeeder) Feed(structure interface{}) error
Feed reads the .env file and populates the provided structure
func (*DotEnvFeeder) SetVerboseDebug ¶ added in v1.3.3
func (f *DotEnvFeeder) SetVerboseDebug(enabled bool, logger interface{ Debug(msg string, args ...any) })
SetVerboseDebug enables or disables verbose debug logging
type EnvFeeder ¶
type EnvFeeder struct {
// contains filtered or unexported fields
}
EnvFeeder is a feeder that reads environment variables with optional verbose debug logging
func NewEnvFeeder ¶
func NewEnvFeeder() *EnvFeeder
NewEnvFeeder creates a new EnvFeeder that reads from environment variables
type Feeder ¶ added in v1.2.6
type Feeder interface {
Feed(target interface{}) error
}
Feeder interface for common operations
type InstanceAwareEnvFeeder ¶ added in v1.3.1
type InstanceAwareEnvFeeder struct {
// contains filtered or unexported fields
}
InstanceAwareEnvFeeder is a feeder that can handle environment variables for multiple instances of the same configuration type using instance-specific prefixes
func NewInstanceAwareEnvFeeder ¶ added in v1.3.1
func NewInstanceAwareEnvFeeder(prefixFunc InstancePrefixFunc) *InstanceAwareEnvFeeder
NewInstanceAwareEnvFeeder creates a new instance-aware environment variable feeder
func (*InstanceAwareEnvFeeder) Feed ¶ added in v1.3.1
func (f *InstanceAwareEnvFeeder) Feed(structure interface{}) error
Feed implements the basic Feeder interface for single instances (backward compatibility)
func (*InstanceAwareEnvFeeder) FeedInstances ¶ added in v1.3.1
func (f *InstanceAwareEnvFeeder) FeedInstances(instances interface{}) error
FeedInstances feeds multiple instances of the same configuration type
func (*InstanceAwareEnvFeeder) FeedKey ¶ added in v1.3.1
func (f *InstanceAwareEnvFeeder) FeedKey(instanceKey string, structure interface{}) error
FeedKey implements the ComplexFeeder interface for instance-specific feeding
func (*InstanceAwareEnvFeeder) SetVerboseDebug ¶ added in v1.3.3
func (f *InstanceAwareEnvFeeder) SetVerboseDebug(enabled bool, logger interface{ Debug(msg string, args ...any) })
SetVerboseDebug enables or disables verbose debug logging
type InstancePrefixFunc ¶ added in v1.3.1
InstancePrefixFunc is a function that generates a prefix for an instance key
type JSONFeeder ¶ added in v1.2.6
JSONFeeder is a feeder that reads JSON files with optional verbose debug logging
func NewJSONFeeder ¶ added in v1.2.6
func NewJSONFeeder(filePath string) JSONFeeder
NewJSONFeeder creates a new JSONFeeder that reads from the specified JSON file
func (JSONFeeder) Feed ¶ added in v1.3.3
func (j JSONFeeder) Feed(structure interface{}) error
Feed reads the JSON file and populates the provided structure
func (JSONFeeder) FeedKey ¶ added in v1.2.6
func (j JSONFeeder) FeedKey(key string, target interface{}) error
FeedKey reads a JSON file and extracts a specific key
func (*JSONFeeder) SetVerboseDebug ¶ added in v1.3.3
func (j *JSONFeeder) SetVerboseDebug(enabled bool, logger interface{ Debug(msg string, args ...any) })
SetVerboseDebug enables or disables verbose debug logging
type TenantAffixedEnvFeeder ¶ added in v1.1.0
type TenantAffixedEnvFeeder struct {
*AffixedEnvFeeder
SetPrefixFunc func(string)
SetSuffixFunc func(string)
// contains filtered or unexported fields
}
TenantAffixedEnvFeeder is a feeder that reads environment variables with tenant-specific prefixes and suffixes
func NewTenantAffixedEnvFeeder ¶ added in v1.1.0
func NewTenantAffixedEnvFeeder(prefix, suffix func(string) string) TenantAffixedEnvFeeder
NewTenantAffixedEnvFeeder creates a new TenantAffixedEnvFeeder with the given prefix and suffix functions The prefix and suffix functions are used to modify the prefix and suffix of the environment variables before they are used to set the struct fields The prefix and suffix functions should take a string and return a string The prefix function is used to modify the prefix of the environment variables The suffix function is used to modify the suffix of the environment variables
func (*TenantAffixedEnvFeeder) SetVerboseDebug ¶ added in v1.3.3
func (f *TenantAffixedEnvFeeder) SetVerboseDebug(enabled bool, logger interface{ Debug(msg string, args ...any) })
SetVerboseDebug enables or disables verbose debug logging
type TomlFeeder ¶
TomlFeeder is a feeder that reads TOML files with optional verbose debug logging
func NewTomlFeeder ¶
func NewTomlFeeder(filePath string) TomlFeeder
NewTomlFeeder creates a new TomlFeeder that reads from the specified TOML file
func (TomlFeeder) Feed ¶ added in v1.3.3
func (t TomlFeeder) Feed(structure interface{}) error
Feed reads the TOML file and populates the provided structure
func (TomlFeeder) FeedKey ¶
func (t TomlFeeder) FeedKey(key string, target interface{}) error
FeedKey reads a TOML file and extracts a specific key
func (*TomlFeeder) SetVerboseDebug ¶ added in v1.3.3
func (t *TomlFeeder) SetVerboseDebug(enabled bool, logger interface{ Debug(msg string, args ...any) })
SetVerboseDebug enables or disables verbose debug logging
type YamlFeeder ¶
YamlFeeder is a feeder that reads YAML files with optional verbose debug logging
func NewYamlFeeder ¶
func NewYamlFeeder(filePath string) YamlFeeder
NewYamlFeeder creates a new YamlFeeder that reads from the specified YAML file
func (YamlFeeder) Feed ¶ added in v1.3.3
func (y YamlFeeder) Feed(structure interface{}) error
Feed reads the YAML file and populates the provided structure
func (YamlFeeder) FeedKey ¶
func (y YamlFeeder) FeedKey(key string, target interface{}) error
FeedKey reads a YAML file and extracts a specific key
func (*YamlFeeder) SetVerboseDebug ¶ added in v1.3.3
func (y *YamlFeeder) SetVerboseDebug(enabled bool, logger interface{ Debug(msg string, args ...any) })
SetVerboseDebug enables or disables verbose debug logging