Sign in to follow this  

Configuration Reload

This topic is 3335 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

1. I am using a std::map to store some values of keys 2. On startup of my function i am loading values to my map 3. I am storing values to my map by a http call which is returning the key and values from a file. 4. Now i have changed my configuration file and i want to reload the config map without restarting my process 5. lots of places i am already accessing this map How safely i can reload my configurations? Please need some idea and help Regards, Samba

Share this post


Link to post
Share on other sites
Quote:
Original post by Kylotan
It's safe to do it anywhere


Not really, changing configuration may mean a lot. Consider "server.port" being changed. It requires you to shut down all sockets, recreate them, taking into consideration failures, then rewire the handlers, take care of timeouts, failed services, potentially cascading failure if port is mis-configured.

What you need is some form of configuration mechanism. All configurable components must implement some for of an interface, such as:
IConfigurable {
void applyConfiguration(Config & c);
}

class Configuration {
void install(IConfigurable * cfg);
void remove(IConfigurable * cfg);

void reloadConfiguration() {
for (every cfg in configurables) {
cfg->applyConfiguration(new_config);
}
}
};


When such a component starts, it registers itself with configuration system. Whenever this configuration changes, applyConfiguration is called, and each implementor of this interface is responsible of properly handling any changes.

Note that if any component incorrectly implements IConfigurable, you'll be left with broken state. This is all complicated further by inter-connected components, where one may depend on another, yet configuration may remove one of the required components.

Share this post


Link to post
Share on other sites
Quote:
Original post by Antheus
Quote:
Original post by Kylotan
It's safe to do it anywhere


Not really, changing configuration may mean a lot.

I suppose I was focusing on the safety of the std::map, since I thought that was the focus of the question. I guess the rest depends exactly on what is being configured.

Share this post


Link to post
Share on other sites

This topic is 3335 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this