![]()  | 
  
    MySQL 8.4.7
    
   Source Code Documentation 
   | 
 
Manage Connections from clients to MySQL servers. More...
#include <mysql_routing.h>
Public Member Functions | |
| MySQLRouting (const RoutingConfig &routing_config, net::io_context &io_ctx, const std::string &route_name={}, TlsServerContext *client_ssl_ctx=nullptr, DestinationTlsContext *dest_ssl_ctx=nullptr) | |
| Default constructor.  More... | |
| void | run (mysql_harness::PluginFuncEnv *env) | 
| Runs the service and accept incoming connections.  More... | |
| void | set_destinations_from_csv (const std::string &csv) | 
| Sets the destinations from URI.  More... | |
| void | set_destinations_from_uri (const mysqlrouter::URI &uri) | 
| std::chrono::milliseconds | get_destination_connect_timeout () const noexcept | 
| Returns timeout when connecting to destination.  More... | |
| void | validate_destination_connect_timeout (std::chrono::milliseconds timeout) | 
| Sets timeout when connecting to destination.  More... | |
| int | set_max_connections (int maximum) | 
| Sets maximum active connections.  More... | |
| int | get_max_connections () const noexcept override | 
| Returns maximum active connections.  More... | |
| template<class ClientProtocol > | |
| void | create_connection (typename ClientProtocol::socket client_socket, const typename ClientProtocol::endpoint &client_endpoint) | 
| create new connection to MySQL Server than can handle client's traffic and adds it to connection container.  More... | |
| routing::RoutingStrategy | get_routing_strategy () const override | 
| std::vector< mysql_harness::TCPAddress > | get_destinations () const override | 
| std::vector< MySQLRoutingAPI::ConnData > | get_connections () override | 
| MySQLRoutingConnectionBase * | get_connection (const std::string &) override | 
| RouteDestination * | destinations () | 
| void | disconnect_all () | 
| void | stop_socket_acceptors () override | 
| Stop accepting new connections on a listening socket.  More... | |
| bool | is_accepting_connections () const override | 
| Check if we are accepting connections on a routing socket.  More... | |
| stdx::expected< void, std::string > | start_accepting_connections () override | 
| Start accepting new connections on a listening socket.  More... | |
| stdx::expected< void, std::string > | restart_accepting_connections () override | 
| Start accepting new connections on a listening socket after it has been quarantined for lack of valid destinations.  More... | |
| MySQLRoutingContext & | get_context () override | 
| bool | is_running () const override | 
| mysqlrouter::ServerMode | purpose () const override | 
| get the purpose of connections to this route.  More... | |
  Public Member Functions inherited from MySQLRoutingBase | |
| MySQLRoutingBase ()=default | |
| MySQLRoutingBase (const MySQLRoutingBase &)=default | |
| MySQLRoutingBase (MySQLRoutingBase &&)=default | |
| MySQLRoutingBase & | operator= (const MySQLRoutingBase &)=default | 
| MySQLRoutingBase & | operator= (MySQLRoutingBase &&)=default | 
| virtual | ~MySQLRoutingBase ()=default | 
Private Member Functions | |
| stdx::expected< void, std::string > | run_acceptor (mysql_harness::PluginFuncEnv *env) | 
Static Private Member Functions | |
| static void | set_unix_socket_permissions (const char *socket_file) | 
| Sets unix socket permissions so that the socket is accessible to all users (no-op on Windows)  More... | |
Private Attributes | |
| WaitableMonitor< Nothing > | acceptor_waitable_ {Nothing{}} | 
| Monitor for notifying socket acceptor.  More... | |
| MySQLRoutingContext | context_ | 
| wrapper for data used by all connections  More... | |
| net::io_context & | io_ctx_ | 
| std::unique_ptr< RouteDestination > | destination_ | 
| Destination object to use when getting next connection.  More... | |
| bool | is_destination_standalone_ {false} | 
| routing::RoutingStrategy | routing_strategy_ | 
| Routing strategy to use when getting next destination.  More... | |
| routing::AccessMode | access_mode_ | 
| access_mode of the servers in the routing  More... | |
| int | max_connections_ | 
| Maximum active connections.  More... | |
| AllowedNodesChangeCallbacksListIterator | allowed_nodes_list_iterator_ | 
| used to unregister from subscription on allowed nodes changes  More... | |
| ConnectionContainer | connection_container_ | 
| container for connections  More... | |
| std::atomic< bool > | is_running_ {true} | 
| Information if the routing plugin is still running.  More... | |
| net::steady_timer | accept_port_reopen_retry_timer_ {io_ctx_} | 
| Used when the accepting port is been reopened and it failed, to schedule another retry for standalone-destination(s) route.  More... | |
| std::vector< std::unique_ptr< AcceptingEndpoint > > | accepting_endpoints_ | 
Manage Connections from clients to MySQL servers.
The class MySQLRouter is used to start a service listening on a particular TCP port for incoming MySQL Client connection and route these to a MySQL Server.
| MySQLRouting::MySQLRouting | ( | const RoutingConfig & | routing_config, | 
| net::io_context & | io_ctx, | ||
| const std::string & | route_name = {},  | 
        ||
| TlsServerContext * | client_ssl_ctx = nullptr,  | 
        ||
| DestinationTlsContext * | dest_ssl_ctx = nullptr  | 
        ||
| ) | 
Default constructor.
class MySQLRouting
| routing_config | routing configuration | 
| io_ctx | IO context | 
| route_name | Name of connection routing (can be empty string) | 
| client_ssl_ctx | SSL context of the client side | 
| dest_ssl_ctx | SSL contexts of the destinations | 
| void MySQLRouting::create_connection | ( | typename ClientProtocol::socket | client_socket, | 
| const typename ClientProtocol::endpoint & | client_endpoint | ||
| ) | 
create new connection to MySQL Server than can handle client's traffic and adds it to connection container.
| client_socket | socket used to transfer data to/from client | 
| client_endpoint | endpoint of client | 
      
  | 
  inline | 
