MySQL 8.0.39
Source Code Documentation
MysqlRoutingClassicConnectionBase Class Reference

#include <classic_connection_base.h>

Inheritance diagram for MysqlRoutingClassicConnectionBase:
[legend]

Public Types

enum class  FromEither { None , Started , RecvedFromClient , RecvedFromServer }
 
- Public Types inherited from MySQLRoutingConnectionBase
using clock_type = std::chrono::system_clock
 
using time_point_type = clock_type::time_point
 

Public Member Functions

std::shared_ptr< MysqlRoutingClassicConnectionBasegetptr ()
 
void on_handshake_received ()
 
void on_handshake_aborted ()
 
SslMode source_ssl_mode () const
 
SslMode dest_ssl_mode () const
 
std::string get_client_address () const override
 Returns address of client which connected to router. More...
 
std::string get_server_address () const override
 Returns address of server to which connection is established. More...
 
void disconnect () override
 
virtual void async_run ()
 
void send_server_failed (std::error_code ec, bool call_finish=true)
 
void recv_server_failed (std::error_code ec, bool call_finish=true)
 
void send_client_failed (std::error_code ec, bool call_finish=true)
 
void recv_client_failed (std::error_code ec, bool call_finish=true)
 
void server_socket_failed (std::error_code ec, bool call_finish=true)
 
virtual void client_socket_failed (std::error_code ec, bool call_finish=true)
 
void resume ()
 
void push_processor (std::unique_ptr< BasicProcessor > processor)
 
void pop_processor ()
 
stdx::expected< void, std::error_code > track_session_changes (net::const_buffer session_trackers, classic_protocol::capabilities::value_type caps, bool ignore_some_state_changed=false)
 
ClassicProtocolStateclient_protocol ()
 
const ClassicProtocolStateclient_protocol () const
 
ClassicProtocolStateserver_protocol ()
 
const ClassicProtocolStateserver_protocol () const
 
const ProtocolSplicerBasesocket_splicer () const
 
ProtocolSplicerBasesocket_splicer ()
 
std::string get_destination_id () const override
 
void destination_id (const std::string &id)
 
bool authenticated () const
 check if the connection is authenticated. More...
 
void authenticated (bool v)
 
bool connection_sharing_possible () const
 check if connection sharing is possible. More...
 
bool connection_sharing_allowed () const
 check if connection sharing is allowed. More...
 
void connection_sharing_allowed_reset ()
 reset the connection-sharing state. More...
 
bool greeting_from_router () const
 if the router is sending the initial server-greeting. More...
 
void requires_tls (bool v)
 
bool requires_tls () const
 
void some_state_changed (bool v)
 
RouteDestinationdestinations ()
 
Destinationscurrent_destinations ()
 
void collation_connection_maybe_dirty (bool val)
 
bool collation_connection_maybe_dirty () const
 
ExecutionContextexecution_context ()
 
const ExecutionContextexecution_context () const
 
void trace (Tracer::Event e)
 
Tracertracer ()
 
net::steady_timerread_timer ()
 
net::steady_timerconnect_timer ()
 
void connect_error_code (const std::error_code &ec)
 
std::error_code connect_error_code () const
 
void diagnostic_area_changed (bool diagnostic_area_changed)
 
bool diagnostic_area_changed () const
 
void recv_from_either (FromEither v)
 
FromEither recv_from_either () const
 
- Public Member Functions inherited from MySQLRoutingConnectionBase
 MySQLRoutingConnectionBase (MySQLRoutingContext &context, std::function< void(MySQLRoutingConnectionBase *)> remove_callback)
 
virtual ~MySQLRoutingConnectionBase ()=default
 
MySQLRoutingContextcontext ()
 
const MySQLRoutingContextcontext () const
 
std::size_t get_bytes_up () const
 
std::size_t get_bytes_down () const
 
time_point_type get_started () const
 
time_point_type get_connected_to_server () const
 
time_point_type get_last_sent_to_server () const
 
time_point_type get_last_received_from_server () const
 
Stats get_stats () const
 
void transfered_to_server (size_t bytes)
 
void transfered_to_client (size_t bytes)
 
