26#ifndef MYSQLROUTER_ROUTING_COMPONENT_INCLUDED
27#define MYSQLROUTER_ROUTING_COMPONENT_INCLUDED
38#include "connection.h"
52 std::string get_bind_address()
const;
53 uint16_t get_bind_port()
const;
57 std::string get_destination_cluster_name()
const;
58 std::string get_destination_replicaset_name()
const;
62 uint64_t get_max_connect_errors()
const;
64 std::string get_name()
const;
66 std::string get_protocol_name()
const;
70 explicit operator bool() const noexcept {
return r_.operator bool(); }
72 std::vector<std::string> get_blocked_client_hosts()
const;
79 ConnData(std::string src, std::string dst, std::size_t bytes_up,
84 : src(
std::move(src)),
87 bytes_down(bytes_down),
89 connected_to_server(connected_to_server),
90 last_sent_to_server(last_sent_to_server),
91 last_received_from_server(last_received_from_server) {}
118 std::vector<ConnData> get_connections()
const;
121 int get_active_connections()
const;
122 int get_total_connections()
const;
124 std::vector<mysql_harness::Destination> get_destination_candidates()
const;
125 SslOptions get_destination_ssl_options()
const;
127 void start_accepting_connections();
128 void restart_accepting_connections();
130 bool is_accepting_connections()
const;
132 void stop_socket_acceptors();
137 std::shared_ptr<MySQLRoutingBase>
r_;
148 void register_route(
const std::string &
name,
149 std::shared_ptr<MySQLRoutingBase>
srv);
151 void erase(
const std::string &
name);
155 uint64_t current_total_connections();
158 const rapidjson::Document &routing_guidelines_document()
const;
160 rapidjson::Document routing_guidelines_document_schema()
const;
162 std::vector<std::string> route_names()
const;
164 void set_routing_guidelines(
const std::string &routing_guidelines_document);
166 bool routing_guidelines_initialized()
const;
168 std::shared_ptr<routing_guidelines::Routing_guidelines_engine>
170 std::lock_guard<std::mutex>
lock{routing_guidelines_mtx_};
171 return routing_guidelines_;
175 const std::string &client_endpoint);
183 std::map<std::string, std::weak_ptr<MySQLRoutingBase>>
routes_;
185 uint64_t max_total_connections_{0};
190 std::shared_ptr<routing_guidelines::Routing_guidelines_engine>
191 routing_guidelines_{
nullptr};
static mysql_service_status_t deinit()
Component deinitialization.
Definition: audit_api_message_emit.cc:575
static mysql_service_status_t init()
Component initialization.
Definition: audit_api_message_emit.cc:566
Definition: base_protocol.h:29
Allows the obervers to register for notifications on the change in the state of the destination nodes...
Definition: destination_nodes_state_notifier.h:71
Definition: routing_component.h:45
std::shared_ptr< MySQLRoutingBase > r_
Definition: routing_component.h:137
MySQLRoutingAPI(std::shared_ptr< MySQLRoutingBase > r)
Definition: routing_component.h:49
MySQLRoutingAPI()=default
Facade to avoid a tight coupling between Routing component and actual routing endpoint implementation...
Definition: mysql_routing_base.h:41
Definition: routing_component.h:140
MySQLRoutingComponent(MySQLRoutingComponent const &)=delete
std::map< std::string, std::weak_ptr< MySQLRoutingBase > > routes_
Definition: routing_component.h:183
uint64_t max_total_connections() const
Definition: routing_component.h:156
MySQLRoutingComponent()=default
void operator=(MySQLRoutingComponent const &)=delete
std::mutex routing_guidelines_mtx_
Definition: routing_component.h:189
std::mutex routes_mu_
Definition: routing_component.h:182
std::shared_ptr< routing_guidelines::Routing_guidelines_engine > get_routing_guidelines()
Definition: routing_component.h:169
Definition: connection.h:47
Configuration.
Definition: config_parser.h:253
static int get_connection(MEM_ROOT *mem_root, FEDERATED_SHARE *share)
Definition: ha_federated.cc:608
mysql_ssl_mode
Definition: mysql.h:272
net::ip::tcp::socket * get_socket(net::ip::tcp::socket *s)
Definition: connection.h:65
Provides atomic access in shared-exclusive modes.
Definition: shared_spin_lock.h:79
std::chrono::milliseconds milliseconds
Definition: authorize_manager.cc:68
bool is_running(const PluginFuncEnv *env) noexcept
Definition: loader.cc:243
stdx::expected< RoutingStrategy, std::error_code > get_routing_strategy(std::string_view value)
Returns RoutingStrategy for its literal representation.
Definition: routing.cc:71
Definition: srv0dynamic_procedures.h:48
Definition: gcs_xcom_synode.h:64
const mysql_service_registry_t * r
Definition: pfs_example_plugin_employee.cc:86
#define ROUTING_EXPORT
Definition: routing_export.h:15
case opt name
Definition: sslopt-case.h:29
Definition: routing_component.h:74
std::size_t bytes_up
Definition: routing_component.h:96
time_point_type last_sent_to_server
Definition: routing_component.h:101
time_point_type connected_to_server
Definition: routing_component.h:100
std::string dst
Definition: routing_component.h:94
time_point_type started
Definition: routing_component.h:99
std::string src
Definition: routing_component.h:93
std::chrono::time_point< std::chrono::system_clock > time_point_type
Definition: routing_component.h:75
std::size_t bytes_down
Definition: routing_component.h:97
time_point_type last_received_from_server
Definition: routing_component.h:102
ConnData(std::string src, std::string dst, std::size_t bytes_up, std::size_t bytes_down, time_point_type started, time_point_type connected_to_server, time_point_type last_sent_to_server, time_point_type last_received_from_server)
Definition: routing_component.h:79
Definition: routing_component.h:105
mysql_ssl_mode ssl_mode
Definition: routing_component.h:106
std::string ca
Definition: routing_component.h:109
std::string crlpath
Definition: routing_component.h:112
std::string tls_version
Definition: routing_component.h:107
std::string key
Definition: routing_component.h:114
std::string curves
Definition: routing_component.h:115
std::string cert
Definition: routing_component.h:113
std::string crl
Definition: routing_component.h:111
std::string capath
Definition: routing_component.h:110
std::string ssl_cipher
Definition: routing_component.h:108
ulong get_max_connections(void)
Get max number of connections.
Definition: sql_thd_api.cc:314
static int started(pax_machine *p)
Definition: xcom_base.cc:759