diff options
Diffstat (limited to 'configd/src/apps/sentinel/config-owner.h')
-rw-r--r-- | configd/src/apps/sentinel/config-owner.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/configd/src/apps/sentinel/config-owner.h b/configd/src/apps/sentinel/config-owner.h new file mode 100644 index 00000000000..612db7fe9a1 --- /dev/null +++ b/configd/src/apps/sentinel/config-owner.h @@ -0,0 +1,40 @@ +// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#pragma once + +#include <vespa/config-sentinel.h> +#include <vespa/config/config.h> + +using cloud::config::SentinelConfig; + +using config::ConfigSubscriber; +using config::ConfigHandle; + +namespace config::sentinel { + +/** + * Handles config subscription and has a snapshot of current config. + **/ +class ConfigOwner { +private: + ConfigSubscriber _subscriber; + ConfigHandle<SentinelConfig>::UP _sentinelHandle; + + int64_t _currGeneration = -1; + std::unique_ptr<SentinelConfig> _currConfig; + + ConfigOwner(const ConfigOwner&) = delete; + ConfigOwner& operator =(const ConfigOwner&) = delete; + + void doConfigure(); +public: + ConfigOwner(); + virtual ~ConfigOwner(); + void subscribe(const std::string & configId, std::chrono::milliseconds timeout); + bool checkForConfigUpdate(); + bool hasConfig() const { return _currConfig.get() != nullptr; } + const SentinelConfig& getConfig() const { return *_currConfig; } + int64_t getGeneration() const { return _currGeneration; } +}; + +} |