blob: 7b79f65b1de8113db65a44c04769d2c6d411ae09 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
// 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-model.h>
#include <vespa/config/config.h>
#include <optional>
using cloud::config::SentinelConfig;
using cloud::config::ModelConfig;
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;
ConfigSubscriber _modelSubscriber;
ConfigHandle<ModelConfig>::UP _modelHandle;
std::unique_ptr<ModelConfig> _modelConfig;
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; }
std::optional<ModelConfig> getModelConfig();
};
}
|