| void MySQLRouting::disconnect_all | ( | ) | 
      
  | 
  overridevirtual | 
Implements MySQLRoutingBase.
      
  | 
  overridevirtual | 
Implements MySQLRoutingBase.
      
  | 
  inlineoverridevirtual | 
Implements MySQLRoutingBase.
      
  | 
  inlinenoexcept | 
Returns timeout when connecting to destination.
      
  | 
  overridevirtual | 
Implements MySQLRoutingBase.
      
  | 
  inlineoverridevirtualnoexcept | 
      
  | 
  overridevirtual | 
Implements MySQLRoutingBase.
      
  | 
  overridevirtual | 
Check if we are accepting connections on a routing socket.
| true | if we are accepting connections, false otherwise | 
Implements MySQLRoutingBase.
      
  | 
  inlineoverridevirtual | 
Implements MySQLRoutingBase.
      
  | 
  overridevirtual | 
get the purpose of connections to this route.
"Unavailable" is used for read-write splitting where the purpose is determined per statement, session, ...
A statement over a read-only server connection may end up on a read-write server in case all read-only servers aren't reachable. Even if the server is read-write, the connections purpose is read-only and if the server changes its role from PRIMARY to SECONDARY, these read-only connections will not be abort as a SECONDARY is good enough to serve read-only connections.
Implements MySQLRoutingBase.
      
  | 
  overridevirtual | 
Start accepting new connections on a listening socket after it has been quarantined for lack of valid destinations.
Implements MySQLRoutingBase.
| void MySQLRouting::run | ( | mysql_harness::PluginFuncEnv * | env | ) | 
Runs the service and accept incoming connections.
Runs the connection routing service and starts accepting incoming MySQL client connections.
| std::runtime_error | on errors. | 
      
  | 
  private | 
| void MySQLRouting::set_destinations_from_csv | ( | const std::string & | csv | ) | 
Sets the destinations from URI.
Sets destinations using the given string. The string should be a comma separated list of MySQL servers.
Example of destinations: "10.0.10.5,10.0.11.6:3307"
| csv | destinations as comma-separated-values | 
| void MySQLRouting::set_destinations_from_uri | ( | const mysqlrouter::URI & | uri | ) | 
| int MySQLRouting::set_max_connections | ( | int | maximum | ) | 
Sets maximum active connections.
Sets maximum of active connections. Maximum must be between 1 and 65535.
| std::invalid_argument | when an invalid value was provided. | 
| maximum | Max number of connections allowed | 
      
  | 
  staticprivate | 
Sets unix socket permissions so that the socket is accessible to all users (no-op on Windows)
| socket_file | path to socket file | 
| std::runtime_error | if chmod() inside fails | 
      
  | 
  overridevirtual | 
Start accepting new connections on a listening socket.
Implements MySQLRoutingBase.
      
  | 
  overridevirtual | 
Stop accepting new connections on a listening socket.
Implements MySQLRoutingBase.
| void MySQLRouting::validate_destination_connect_timeout | ( | std::chrono::milliseconds | timeout | ) | 
Sets timeout when connecting to destination.
Checks timeout connecting with destination servers.
| std::invalid_argument | when an invalid value was provided. | 
| timeout | Timeout | 
      
  | 
  private | 
Used when the accepting port is been reopened and it failed, to schedule another retry for standalone-destination(s) route.
      
  | 
  private | 
      
  | 
  private | 
Monitor for notifying socket acceptor.
      
  | 
  private | 
access_mode of the servers in the routing
      
  | 
  private | 
used to unregister from subscription on allowed nodes changes
      
  | 
  private | 
container for connections
      
  | 
  private | 
wrapper for data used by all connections
      
  | 
  private | 
Destination object to use when getting next connection.
      
  | 
  private | 
      
  | 
  private | 
      
  | 
  private | 
Information if the routing plugin is still running.
      
  | 
  private | 
Maximum active connections.
Maximum number of incoming connections that will be accepted by this MySQLRouter instances. There is no maximum for outgoing connections since it is one-to-one with incoming.
      
  | 
  private | 
Routing strategy to use when getting next destination.