aboutsummaryrefslogtreecommitdiffstats
path: root/configd/src/apps/sentinel/env.h
blob: ec3e201cf5e93eb0a9d5032ba0e732d8bac14670 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "cmdq.h"
#include "config-owner.h"
#include "metrics.h"
#include "model-owner.h"
#include "rpcserver.h"
#include "state-api.h"
#include <vespa/vespalib/net/http/state_server.h>

namespace config::sentinel {

/**
 * Environment for config sentinel, with config
 * subscription, rpc server, state server, and
 * metrics.
 **/
class Env {
public:
    Env();
    ~Env();

    ConfigOwner &configOwner() { return _cfgOwner; }
    ModelOwner &modelOwner() { return _modelOwner; }
    CommandQueue &commandQueue() { return _rpcCommandQueue; }
    StartMetrics &metrics() { return _startMetrics; }

    void boot(const std::string &configId);
    void rpcPort(int portnum);
    void statePort(int portnum);

    void notifyConfigUpdated();
private:
    void respondAsEmpty();
    ConfigOwner _cfgOwner;
    ModelOwner _modelOwner;
    CommandQueue _rpcCommandQueue;
    std::unique_ptr<RpcServer> _rpcServer;
    StateApi _stateApi;
    StartMetrics _startMetrics;
    std::unique_ptr<vespalib::StateServer> _stateServer;
    int _statePort;
};

}