void disassociate ()
 
void accepted ()
 
virtual void connected ()
 
template<class F >
auto disconnect_request (F &&f)
 
bool disconnect_requested () const
 

Static Public Member Functions

template<typename... Args>
static std::shared_ptr< MysqlRoutingClassicConnectionBasecreate (Args &&... args)
 
static stdx::expected< size_t, std::error_code > encode_error_packet (std::vector< uint8_t > &error_frame, const uint8_t seq_id, const classic_protocol::capabilities::value_type caps, const uint16_t error_code, const std::string &msg, const std::string &sql_state)
 

Protected Types

enum class  Function { kLoop , kFinish }
 

Protected Member Functions

 MysqlRoutingClassicConnectionBase (MySQLRoutingContext &context, RouteDestination *route_destination, std::unique_ptr< ConnectionBase > client_connection, std::unique_ptr< RoutingConnectionBase > client_routing_connection, std::function< void(MySQLRoutingConnectionBase *)> remove_callback)
 
void call_next_function (Function next)
 

Private Member Functions

void trace_and_call_function (Tracer::Event::Direction dir, std::string_view stage, Function func)
 
void async_send_client (Function next)
 
void async_recv_client (Function next)
 
void async_send_server (Function next)
 
void async_recv_server (Function next)
 
void async_recv_both (Function next)
 
void async_send_client_and_finish ()
 
void async_wait_client_closed ()
 
void async_wait_send_server (Function next)
 
void server_side_client_greeting ()
 
void loop ()
 
void finish ()
 
virtual void done ()
 

Private Attributes

std::vector< std::unique_ptr< BasicProcessor > > processors_
 
int active_work_ {0}
 
bool authenticated_ {false}
 
RouteDestinationroute_destination_
 
Destinations destinations_
 
std::unique_ptr< ProtocolSplicerBasesocket_splicer_
 
std::string destination_id_
 
bool in_handshake_ {true}
 client side handshake isn't finished yet. More...
 
std::optional< classic_protocol::session_track::TransactionStatetrx_state_
 
std::optional< classic_protocol::session_track::TransactionCharacteristicstrx_characteristics_
 
bool some_state_changed_ {false}
 
bool collation_connection_maybe_dirty_ {false}
 
bool requires_tls_ {true}
 
ExecutionContext exec_ctx_
 
Tracer tracer_ {false}
 
net::steady_timer read_timer_
 
net::steady_timer connect_timer_
 
std::error_code connect_ec_ {}
 
bool diagnostic_area_changed_ {}
 
FromEither recv_from_either_ {FromEither::None}
 

Additional Inherited Members

- Protected Attributes inherited from MySQLRoutingConnectionBase
MySQLRoutingContextcontext_
 wrapper for common data used by all routing threads More...
 
std::function< void(MySQLRoutingConnectionBase *)> remove_callback_
 callback that is called when thread of execution completes More...
 
Monitor< Statsstats_ {{}}
 
Monitor< bool > disconnect_ {{}}
 

Member Enumeration Documentation

◆ FromEither

Enumerator
None 
Started 
RecvedFromClient 
RecvedFromServer 

◆ Function

enum class MysqlRoutingClassicConnectionBase::Function
strongprotected
Enumerator
kLoop 
kFinish 

Constructor & Destructor Documentation

◆ MysqlRoutingClassicConnectionBase()

MysqlRoutingClassicConnectionBase::MysqlRoutingClassicConnectionBase ( MySQLRoutingContext context,
RouteDestination route_destination,
std::unique_ptr< ConnectionBase client_connection,
std::unique_ptr< RoutingConnectionBase client_routing_connection,
std::function< void(MySQLRoutingConnectionBase *)>  remove_callback 
)
inlineprotected

Member Function Documentation

◆ async_recv_both()

void MysqlRoutingClassicConnectionBase::async_recv_both ( Function  next)
private

◆ async_recv_client()

void MysqlRoutingClassicConnectionBase::async_recv_client ( Function  next)
private

◆ async_recv_server()

void MysqlRoutingClassicConnectionBase::async_recv_server ( Function  next)
private

◆ async_run()

virtual void MysqlRoutingClassicConnectionBase::async_run ( )
inlinevirtual

Reimplemented in MysqlRoutingClassicConnection.

◆ async_send_client()

void MysqlRoutingClassicConnectionBase::async_send_client ( Function  next)
private

◆ async_send_client_and_finish()

void MysqlRoutingClassicConnectionBase::async_send_client_and_finish ( )
private

◆ async_send_server()

void MysqlRoutingClassicConnectionBase::async_send_server ( Function  next)
private

◆ async_wait_client_closed()

void MysqlRoutingClassicConnectionBase::async_wait_client_closed ( )
private

◆ async_wait_send_server()

void MysqlRoutingClassicConnectionBase::async_wait_send_server ( Function  next)
private

◆ authenticated() [1/2]

bool MysqlRoutingClassicConnectionBase::authenticated ( ) const
inline

check if the connection is authenticated.

'true' after the initial handshake and change-user finished with "ok". 'false' at connection start and after change-user is started.

Return values
trueif the connection is authenticated.
Returns
false otherwise

◆ authenticated() [2/2]

void MysqlRoutingClassicConnectionBase::authenticated ( bool  v)
inline

◆ call_next_function()

void MysqlRoutingClassicConnectionBase::call_next_function ( Function  next)
inlineprotected

◆ client_protocol() [1/2]

ClassicProtocolState * MysqlRoutingClassicConnectionBase::client_protocol ( )
inline

◆ client_protocol() [2/2]

const ClassicProtocolState * MysqlRoutingClassicConnectionBase::client_protocol ( ) const
inline

◆ client_socket_failed()

void MysqlRoutingClassicConnectionBase::client_socket_failed ( std::error_code  ec,
bool  call_finish = true 
)
virtual

◆ collation_connection_maybe_dirty() [1/2]

bool MysqlRoutingClassicConnectionBase::collation_connection_maybe_dirty ( ) const
inline

◆ collation_connection_maybe_dirty() [2/2]

void MysqlRoutingClassicConnectionBase::collation_connection_maybe_dirty ( bool  val)
inline

◆ connect_error_code() [1/2]

std::error_code MysqlRoutingClassicConnectionBase::connect_error_code ( ) const
inline

◆ connect_error_code() [2/2]

void MysqlRoutingClassicConnectionBase::connect_error_code ( const std::error_code &  ec)
inline

◆ connect_timer()

net::steady_timer & MysqlRoutingClassicConnectionBase::connect_timer ( )
inline

◆ connection_sharing_allowed()

bool MysqlRoutingClassicConnectionBase::connection_sharing_allowed ( ) const

check if connection sharing is allowed.

  • connection sharing is possible.
  • no active transaction
  • no SET TRANSACTION

◆ connection_sharing_allowed_reset()

void MysqlRoutingClassicConnectionBase::connection_sharing_allowed_reset ( )

reset the connection-sharing state.

  • after COM_RESET_CONNECTION::ok
  • after COM_CHANGE_USER::ok

◆ connection_sharing_possible()

bool MysqlRoutingClassicConnectionBase::connection_sharing_possible ( ) const

check if connection sharing is possible.

  • the configuration enabled it

◆ create()

template<typename... Args>
static std::shared_ptr< MysqlRoutingClassicConnectionBase > MysqlRoutingClassicConnectionBase::create ( Args &&...  args)
inlinestatic

◆ current_destinations()

Destinations & MysqlRoutingClassicConnectionBase::current_destinations ( )
inline

◆ dest_ssl_mode()

SslMode MysqlRoutingClassicConnectionBase::dest_ssl_mode ( ) const
inline

◆ destination_id()

void MysqlRoutingClassicConnectionBase::destination_id ( const std::string &  id)
inline

◆ destinations()

RouteDestination * MysqlRoutingClassicConnectionBase::destinations ( )
inline

◆ diagnostic_area_changed() [1/2]

bool MysqlRoutingClassicConnectionBase::diagnostic_area_changed ( ) const
inline

◆ diagnostic_area_changed() [2/2]

