Kagome
Polkadot Runtime Engine in C++17
exposer.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_CORE_METRICS_EXPOSER_HPP
7 #define KAGOME_CORE_METRICS_EXPOSER_HPP
8 
9 #include <memory>
10 
11 #include <boost/asio/io_context.hpp>
12 #include <boost/asio/ip/tcp.hpp>
13 #include "handler.hpp"
14 
15 namespace kagome::metrics {
16 
21  class Exposer {
22  protected:
23  using Acceptor = boost::asio::ip::tcp::acceptor;
24  using Endpoint = boost::asio::ip::tcp::endpoint;
25 
26  public:
27  using Context = boost::asio::io_context;
28 
29  struct Configuration {
30  Endpoint endpoint{boost::asio::ip::address_v4::any(), 0};
31  };
32 
36  void setHandler(const std::shared_ptr<Handler> &handler) {
37  handler_ = handler;
38  }
39 
40  virtual ~Exposer() = default;
41 
45  virtual bool prepare() = 0;
46 
50  virtual bool start() = 0;
51 
55  virtual void stop() = 0;
56 
57  protected:
58  std::shared_ptr<Handler> handler_;
59  };
60 
61 } // namespace kagome::metrics
62 
63 #endif // KAGOME_CORE_METRICS_EXPOSER_HPP
void setHandler(const std::shared_ptr< Handler > &handler)
sets handler and takes ownership
Definition: exposer.hpp:36
virtual bool start()=0
start interface for AppStateManager
virtual ~Exposer()=default
boost::asio::io_context Context
Definition: exposer.hpp:27
boost::asio::ip::tcp::acceptor Acceptor
Definition: exposer.hpp:23
boost::asio::ip::tcp::endpoint Endpoint
Definition: exposer.hpp:24
std::shared_ptr< Handler > handler_
Definition: exposer.hpp:58
virtual bool prepare()=0
prepare interface for AppStateManager
an http server interface to expose metrics on request with custom request handler ...
Definition: exposer.hpp:21
virtual void stop()=0
stop interface for AppStateManager