Tuesday, April 22, 2025
HomeGolangIntroducing gorealconf โ€“ Kind-Protected Dynamic Configuration for Go ๐Ÿš€ - Releases

Introducing gorealconf โ€“ Kind-Protected Dynamic Configuration for Go ๐Ÿš€ – Releases


Hello Gophers! :wave:

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.

:file_folder: Examples: Discover Examples
:link: 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

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments