26#ifndef MYSQLROUTER_ROUTING_COMPONENT_INCLUDED
27#define MYSQLROUTER_ROUTING_COMPONENT_INCLUDED
38#include "connection.h"
53 std::string get_bind_address()
const;
54 uint16_t get_bind_port()
const;
58 std::string get_destination_cluster_name()
const;
59 std::string get_destination_replicaset_name()
const;
63 uint64_t get_max_connect_errors()
const;
65 std::string get_name()
const;
67 std::string get_protocol_name()
const;
71 explicit operator bool() const
noexcept {
return r_.operator bool(); }
73 std::vector<std::string> get_blocked_client_hosts()
const;
80 ConnData(std::string src, std::string dst, std::size_t bytes_up,
85 : src(
std::move(src)),
88 bytes_down(bytes_down),
90 connected_to_server(connected_to_server),
91 last_sent_to_server(last_sent_to_server),
92 last_received_from_server(last_received_from_server) {}
119 std::vector<ConnData> get_connections()
const;
122 int get_active_connections()
const;
123 int get_total_connections()
const;
125 std::vector<mysql_harness::Destination> get_destination_candidates()
const;
126 SslOptions get_destination_ssl_options()
const;
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 std::optional<std::reference_wrapper<const rapidjson::Document>>
159 routing_guidelines_document()
const;
161 std::optional<rapidjson::Document> routing_guidelines_document_schema()
const;
163 std::vector<std::string> route_names()
const;
165 void set_routing_guidelines(
const std::string &routing_guidelines_document);
167 bool routing_guidelines_initialized()
const;
169 std::shared_ptr<routing_guidelines::Routing_guidelines_engine>
171 std::lock_guard<std::mutex>
lock{routing_guidelines_mtx_};
172 return routing_guidelines_;
176 const std::string &client_endpoint);
184 std::map<std::string, std::weak_ptr<MySQLRoutingBase>>
routes_;
186 uint64_t max_total_connections_{0};
191 std::shared_ptr<routing_guidelines::Routing_guidelines_engine>
192 routing_guidelines_{
nullptr};
static mysql_service_status_t deinit()
Component deinitialization.
Definition: audit_api_message_emit.cc:584
static mysql_service_status_t init()
Component initialization.
Definition: audit_api_message_emit.cc:575
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:70
Definition: routing_component.h:46
std::shared_ptr< MySQLRoutingBase > r_
Definition: routing_component.h:137
MySQLRoutingAPI(std::shared_ptr< MySQLRoutingBase > r)
Definition: routing_component.h:50
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:184
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:190
std::mutex routes_mu_
Definition: routing_component.h:183
std::shared_ptr< routing_guidelines::Routing_guidelines_engine > get_routing_guidelines()
Definition: routing_component.h:170
Definition: connection.h:47
Configuration.
Definition: config_parser.h:253
Definition: expected.h:286
static int get_connection(MEM_ROOT *mem_root, FEDERATED_SHARE *share)
Definition: ha_federated.cc:608
mysql_ssl_mode
Definition: mysql.h:275
net::ip::tcp::socket * get_socket(net::ip::tcp::socket *s)
Definition: connection.h:68
Provides atomic access in shared-exclusive modes.
Definition: shared_spin_lock.h:79
std::chrono::milliseconds milliseconds
Definition: authorize_manager.cc:70
noexcept
The return type for any call_and_catch(f, args...) call where f(args...) returns Type.
Definition: call_and_catch.h:76
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
Define std::hash<Gtid>.
Definition: gtid.h:355
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:75
std::size_t bytes_up
Definition: routing_component.h:97
time_point_type last_sent_to_server
Definition: routing_component.h:102
time_point_type connected_to_server
Definition: routing_component.h:101
std::string dst
Definition: routing_component.h:95
time_point_type started
Definition: routing_component.h:100
std::string src
Definition: routing_component.h:94
std::chrono::time_point< std::chrono::system_clock > time_point_type
Definition: routing_component.h:76
std::size_t bytes_down
Definition: routing_component.h:98
time_point_type last_received_from_server
Definition: routing_component.h:103
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:80
Definition: routing_component.h:106
mysql_ssl_mode ssl_mode
Definition: routing_component.h:107
std::string ca
Definition: routing_component.h:110
std::string crlpath
Definition: routing_component.h:113
std::string tls_version
Definition: routing_component.h:108
std::string key
Definition: routing_component.h:115
std::string curves
Definition: routing_component.h:116
std::string cert
Definition: routing_component.h:114
std::string crl
Definition: routing_component.h:112
std::string capath
Definition: routing_component.h:111
std::string ssl_cipher
Definition: routing_component.h:109
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:791