aboutsummaryrefslogtreecommitdiffstats
path: root/configd/src/apps/sentinel/model-subscriber.h
blob: 1777e287d4f1e828b974a057378b8be8ac8a37c7 (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
// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/config-model.h>
#include <vespa/config/config.h>
#include <optional>

using cloud::config::ModelConfig;

namespace config::sentinel {

/**
 * Handles config subscription and has a snapshot of current config.
 **/
class ModelSubscriber {
private:
    std::string _configId;
    config::ConfigSubscriber _subscriber;
    config::ConfigHandle<ModelConfig>::UP _modelHandle;
    std::unique_ptr<ModelConfig> _modelConfig;
public:
    ModelSubscriber(const std::string &configId);
    virtual ~ModelSubscriber();
    void start(std::chrono::milliseconds timeout);
    void checkForUpdates();
    std::optional<ModelConfig> getModelConfig();
};

}