26#ifndef ROUTING_DESTINATION_INCLUDED
27#define ROUTING_DESTINATION_INCLUDED
35#include <system_error>
59 const std::string &)>;
65 AllowedNodesChangeCallbacksList::iterator;
69 std::function<stdx::expected<void, std::string>()>;
209 virtual void add(
const std::string &address, uint16_t
port);
218 virtual void remove(
const std::string &address, uint16_t
port);
242 virtual void clear();
250 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:85
MetadataRefreshCallback md_refresh_callback_
Definition: destination.h:152
RefreshSocketAcceptorStateCallback refresh_router_socket_acceptor_state_callback_
Definition: destination.h:154
void unregister_refresh_router_socket_acceptor_state()
Unregisters the callback registered with register_refresh_router_socket_acceptor_state().
Definition: destination.cc:63
void unregister_query_quarantined_destinations()
Unregisters the callback registered with register_query_quarantined_destinations().
Definition: destination.cc:87
void register_refresh_router_socket_acceptor_state(const RefreshSocketAcceptorStateCallback &clb)
Registers the callback for notification that the routing socket acceptor state may need to be refresh...
Definition: destination.cc:56
std::mutex socket_acceptor_handle_callbacks_mtx
Definition: destination.h:158
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:79
QueryQuarantinedDestinationsCallback query_quarantined_destinations_callback_
Definition: destination.h:155
AllowedNodesChangeCallbacksList allowed_nodes_change_callbacks_
Definition: destination.h:151
std::mutex md_refresh_callback_mtx_
Definition: destination.h:157
std::mutex allowed_nodes_change_callbacks_mtx_
Definition: destination.h:156
void unregister_md_refresh_callback()
Unregisters the callback registered with register_md_refresh_callback().
Definition: destination.cc:74
std::mutex query_quarantined_destinations_callback_mtx_
Definition: destination.h:159
void register_md_refresh_callback(const MetadataRefreshCallback &callback)
Registers a callback that is going to be used on metadata refresh.
Definition: destination.cc:68
void unregister_allowed_nodes_change_callback(const AllowedNodesChangeCallbacksListIterator &it)
Unregisters the callback registered with register_allowed_nodes_change_callback().
Definition: destination.cc:49
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:174
virtual ~RouteDestination()=default
Destructor.
RouteDestination(const RouteDestination &other)=delete
AddrVector destinations_
List of destinations.
Definition: destination.h:305
virtual AddrVector get_destinations() const
Definition: destination.cc:142
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:110
AddrVector::const_iterator begin() const
Definition: destination.h:266
virtual void handle_sockets_acceptors()
Trigger listening socket acceptors state handler based on the destination type.
Definition: destination.h:301
RouteDestination & operator=(const RouteDestination &other)=delete
net::io_context & io_ctx_
Definition: destination.h:310
RouteDestination(net::io_context &io_ctx, Protocol::Type protocol=Protocol::get_default())
Default constructor.
Definition: destination.h:184
virtual std::optional< Destinations > refresh_destinations(const Destinations &dests)
refresh destinations.
Definition: destination.cc:149
virtual routing::RoutingStrategy get_strategy()=0
Return our routing strategy.
AddrVector::const_iterator end() const
Definition: destination.h:270
std::vector< mysql_harness::TCPAddress > AddrVector
Definition: destination.h:176
Protocol::Type protocol_
Protocol for the destination.
Definition: destination.h:313
RouteDestination(RouteDestination &&other)=delete
std::mutex mutex_update_
Mutex for updating destinations and iterator.
Definition: destination.h:308
virtual bool empty() const noexcept
Returns whether there are destinations.
Definition: destination.h:256
RouteDestination & operator=(RouteDestination &&other)=delete
AddrVector::iterator end()
Definition: destination.h:268
virtual void add(const mysql_harness::TCPAddress dest)
Adds a destination.
Definition: destination.cc:95
virtual void clear()
Removes all destinations.
Definition: destination.cc:134
size_t size() noexcept
Gets the number of destinations.
Definition: destination.cc:132
AddrVector::iterator begin()
Definition: destination.h:264
virtual mysql_harness::TCPAddress get(const std::string &address, uint16_t port)
Gets destination based on address and port.
Definition: destination.cc:122
virtual void start(const mysql_harness::PluginFuncEnv *env)
Start the destination threads (if any)
Definition: destination.cc:147
virtual mysqlrouter::ServerMode purpose() const
Definition: destination.h:281
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:60
Header for compiler-dependent features.
ServerMode
Definition: datatypes.h:50
RoutingStrategy
Routing strategies supported by Routing plugin.
Definition: routing.h:265
required uint64 port
Definition: replication_asynchronous_connection_failover.proto:33
std::function< void(const AllowedNodes &, const AllowedNodes &, const bool, const std::string &)> AllowedNodesChangedCallback
Definition: destination.h:59
AllowedNodesChangeCallbacksList::iterator AllowedNodesChangeCallbacksListIterator
Definition: destination.h:65
std::list< AllowedNodesChangedCallback > AllowedNodesChangeCallbacksList
Definition: destination.h:63
std::function< void(const bool, const AllowedNodes &)> MetadataRefreshCallback
Definition: destination.h:74
std::function< stdx::expected< void, std::string >()> RefreshSocketAcceptorStateCallback
Definition: destination.h:69
std::function< bool(const mysql_harness::TCPAddress &)> QueryQuarantinedDestinationsCallback
Definition: destination.h:78