can we use it as global config? #1980
-
i have a project that reads some configs from a yaml file and some secrets from env. once bootstrap is finished, it would connect to a grpc service called manager and receive some configs called parameters from it. the parameters would be loaded to each module struct and they use it. now i want to support a model where the manager can call a grpc method from it and update the config on the fly with 0 downtime. (currently, we have to shut down, update configs in manager's database, start the service again, and then the manager sends new configs.), can we use viper to replace it with our current config module and support on-the-fly update of config while different modules are using config everywhere in their struct locally? how? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
As i remember viper has some features to watch the config files so you can update your cfg within runtime using by this. But actually you need to be careful that how you deliver the new updates to your services to prevent inconsistency. Check this out: viper.WatchConfig()
viper.OnConfigChange(func(_ fsnotify.Event) {
loadConfig()
}) |
Beta Was this translation helpful? Give feedback.
As i remember viper has some features to watch the config files so you can update your cfg within runtime using by this.
But actually you need to be careful that how you deliver the new updates to your services to prevent inconsistency.
Check this out: