Hello Gophers!
Iโm excited to share gorealconf, a library designed to make dynamic configuration administration easy and environment friendly for Go purposes.
With gorealconf, you’ll be able to:
- Dynamically replace configurations with out restarting your app.
- Use type-safe APIs (leveraging Go generics) to keep away from runtime errors.
- Mix a number of configuration sources like Redis, etcd, information, and extra.
- Steadily roll out configuration adjustments with built-in validation and rollback mechanisms.
Examples: Discover Examples
GitHub: gorealconf on GitHub
Right hereโs a fast instance:
kind AppConfig struct {
ServerPort int `json:"server_port"`
Timeout time.Length `json:"timeout"`
}
cfg := gorealconf.New[AppConfig](
gorealconf.WithValidation[AppConfig](func(outdated, new AppConfig) error {
if new.ServerPort < 1024 {
return errors.New("port should be >= 1024")
}
return nil
}),
)
// Look ahead to config adjustments
adjustments, _ := cfg.Watch(context.Background())
go func() {
for newCfg := vary adjustments {
log.Printf("Config up to date: %+v", newCfg)
}
}()
Iโd love to listen to your suggestions or reply any questions you’ve got! Contributions and concepts for future options are all the time welcome.
Cheers,
Samuel