aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib/src/vespa/vespalib/net/http/state_server.h
blob: 2ec5d705e3b8065375c19e509976b6eb3ff9cf98 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "http_server.h"
#include "state_api.h"
#include "json_get_handler.h"
#include "health_producer.h"
#include "metrics_producer.h"
#include "component_config_producer.h"
#include "json_handler_repo.h"

namespace vespalib {

/**
 * An all-in-one server making it simple for applications to serve the
 * 'state' REST API over HTTP.
 **/
class StateServer
{
private:
    StateApi _api;
    HttpServer _server;
    std::vector<JsonHandlerRepo::Token::UP> _tokens;

public:
    using UP = std::unique_ptr<StateServer>;
    StateServer(int port, const HealthProducer &hp, MetricsProducer &mp, ComponentConfigProducer &ccp);
    ~StateServer();
    int getListenPort() { return _server.port(); }
    JsonHandlerRepo &repo() { return _api.repo(); }
};

} // namespace vespalib