aboutsummaryrefslogtreecommitdiffstats
path: root/configd/src/apps/sentinel/model-owner.h
blob: d03e7dec06dba2f92885db619c94ad4473cc3c9e (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 ModelOwner {
private:
    std::string _configId;
    config::ConfigSubscriber _subscriber;
    config::ConfigHandle<ModelConfig>::UP _modelHandle;
    std::unique_ptr<ModelConfig> _modelConfig;
public:
    ModelOwner(const std::string &configId);
    virtual ~ModelOwner();
    void start(std::chrono::milliseconds timeout);
    void checkForUpdates();
    std::optional<ModelConfig> getModelConfig();
};

}