1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 07:17:35 +00:00

ConfigServer+LibConfig: Add way for clients to listen for config changes

This patch adds a Config::Listener abstract class that anyone can
inherit from and receive notifications when configuration values change.

We don't yet monitor file system changes, so these only work for changes
made by ConfigServer itself.

In order to receive these notifications, clients must monitor the domain
by calling monitor_domain(). Only pledged domains can be monitored.

Note that the client initiating the change does not get notified.
This commit is contained in:
Andreas Kling 2021-08-26 19:05:50 +02:00
parent 9509f2ff87
commit edf7843409
9 changed files with 188 additions and 15 deletions

View file

@ -24,6 +24,7 @@ private:
explicit ClientConnection(NonnullRefPtr<Core::LocalSocket>, int client_id);
virtual void pledge_domains(Vector<String> const&) override;
virtual void monitor_domain(String const&) override;
virtual Messages::ConfigServer::ReadStringValueResponse read_string_value([[maybe_unused]] String const& domain, [[maybe_unused]] String const& group, [[maybe_unused]] String const& key) override;
virtual Messages::ConfigServer::ReadI32ValueResponse read_i32_value([[maybe_unused]] String const& domain, [[maybe_unused]] String const& group, [[maybe_unused]] String const& key) override;
virtual Messages::ConfigServer::ReadBoolValueResponse read_bool_value([[maybe_unused]] String const& domain, [[maybe_unused]] String const& group, [[maybe_unused]] String const& key) override;
@ -35,6 +36,8 @@ private:
bool m_has_pledged { false };
HashTable<String> m_pledged_domains;
HashTable<String> m_monitored_domains;
};
}