void MysqlRoutingClassicConnectionBase::diagnostic_area_changed ( bool  diagnostic_area_changed)
inline

◆ disconnect()

void MysqlRoutingClassicConnectionBase::disconnect ( )
overridevirtual

◆ done()

void MysqlRoutingClassicConnectionBase::done ( )
privatevirtual

◆ encode_error_packet()

stdx::expected< size_t, std::error_code > MysqlRoutingClassicConnectionBase::encode_error_packet ( std::vector< uint8_t > &  error_frame,
const uint8_t  seq_id,
const classic_protocol::capabilities::value_type  caps,
const uint16_t  error_code,
const std::string &  msg,
const std::string &  sql_state 
)
static

◆ execution_context() [1/2]

ExecutionContext & MysqlRoutingClassicConnectionBase::execution_context ( )
inline

◆ execution_context() [2/2]

const ExecutionContext & MysqlRoutingClassicConnectionBase::execution_context ( ) const
inline

◆ finish()

void MysqlRoutingClassicConnectionBase::finish ( )
private

◆ get_client_address()

std::string MysqlRoutingClassicConnectionBase::get_client_address ( ) const
inlineoverridevirtual

Returns address of client which connected to router.

Returns
address of client

Implements MySQLRoutingConnectionBase.

◆ get_destination_id()

std::string MysqlRoutingClassicConnectionBase::get_destination_id ( ) const
inlineoverridevirtual

◆ get_server_address()

std::string MysqlRoutingClassicConnectionBase::get_server_address ( ) const
inlineoverridevirtual

Returns address of server to which connection is established.

Returns
address of server

Implements MySQLRoutingConnectionBase.

◆ getptr()

std::shared_ptr< MysqlRoutingClassicConnectionBase > MysqlRoutingClassicConnectionBase::getptr ( )
inline

◆ greeting_from_router()

bool MysqlRoutingClassicConnectionBase::greeting_from_router ( ) const
inline

if the router is sending the initial server-greeting.

if true, the router sends the initial greeting to the client, if false, the server is sending the initial greeting and router is forward it.

◆ loop()

void MysqlRoutingClassicConnectionBase::loop ( )
private

◆ on_handshake_aborted()

void MysqlRoutingClassicConnectionBase::on_handshake_aborted ( )

◆ on_handshake_received()

void MysqlRoutingClassicConnectionBase::on_handshake_received ( )

◆ pop_processor()

void MysqlRoutingClassicConnectionBase::pop_processor ( )
inline

◆ push_processor()

void MysqlRoutingClassicConnectionBase::push_processor ( std::unique_ptr< BasicProcessor processor)
inline

◆ read_timer()

net::steady_timer & MysqlRoutingClassicConnectionBase::read_timer ( )
inline

◆ recv_client_failed()

void MysqlRoutingClassicConnectionBase::recv_client_failed ( std::error_code  ec,
bool  call_finish = true 
)

◆ recv_from_either() [1/2]

FromEither MysqlRoutingClassicConnectionBase::recv_from_either ( ) const
inline

◆ recv_from_either() [2/2]

void MysqlRoutingClassicConnectionBase::recv_from_either ( FromEither  v)
inline

◆ recv_server_failed()

void MysqlRoutingClassicConnectionBase::recv_server_failed ( std::error_code  ec,
bool  call_finish = true 
)

◆ requires_tls() [1/2]

bool MysqlRoutingClassicConnectionBase::requires_tls ( ) const
inline

◆ requires_tls() [2/2]

void MysqlRoutingClassicConnectionBase::requires_tls ( bool  v)
inline

◆ resume()

void MysqlRoutingClassicConnectionBase::resume ( )
inline

◆ send_client_failed()

void MysqlRoutingClassicConnectionBase::send_client_failed ( std::error_code  ec,
bool  call_finish = true 
)

◆ send_server_failed()

void MysqlRoutingClassicConnectionBase::send_server_failed ( std::error_code  ec,
bool  call_finish = true 
)

◆ server_protocol() [1/2]

ClassicProtocolState * MysqlRoutingClassicConnectionBase::server_protocol ( )
inline

◆ server_protocol() [2/2]

