-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathexposer.hpp
61 lines (47 loc) · 1.21 KB
/
exposer.hpp
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**
* Copyright Quadrivium LLC
* All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <memory>
#include <boost/asio/io_context.hpp>
#include <boost/asio/ip/tcp.hpp>
#include "handler.hpp"
namespace kagome::metrics {
/**
* @brief an http server interface to expose metrics on request with custom
* request handler
*/
class Exposer {
protected:
using Acceptor = boost::asio::ip::tcp::acceptor;
using Endpoint = boost::asio::ip::tcp::endpoint;
public:
using Context = boost::asio::io_context;
struct Configuration {
Endpoint endpoint{boost::asio::ip::address_v4::any(), 0};
};
/**
* @brief sets handler and takes ownership
*/
void setHandler(const std::shared_ptr<Handler> &handler) {
handler_ = handler;
}
virtual ~Exposer() = default;
/**
* @brief prepare interface for AppStateManager
*/
virtual bool prepare() = 0;
/**
* @brief start interface for AppStateManager
*/
virtual bool start() = 0;
/**
* @brief stop interface for AppStateManager
*/
virtual void stop() = 0;
protected:
std::shared_ptr<Handler> handler_;
};
} // namespace kagome::metrics