Kagome
Polkadot Runtime Engine in C++17
|
#include <connection_impl.hpp>
Public Member Functions | |
TelemetryConnectionImpl (std::shared_ptr< boost::asio::io_context > io_context, const TelemetryEndpoint &endpoint, OnConnectedCallback callback, std::shared_ptr< MessagePool > message_pool, std::shared_ptr< libp2p::basic::Scheduler > scheduler) | |
TelemetryConnectionImpl (const TelemetryConnectionImpl &)=delete | |
TelemetryConnectionImpl (TelemetryConnectionImpl &&)=delete | |
void | connect () override |
Initiate connection process. More... | |
const TelemetryEndpoint & | endpoint () const override |
To remind what was the endpoint ;) More... | |
void | send (const std::string &data) override |
void | send (MessageHandle message_handle) override |
bool | isConnected () const override |
Reports connection status. More... | |
void | shutdown () override |
Request graceful connection shutdown. More... | |
Public Member Functions inherited from kagome::telemetry::TelemetryConnection | |
virtual | ~TelemetryConnection ()=default |
Private Types | |
using | TcpStream = boost::beast::tcp_stream |
using | SslStream = boost::beast::ssl_stream< TcpStream > |
template<typename T > | |
using | WsStream = boost::beast::websocket::stream< T > |
using | WsTcpStream = WsStream< TcpStream > |
using | WsSslStream = WsStream< SslStream > |
using | WsTcpStreamPtr = std::unique_ptr< WsTcpStream > |
using | WsSslStreamPtr = std::unique_ptr< WsSslStream > |
Private Member Functions | |
boost::beast::lowest_layer_type< SslStream > & | stream_lowest_layer () |
template<typename WsStreamT > | |
void | write (WsStreamT &ws, MessageHandle message_handle) |
void | onResolve (boost::beast::error_code ec, boost::asio::ip::tcp::resolver::results_type results) |
void | onConnect (boost::beast::error_code ec, boost::asio::ip::tcp::resolver::results_type::endpoint_type endpoint) |
template<typename WsStreamT > | |
void | setOptionsAndRunWsHandshake (WsStreamT &ws) |
void | onSslHandshake (boost::beast::error_code ec) |
void | onHandshake (boost::beast::error_code ec) |
void | releaseQueue () |
void | close () |
void | reconnect () |
Private Attributes | |
std::shared_ptr< boost::asio::io_context > | io_context_ |
const TelemetryEndpoint | endpoint_ |
OnConnectedCallback | callback_ |
std::shared_ptr< MessagePool > | message_pool_ |
std::shared_ptr< libp2p::basic::Scheduler > | scheduler_ |
bool | is_connected_ = false |
bool | shutdown_requested_ = false |
log::Logger | log_ |
std::chrono::seconds | reconnect_timeout_ = kInitialReconnectTimeout |
uint16_t | port_ = 80 |
bool | secure_ = false |
std::string | path_ |
std::string | ws_handshake_hostname_ |
boost::asio::ssl::context | ssl_ctx_ |
boost::asio::ip::tcp::resolver | resolver_ |
boost::variant< WsTcpStreamPtr, WsSslStreamPtr > | ws_ |
volatile bool | busy_ = false |
boost::circular_buffer< MessageHandle > | queue_ |
Static Private Attributes | |
static std::size_t | instance_ = 0 |
Additional Inherited Members | |
Public Types inherited from kagome::telemetry::TelemetryConnection | |
using | OnConnectedCallback = std::function< void(std::shared_ptr< TelemetryConnection >)> |
Telemetry connection class implementation.
Definition at line 43 of file connection_impl.hpp.
|
private |
Definition at line 90 of file connection_impl.hpp.
|
private |
Definition at line 89 of file connection_impl.hpp.
|
private |
Definition at line 94 of file connection_impl.hpp.
|
private |
Definition at line 96 of file connection_impl.hpp.
|
private |
Definition at line 92 of file connection_impl.hpp.
|
private |
Definition at line 93 of file connection_impl.hpp.
|
private |
Definition at line 95 of file connection_impl.hpp.
kagome::telemetry::TelemetryConnectionImpl::TelemetryConnectionImpl | ( | std::shared_ptr< boost::asio::io_context > | io_context, |
const TelemetryEndpoint & | endpoint, | ||
OnConnectedCallback | callback, | ||
std::shared_ptr< MessagePool > | message_pool, | ||
std::shared_ptr< libp2p::basic::Scheduler > | scheduler | ||
) |
Initializes the connection instance
io_context | - io_context to serve the network events |
endpoint | - telemetry endpoint to connect to |
callback | - callback to notify when connection gets established |
message_pool | - the pool to read messages passed by handle |
scheduler | - scheduler for reconnecting in case of line failure |
Definition at line 14 of file connection_impl.cpp.
|
delete |
|
delete |
|
private |
Definition at line 290 of file connection_impl.cpp.
|
overridevirtual |
Initiate connection process.
Implements kagome::telemetry::TelemetryConnection.
Definition at line 36 of file connection_impl.cpp.
|
overridevirtual |
To remind what was the endpoint ;)
Implements kagome::telemetry::TelemetryConnection.
Definition at line 101 of file connection_impl.cpp.
|
overridevirtual |
Reports connection status.
Implements kagome::telemetry::TelemetryConnection.
Definition at line 137 of file connection_impl.cpp.
|
private |
Definition at line 202 of file connection_impl.cpp.
|
private |
Definition at line 267 of file connection_impl.cpp.
|
private |
Definition at line 186 of file connection_impl.cpp.
|
private |
Definition at line 257 of file connection_impl.cpp.
|
private |
Definition at line 301 of file connection_impl.cpp.
|
private |
Definition at line 283 of file connection_impl.cpp.
|
overridevirtual |
Send the line over the connection
data | - data to send, can be disposed immediately after returning |
Implements kagome::telemetry::TelemetryConnection.
Definition at line 105 of file connection_impl.cpp.
|
overridevirtual |
Send the record from the message pool
message_handle | - handle to the record to send |
Implements kagome::telemetry::TelemetryConnection.
Definition at line 116 of file connection_impl.cpp.
|
private |
Definition at line 237 of file connection_impl.cpp.
|
overridevirtual |
Request graceful connection shutdown.
Implements kagome::telemetry::TelemetryConnection.
Definition at line 141 of file connection_impl.cpp.
|
private |
Definition at line 149 of file connection_impl.cpp.
|
private |
Definition at line 157 of file connection_impl.cpp.
|
private |
Definition at line 143 of file connection_impl.hpp.
|
private |
Definition at line 125 of file connection_impl.hpp.
|
private |
Definition at line 124 of file connection_impl.hpp.
|
staticprivate |
Definition at line 142 of file connection_impl.hpp.
|
private |
Definition at line 123 of file connection_impl.hpp.
|
private |
Definition at line 128 of file connection_impl.hpp.
|
private |
Definition at line 130 of file connection_impl.hpp.
|
private |
Definition at line 126 of file connection_impl.hpp.
|
private |
Definition at line 135 of file connection_impl.hpp.
|
private |
Definition at line 133 of file connection_impl.hpp.
|
private |
Definition at line 144 of file connection_impl.hpp.
|
private |
Definition at line 132 of file connection_impl.hpp.
|
private |
Definition at line 139 of file connection_impl.hpp.
|
private |
Definition at line 127 of file connection_impl.hpp.
|
private |
Definition at line 134 of file connection_impl.hpp.
|
private |
Definition at line 129 of file connection_impl.hpp.
|
private |
Definition at line 138 of file connection_impl.hpp.
|
private |
Definition at line 140 of file connection_impl.hpp.
|
private |
Definition at line 136 of file connection_impl.hpp.