You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ConfigManager notifies other modules with the config change by a channel. There are some bugs:
When a module starts, it must receive an initial config and a channel as its parameters, such as someModule.Init(cfgMgr.GetConfig(), cfgMgr.WatchConfig()). However, between calling GetConfig() and WatchConfig(), there may be a config change, and thus someModule may miss this config change.
ConfigManager notifies all the modules by writing to the channels when config changes. If one module blocks (maybe forever or temporarily), it hangs. If the module blocks forever, such as deadlock or panic, the config change will block forever. But if you add a timeout on writing the channel, the module may miss the config change if it just blocks temporarily, such as busy handling other things.
There's no way to unsubscribe from ConfigManager after calling WatchConfig(). If a module wants to quit, ConfigManager will still try to notify it.
For the 1st problem, one workaround is calling WatchConfig() after GetConfig().
For the 2nd problem, one workaround is to set the channel size to a big enough size and also set a timeout on writing the channel.
For the 3rd problem, one workaround is to add another function to unsubscribe.
If we deprecate the WatchConfig() way and always use GetConfig(), all problems will be solved.
The text was updated successfully, but these errors were encountered:
Development Task
ConfigManager
notifies other modules with the config change by a channel. There are some bugs:someModule.Init(cfgMgr.GetConfig(), cfgMgr.WatchConfig())
. However, between callingGetConfig()
andWatchConfig()
, there may be a config change, and thussomeModule
may miss this config change.ConfigManager
notifies all the modules by writing to the channels when config changes. If one module blocks (maybe forever or temporarily), it hangs. If the module blocks forever, such as deadlock or panic, the config change will block forever. But if you add a timeout on writing the channel, the module may miss the config change if it just blocks temporarily, such as busy handling other things.ConfigManager
after callingWatchConfig()
. If a module wants to quit,ConfigManager
will still try to notify it.For the 1st problem, one workaround is calling
WatchConfig()
afterGetConfig()
.For the 2nd problem, one workaround is to set the channel size to a big enough size and also set a timeout on writing the channel.
For the 3rd problem, one workaround is to add another function to unsubscribe.
If we deprecate the
WatchConfig()
way and always useGetConfig()
, all problems will be solved.The text was updated successfully, but these errors were encountered: