26#ifndef ROUTING_MYSQLROUTING_INCLUDED
27#define ROUTING_MYSQLROUTING_INCLUDED
52#include <netinet/in.h>
53#include <netinet/tcp.h>
54#include <sys/socket.h>
71#include "mysql/harness/plugin.h"
94 const std::string &parent_routing_name)
95 : io_ctx_(io_ctx), parent_routing_name_(parent_routing_name) {}
106 virtual std::string
name() = 0;
119 const std::string &parent_routing_name,
120 const std::string &address, uint16_t
port);
124 bool is_open()
const override;
129 std::string
name()
override;
143 const std::string &parent_routing_name,
144 const std::string &socket_name);
148 bool is_open()
const override;
153 std::string
name()
override;
207 const std::string &route_name = {},
234 void set_destinations_from_csv(
const std::string &csv);
243 return context_.get_destination_connect_timeout();
254 void validate_destination_connect_timeout(std::chrono::milliseconds
timeout);
266 int set_max_connections(
int maximum);
281 template <
class ClientProtocol>
282 void create_connection(
284 const typename ClientProtocol::endpoint &client_endpoint);
288 std::vector<mysql_harness::TCPAddress> get_destinations()
const override;
290 std::vector<MySQLRoutingAPI::ConnData> get_connections()
override;
296 void disconnect_all();
301 void stop_socket_acceptors()
override;
308 bool is_accepting_connections()
const override;
332 static void set_unix_socket_permissions(
const char *socket_file);
373 bool is_destination_standalone_{
false};
396 std::atomic<bool> is_running_{
true};
403 FRIEND_TEST(RoutingTests, bug_24841281);
405 FRIEND_TEST(ClassicProtocolRoutingTest, NoValidDestinations);
406 FRIEND_TEST(TestSetupTcpService, single_addr_ok);
407 FRIEND_TEST(TestSetupTcpService, getaddrinfo_fails);
408 FRIEND_TEST(TestSetupTcpService, socket_fails_for_all_addr);
409 FRIEND_TEST(TestSetupTcpService, socket_fails);
410 FRIEND_TEST(TestSetupTcpService, bind_fails);
411 FRIEND_TEST(TestSetupTcpService, listen_fails);
413 FRIEND_TEST(TestSetupTcpService, setsockopt_fails);
414 FRIEND_TEST(TestSetupNamedSocketService, unix_socket_permissions_failure);
Definition: mysql_routing.h:116
std::string address_
Definition: mysql_routing.h:135
uint16_t port_
Definition: mysql_routing.h:136
net::ip::tcp::acceptor service_
Definition: mysql_routing.h:132
net::ip::tcp::endpoint service_endpoint_
Definition: mysql_routing.h:133
Definition: mysql_routing.h:140
local::stream_protocol::acceptor service_
Definition: mysql_routing.h:156
std::string socket_name_
Definition: mysql_routing.h:159
local::stream_protocol::endpoint service_endpoint_
Definition: mysql_routing.h:157
Definition: mysql_routing.h:91
virtual ~AcceptingEndpoint()
Definition: mysql_routing.h:108
virtual stdx::expected< void, std::error_code > setup()=0
virtual void start(MySQLRouting *r, std::list< IoThread > &, WaitableMonitor< Nothing > &waitable)=0
virtual std::string name()=0
std::string parent_routing_name_
Definition: mysql_routing.h:113
net::io_context & io_ctx_
Definition: mysql_routing.h:111
AcceptingEndpoint(const AcceptingEndpoint &)=delete
virtual bool is_open() const =0
AcceptingEndpoint(net::io_context &io_ctx, const std::string &parent_routing_name)
Definition: mysql_routing.h:93
virtual stdx::expected< void, std::error_code > cancel()=0
container for connections to MySQL Server.
Definition: connection_container.h:167
TlsClientContext per destination.
Definition: destination_ssl_context.h:42
Facade to avoid a tight coupling between Routing component and actual routing endpoint implementation...
Definition: mysql_routing_base.h:41
Definition: connection.h:44
MySQLRoutingContext holds data used by MySQLRouting (1 per plugin instances) and MySQLRoutingConnecti...
Definition: context.h:59
Manage Connections from clients to MySQL servers.
Definition: mysql_routing.h:196
std::chrono::milliseconds get_destination_connect_timeout() const noexcept
Returns timeout when connecting to destination.
Definition: mysql_routing.h:242
std::unique_ptr< RouteDestination > destination_
Destination object to use when getting next connection.
Definition: mysql_routing.h:371
MySQLRoutingContext & get_context() override
Definition: mysql_routing.h:338
ConnectionContainer connection_container_
container for connections
Definition: mysql_routing.h:393
routing::AccessMode access_mode_
access_mode of the servers in the routing
Definition: mysql_routing.h:379
AllowedNodesChangeCallbacksListIterator allowed_nodes_list_iterator_
used to unregister from subscription on allowed nodes changes
Definition: mysql_routing.h:390
std::vector< std::unique_ptr< AcceptingEndpoint > > accepting_endpoints_
Definition: mysql_routing.h:418
MySQLRoutingContext context_
wrapper for data used by all connections
Definition: mysql_routing.h:366
net::io_context & io_ctx_
Definition: mysql_routing.h:368
RouteDestination * destinations()
Definition: mysql_routing.h:294
int max_connections_
Maximum active connections.
Definition: mysql_routing.h:387
bool is_running() const override
Definition: mysql_routing.h:340
int get_max_connections() const noexcept override
Returns maximum active connections.
Definition: mysql_routing.h:272
routing::RoutingStrategy routing_strategy_
Routing strategy to use when getting next destination.
Definition: mysql_routing.h:376
Manage destinations for a Connection Routing.
Definition: destination.h:189
virtual mysql_harness::TCPAddress get(const std::string &address, uint16_t port)
Gets destination based on address and port.
Definition: destination.cc:131
route specific configuration.
Definition: routing_config.h:40
TLS Context for the server side.
Definition: tls_server_context.h:51
Monitor can be waited for.
Definition: monitor.h:62
PluginFuncEnv object.
Definition: loader.h:673
Parse and create URIs according to RFC3986.
Definition: uri.h:70
Definition: socket.h:1293
Definition: io_context.h:61
Definition: internet.h:678
Definition: expected.h:286
static int get_connection(MEM_ROOT *mem_root, FEDERATED_SHARE *share)
Definition: ha_federated.cc:608
static void start(mysql_harness::PluginFuncEnv *env)
Definition: http_auth_backend_plugin.cc:180
static void run(mysql_harness::PluginFuncEnv *)
Definition: io_plugin.cc:199
mysql_harness::Plugin ROUTING_PLUGIN_EXPORT harness_plugin_routing
Definition: routing_plugin.cc:587
std::string get_routing_thread_name(const std::string &config_name, const std::string &prefix)
return a short string suitable to be used as a thread name
Definition: mysql_routing_common.cc:30
static bool timeout(bool(*wait_condition)())
Timeout function.
Definition: log0meb.cc:498
ServerMode
Definition: datatypes.h:50
stdx::expected< native_handle_type, error_type > socket(int family, int sock_type, int protocol)
Definition: socket.h:63
RoutingStrategy get_routing_strategy(const std::string &value)
Returns RoutingStrategy for its literal representation.
Definition: routing.cc:71
AccessMode
Definition: routing.h:259
RoutingStrategy
Routing strategies supported by Routing plugin.
Definition: routing.h:265
const mysql_service_registry_t * r
Definition: pfs_example_plugin_employee.cc:86
required uint64 port
Definition: replication_asynchronous_connection_failover.proto:33
#define ROUTING_EXPORT
Definition: routing_export.h:15
#define ROUTING_PLUGIN_EXPORT
Definition: routing_plugin_export.h:15
AllowedNodesChangeCallbacksList::iterator AllowedNodesChangeCallbacksListIterator
Definition: destination.h:65
case opt name
Definition: sslopt-case.h:29
Definition: mysql_routing.h:88