Kagome
Polkadot Runtime Engine in C++17
kagome::metrics::SessionImpl Class Reference

#include <session_impl.hpp>

Inheritance diagram for kagome::metrics::SessionImpl:
Collaboration diagram for kagome::metrics::SessionImpl:

Public Member Functions

 SessionImpl (Context &context, Configuration config)
 constructor More...
 
 ~SessionImpl () override=default
 
Socketsocket () override
 
void start () override
 starts session More...
 
void respond (Response response) override
 sends response wrapped by http message More...
 
SessionId id () const override
 method to get id of the session More...
 
- Public Member Functions inherited from kagome::metrics::Session
virtual ~Session ()=default
 
void connectOnRequest (std::function< OnRequestSignature > callback)
 connects on request callback More...
 
void processRequest (Request request, std::shared_ptr< Session > session)
 process request message More...
 

Private Types

using Body = boost::beast::http::string_body
 
using Request = boost::beast::http::request< Body >
 
using Response = boost::beast::http::response< Body >
 
using Parser = boost::beast::http::request_parser< Body >
 
using HttpField = boost::beast::http::field
 
using HttpError = boost::beast::http::error
 

Private Member Functions

void stop ()
 stops session More...
 
void handleRequest (Request &&request)
 process http request, compose and execute response More...
 
void asyncRead ()
 asynchronously read http message More...
 
void asyncWrite (Response message)
 sends http message More...
 
void onRead (boost::system::error_code ec, std::size_t size)
 read completion callback More...
 
void onWrite (bool close, boost::system::error_code ec, std::size_t)
 write completion callback More...
 
void reportError (boost::system::error_code ec, std::string_view message)
 reports error code and message More...
 

Private Attributes

boost::asio::strand< boost::asio::io_context::executor_type > strand_
 Strand to ensure the connection's handlers are not called concurrently. More...
 
Configuration config_
 session configuration More...
 
boost::beast::tcp_stream stream_
 stream More...
 
boost::beast::flat_buffer buffer_
 read buffer More...
 
std::shared_ptr< void > res_
 
std::unique_ptr< Parserparser_
 request parser type More...
 
log::Logger logger_
 

Static Private Attributes

static constexpr boost::string_view kServerName = "Kagome"
 

Additional Inherited Members

- Public Types inherited from kagome::metrics::Session
using Body = boost::beast::http::string_body
 
using Request = boost::beast::http::request< Body >
 
using Response = boost::beast::http::response< Body >
 
using Context = boost::asio::io_context
 
using Socket = boost::asio::ip::tcp::socket
 
using ErrorCode = boost::system::error_code
 
using Streambuf = boost::asio::streambuf
 
using Duration = boost::asio::steady_timer::duration
 
using SessionId = uint64_t
 

Detailed Description

Definition at line 18 of file session_impl.hpp.

Member Typedef Documentation

using kagome::metrics::SessionImpl::Body = boost::beast::http::string_body
private

Definition at line 20 of file session_impl.hpp.

using kagome::metrics::SessionImpl::HttpError = boost::beast::http::error
private

Definition at line 25 of file session_impl.hpp.

using kagome::metrics::SessionImpl::HttpField = boost::beast::http::field
private

Definition at line 24 of file session_impl.hpp.

using kagome::metrics::SessionImpl::Parser = boost::beast::http::request_parser<Body>
private

Definition at line 23 of file session_impl.hpp.

using kagome::metrics::SessionImpl::Request = boost::beast::http::request<Body>
private

Definition at line 21 of file session_impl.hpp.

using kagome::metrics::SessionImpl::Response = boost::beast::http::response<Body>
private

Definition at line 22 of file session_impl.hpp.

Constructor & Destructor Documentation

kagome::metrics::SessionImpl::SessionImpl ( Context context,
Configuration  config 
)

constructor

Parameters
socketsocket instance
configsession configuration

Definition at line 12 of file session_impl.cpp.

kagome::metrics::SessionImpl::~SessionImpl ( )
overridedefault

Member Function Documentation

void kagome::metrics::SessionImpl::asyncRead ( )
private

asynchronously read http message

Definition at line 32 of file session_impl.cpp.

void kagome::metrics::SessionImpl::asyncWrite ( Response  message)
private

sends http message

Template Parameters
Messagehttp message type
Parameters
messagehttp message

Definition at line 45 of file session_impl.cpp.

void kagome::metrics::SessionImpl::handleRequest ( Request &&  request)
private

process http request, compose and execute response

Template Parameters
Bodyrequest body type
Parameters
requestrequest

Definition at line 28 of file session_impl.cpp.

SessionId kagome::metrics::SessionImpl::id ( ) const
inlineoverridevirtual

method to get id of the session

Returns
id of the session

Implements kagome::metrics::Session.

Definition at line 55 of file session_impl.hpp.

void kagome::metrics::SessionImpl::onRead ( boost::system::error_code  ec,
std::size_t  size 
)
private

read completion callback

Definition at line 62 of file session_impl.cpp.

void kagome::metrics::SessionImpl::onWrite ( bool  close,
boost::system::error_code  ec,
std::size_t   
)
private

write completion callback

Definition at line 74 of file session_impl.cpp.

void kagome::metrics::SessionImpl::reportError ( boost::system::error_code  ec,
std::string_view  message 
)
private

reports error code and message

Parameters
ecerror code
messageerror message

Definition at line 92 of file session_impl.cpp.

void kagome::metrics::SessionImpl::respond ( Response  response)
overridevirtual

sends response wrapped by http message

Parameters
responsemessage to send

Implements kagome::metrics::Session.

Definition at line 58 of file session_impl.cpp.

Socket& kagome::metrics::SessionImpl::socket ( )
inlineoverridevirtual

Implements kagome::metrics::Session.

Definition at line 36 of file session_impl.hpp.

void kagome::metrics::SessionImpl::start ( )
overridevirtual

starts session

Implements kagome::metrics::Session.

Definition at line 18 of file session_impl.cpp.

void kagome::metrics::SessionImpl::stop ( )
private

stops session

Definition at line 22 of file session_impl.cpp.

Member Data Documentation

boost::beast::flat_buffer kagome::metrics::SessionImpl::buffer_
private

read buffer

Definition at line 108 of file session_impl.hpp.

Configuration kagome::metrics::SessionImpl::config_
private

session configuration

Definition at line 106 of file session_impl.hpp.

constexpr boost::string_view kagome::metrics::SessionImpl::kServerName = "Kagome"
staticprivate

Definition at line 101 of file session_impl.hpp.

log::Logger kagome::metrics::SessionImpl::logger_
private

Definition at line 116 of file session_impl.hpp.

std::unique_ptr<Parser> kagome::metrics::SessionImpl::parser_
private

request parser type

http parser

Definition at line 115 of file session_impl.hpp.

std::shared_ptr<void> kagome::metrics::SessionImpl::res_
private

Definition at line 109 of file session_impl.hpp.

boost::asio::strand<boost::asio::io_context::executor_type> kagome::metrics::SessionImpl::strand_
private

Strand to ensure the connection's handlers are not called concurrently.

Definition at line 104 of file session_impl.hpp.

boost::beast::tcp_stream kagome::metrics::SessionImpl::stream_
private

stream

Definition at line 107 of file session_impl.hpp.


The documentation for this class was generated from the following files: