summaryrefslogtreecommitdiffstats
path: root/staging_vespalib/src/vespa/vespalib/net/state_server.h
blob: 63ee899fd842ff2e76fe1297bd1c369fa9a25f9a (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
// Copyright 2016 Yahoo Inc. 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 <memory>
#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:
    typedef std::unique_ptr<StateServer> UP;
    StateServer(int port,
                const HealthProducer &hp,
                MetricsProducer &mp,
                ComponentConfigProducer &ccp);
    int getListenPort() { return _server.port(); }
    JsonHandlerRepo &repo() { return _api.repo(); }
};

} // namespace vespalib