aboutsummaryrefslogtreecommitdiffstats
path: root/configd/src/apps/sentinel/model-owner.h
blob: 05cbb71230cbaa2641999b45b46600a8d34062e5 (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
// Copyright Vespa.ai. 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/subscription/configsubscriber.h>
#include <optional>
#include <mutex>

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::mutex _lock;
    std::unique_ptr<ModelConfig> _modelConfig;
public:
    ModelOwner(const std::string &configId);
    ~ModelOwner();
    void start(std::chrono::milliseconds timeout, bool firstTime);
    void checkForUpdates();
    std::optional<ModelConfig> getModelConfig();
};

}