const ClassicProtocolState * MysqlRoutingClassicConnectionBase::server_protocol ( ) const
inline

◆ server_side_client_greeting()

void MysqlRoutingClassicConnectionBase::server_side_client_greeting ( )
private

◆ server_socket_failed()

void MysqlRoutingClassicConnectionBase::server_socket_failed ( std::error_code  ec,
bool  call_finish = true 
)

◆ socket_splicer() [1/2]

ProtocolSplicerBase * MysqlRoutingClassicConnectionBase::socket_splicer ( )
inline

◆ socket_splicer() [2/2]

const ProtocolSplicerBase * MysqlRoutingClassicConnectionBase::socket_splicer ( ) const
inline

◆ some_state_changed()

void MysqlRoutingClassicConnectionBase::some_state_changed ( bool  v)
inline

◆ source_ssl_mode()

SslMode MysqlRoutingClassicConnectionBase::source_ssl_mode ( ) const
inline

◆ trace()

void MysqlRoutingClassicConnectionBase::trace ( Tracer::Event  e)
inline

◆ trace_and_call_function()

void MysqlRoutingClassicConnectionBase::trace_and_call_function ( Tracer::Event::Direction  dir,
std::string_view  stage,
MysqlRoutingClassicConnectionBase::Function  func 
)
private

◆ tracer()

Tracer & MysqlRoutingClassicConnectionBase::tracer ( )
inline

◆ track_session_changes()

stdx::expected< void, std::error_code > MysqlRoutingClassicConnectionBase::track_session_changes ( net::const_buffer  session_trackers,
classic_protocol::capabilities::value_type  caps,
bool  ignore_some_state_changed = false 
)

Member Data Documentation

◆ active_work_

int MysqlRoutingClassicConnectionBase::active_work_ {0}
private

◆ authenticated_

bool MysqlRoutingClassicConnectionBase::authenticated_ {false}
private

◆ collation_connection_maybe_dirty_

bool MysqlRoutingClassicConnectionBase::collation_connection_maybe_dirty_ {false}
private

◆ connect_ec_

std::error_code MysqlRoutingClassicConnectionBase::connect_ec_ {}
private

◆ connect_timer_

net::steady_timer MysqlRoutingClassicConnectionBase::connect_timer_
private

◆ destination_id_

std::string MysqlRoutingClassicConnectionBase::destination_id_
private

◆ destinations_

Destinations MysqlRoutingClassicConnectionBase::destinations_
private

◆ diagnostic_area_changed_

bool MysqlRoutingClassicConnectionBase::diagnostic_area_changed_ {}
private

◆ exec_ctx_

ExecutionContext MysqlRoutingClassicConnectionBase::exec_ctx_
private

◆ in_handshake_

bool MysqlRoutingClassicConnectionBase::in_handshake_ {true}
private

client side handshake isn't finished yet.

◆ processors_

std::vector<std::unique_ptr<BasicProcessor> > MysqlRoutingClassicConnectionBase::processors_
private

◆ read_timer_

net::steady_timer MysqlRoutingClassicConnectionBase::read_timer_
private

◆ recv_from_either_

FromEither MysqlRoutingClassicConnectionBase::recv_from_either_ {FromEither::None}
private

◆ requires_tls_

bool MysqlRoutingClassicConnectionBase::requires_tls_ {true}
private

◆ route_destination_

RouteDestination* MysqlRoutingClassicConnectionBase::route_destination_
private

◆ socket_splicer_

std::unique_ptr<ProtocolSplicerBase> MysqlRoutingClassicConnectionBase::socket_splicer_
private

◆ some_state_changed_

bool MysqlRoutingClassicConnectionBase::some_state_changed_ {false}
private

◆ tracer_

Tracer MysqlRoutingClassicConnectionBase::tracer_ {false}
private

◆ trx_characteristics_

std::optional<classic_protocol::session_track::TransactionCharacteristics> MysqlRoutingClassicConnectionBase::trx_characteristics_
private

◆ trx_state_

std::optional<classic_protocol::session_track::TransactionState> MysqlRoutingClassicConnectionBase::trx_state_
private

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