Documentation ¶
Index ¶
- func Load(cs Config, c any) error
- func LoadConfigFromFile(filePath string, appConfig any) error
- func LoadConfigFromRigel(etcdEndpoints, configName, schemaName string, appConfig any) error
- func NewRigelClient(etcdEndpoints string) (*rigel.Rigel, error)
- type Config
- type Event
- type File
- type KeyNotFoundError
- type Rigel
- type ValueNotStringError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Load ¶
Load first ensures that the config system valid and accessible. Then it loads the config into c.
func LoadConfigFromFile ¶
func LoadConfigFromRigel ¶
Types ¶
type Config ¶
type Config interface { LoadConfig(c any) error Check() error Get(key string) (string, error) // Watch watches for changes to a key in the storage and sends the events to the provided channel. // The events includes the key and the updated value. // events is the channel to send events when the key's value changes Watch(ctx context.Context, key string, events chan<- Event) error }
Config is an interface that represents a source from which application configuration can be loaded.
type Event ¶ added in v0.6.0
Event represents a change to a key in the storage. Key is the key that was changed Value is the new value of the key
type File ¶
func (*File) Get ¶ added in v0.6.0
Get retrieves a value from the configuration based on the provided key. If the value is a string, it is returned as is. If the value is not a string, it is converted to a string using fmt.Sprintf and returned along with the error ValueNotStringError. If the key is not found in the configuration, an error of type KeyNotFoundError is returned.
func (*File) LoadConfig ¶
type KeyNotFoundError ¶ added in v0.6.0
type KeyNotFoundError struct {
Key string
}
func (*KeyNotFoundError) Error ¶ added in v0.6.0
func (e *KeyNotFoundError) Error() string
type ValueNotStringError ¶ added in v0.6.0
type ValueNotStringError struct { Key string Value interface{} }
func (*ValueNotStringError) Error ¶ added in v0.6.0
func (e *ValueNotStringError) Error() string