26#ifndef ROUTING_DESTINATION_INCLUDED
27#define ROUTING_DESTINATION_INCLUDED
35#include <system_error>
58 const std::string &)>;
64 AllowedNodesChangeCallbacksList::iterator;
67 std::function<stdx::expected<void, std::string>()>;
223 virtual void add(
const std::string &address, uint16_t
port);
232 virtual void remove(
const std::string &address, uint16_t
port);
256 virtual void clear();
264 size_t size() noexcept;
Type
supported protocols
Definition: base_protocol.h:32
Allows the obervers to register for notifications on the change in the state of the destination nodes...
Definition: destination.h:84
StartSocketAcceptorCallback start_router_socket_acceptor_callback_
Definition: destination.h:167
MetadataRefreshCallback md_refresh_callback_
Definition: destination.h:166
StopSocketAcceptorCallback stop_router_socket_acceptor_callback_
Definition: destination.h:168
void unregister_query_quarantined_destinations()
Unregisters the callback registered with register_query_quarantined_destinations().
Definition: destination.cc:96
std::mutex socket_acceptor_handle_callbacks_mtx
Definition: destination.h:172
void register_query_quarantined_destinations(const QueryQuarantinedDestinationsCallback &clb)
Registers a callback that could be used for checking if the provided destination candidate is current...
Definition: destination.cc:88
QueryQuarantinedDestinationsCallback query_quarantined_destinations_callback_
Definition: destination.h:169
AllowedNodesChangeCallbacksList allowed_nodes_change_callbacks_
Definition: destination.h:165
std::mutex md_refresh_callback_mtx_
Definition: destination.h:171
std::mutex allowed_nodes_change_callbacks_mtx_
Definition: destination.h:170
void unregister_md_refresh_callback()
Unregisters the callback registered with register_md_refresh_callback().
Definition: destination.cc:83
std::mutex query_quarantined_destinations_callback_mtx_
Definition: destination.h:173
void register_md_refresh_callback(const MetadataRefreshCallback &callback)
Registers a callback that is going to be used on metadata refresh.
Definition: destination.cc:77
void register_start_router_socket_acceptor(const StartSocketAcceptorCallback &clb)
Registers the callback for notification that the routing socket acceptor should accept new connection...
Definition: destination.cc:55
void unregister_allowed_nodes_change_callback(const AllowedNodesChangeCallbacksListIterator &it)
Unregisters the callback registered with register_allowed_nodes_change_callback().
Definition: destination.cc:49
void unregister_stop_router_socket_acceptor()
Unregisters the callback registered with register_stop_router_socket_acceptor().
Definition: destination.cc:72
void unregister_start_router_socket_acceptor()
Unregisters the callback registered with register_start_router_socket_acceptor().
Definition: destination.cc:61
void register_stop_router_socket_acceptor(const StopSocketAcceptorCallback &clb)
Registers the callback for notification that the routing socket acceptor should stop accepting new co...
Definition: destination.cc:66
AllowedNodesChangeCallbacksListIterator register_allowed_nodes_change_callback(const AllowedNodesChangedCallback &clb)
Registers the callback for notification on the change in the state if the destination nodes.
Definition: destination.cc:42
A forward iterable container of destinations.
Definition: destination.h:107
static Type get_default()
Definition: protocol.h:37
Manage destinations for a Connection Routing.
Definition: destination.h:188
virtual ~RouteDestination()=default
Destructor.
RouteDestination(const RouteDestination &other)=delete
AddrVector destinations_
List of destinations.
Definition: destination.h:315
virtual AddrVector get_destinations() const
Definition: destination.cc:151
virtual Destinations destinations()=0
get destinations to connect() to.
virtual void remove(const std::string &address, uint16_t port)
Removes a destination.
Definition: destination.cc:119
AddrVector::const_iterator begin() const
Definition: destination.h:280
virtual void handle_sockets_acceptors()
Trigger listening socket acceptors state handler based on the destination type.
Definition: destination.h:311
RouteDestination & operator=(const RouteDestination &other)=delete
net::io_context & io_ctx_
Definition: destination.h:320
RouteDestination(net::io_context &io_ctx, Protocol::Type protocol=Protocol::get_default())
Default constructor.
Definition: destination.h:198
virtual std::optional< Destinations > refresh_destinations(const Destinations &dests)
refresh destinations.
Definition: destination.cc:158
virtual routing::RoutingStrategy get_strategy()=0
Return our routing strategy.
AddrVector::const_iterator end() const
Definition: destination.h:284
std::vector< mysql_harness::TCPAddress > AddrVector
Definition: destination.h:190
Protocol::Type protocol_
Protocol for the destination.
Definition: destination.h:323
RouteDestination(RouteDestination &&other)=delete
std::mutex mutex_update_
Mutex for updating destinations and iterator.
Definition: destination.h:318
virtual bool empty() const noexcept
Returns whether there are destinations.
Definition: destination.h:270
RouteDestination & operator=(RouteDestination &&other)=delete
AddrVector::iterator end()
Definition: destination.h:282
virtual void add(const mysql_harness::TCPAddress dest)
Adds a destination.
Definition: destination.cc:104
virtual void clear()
Removes all destinations.
Definition: destination.cc:143
size_t size() noexcept
Gets the number of destinations.
Definition: destination.cc:141
AddrVector::iterator begin()
Definition: destination.h:278
virtual mysql_harness::TCPAddress get(const std::string &address, uint16_t port)
Gets destination based on address and port.
Definition: destination.cc:131
virtual void start(const mysql_harness::PluginFuncEnv *env)
Start the destination threads (if any)
Definition: destination.cc:156
PluginFuncEnv object.
Definition: loader.h:673
Defines an IP address with port number
Definition: tcp_address.h:40
Definition: io_context.h:61
std::vector< AvailableDestination > AllowedNodes
Definition: destination_status_types.h:59
Header for compiler-dependent features.
RoutingStrategy
Routing strategies supported by Routing plugin.
Definition: routing.h:265
required uint64 port
Definition: replication_asynchronous_connection_failover.proto:33
std::function< void()> StopSocketAcceptorCallback
Definition: destination.h:68
std::function< stdx::expected< void, std::string >()> StartSocketAcceptorCallback
Definition: destination.h:67
std::function< void(const AllowedNodes &, const AllowedNodes &, const bool, const std::string &)> AllowedNodesChangedCallback
Definition: destination.h:58
AllowedNodesChangeCallbacksList::iterator AllowedNodesChangeCallbacksListIterator
Definition: destination.h:64
std::list< AllowedNodesChangedCallback > AllowedNodesChangeCallbacksList
Definition: destination.h:62
std::function< void(const bool, const AllowedNodes &)> MetadataRefreshCallback
Definition: destination.h:73
std::function< bool(const mysql_harness::TCPAddress &)> QueryQuarantinedDestinationsCallback
Definition: destination.h:77