#include <ozo/failover/role_based.h>
ConnectionProvider
implementation for the role-based failover strategy.
This is the role-based implementation of the ConnectionProvider
concept. It binds io_context
and role to the ConnectionSource
implementation object. It requires from the underlying ConnectionSource
an ability to be bound to a certain role via bind_role(role)
method.
Source | — ConnectionSource implementation |
ConnectionProvider
Types | |
using | source_type = std::decay_t< Source > |
using | connection_type = typename connection_source_traits< source_type >::connection_type |
Public Member Functions | |
template<typename T > | |
role_based_connection_provider (T &&source, io_context &io) | |
template<typename OtherRole > | |
constexpr decltype(auto) | rebind_role (OtherRole r) const & |
Rebind the ConnectionProvider to an other role. More... | |
template<typename OtherRole > | |
constexpr decltype(auto) | rebind_role (OtherRole r) & |
Rebind the ConnectionProvider to an other role. More... | |
template<typename OtherRole > | |
constexpr decltype(auto) | rebind_role (OtherRole r) && |
Rebind the ConnectionProvider to an other role. More... | |
Static Public Member Functions | |
template<typename OtherRole > | |
static constexpr auto | is_supported (const OtherRole &) |
using ozo::failover::role_based_connection_provider< Source >::connection_type = typename connection_source_traits<source_type>::connection_type |
Connection
implementation type according to ConnectionProvider
requirements. Specifies the Connection
implementation type which can be obtained from this provider.
Connection
type depends on role type via source_type
and maybe different for a different role. using ozo::failover::role_based_connection_provider< Source >::source_type = std::decay_t<Source> |
Current source type.
ozo::failover::role_based_connection_provider< Source >::role_based_connection_provider | ( | T && | source, |
io_context & | io | ||
) |
Construct a new role_based_connection_provider
object
source | — ConnectionSource implementation |
io | — io_context for asynchronous IO |
|
staticconstexpr |
Indicates if a given role is supported by the source. The role
is supported if source.rebind_role(role)
can be invoked successful.
OtherRole | — role to examine. |
Referenced by ozo::failover::role_based_connection_provider< Source >::rebind_role().
|
constexpr |
Rebind the ConnectionProvider
to an other role.
r | — other role to rebind to |
ConnectionProvider
object References ozo::failover::role_based_connection_provider< Source >::is_supported(), and ozo::unwrap().
|
constexpr |
Rebind the ConnectionProvider
to an other role.
r | — other role to rebind to |
ConnectionProvider
object References ozo::failover::role_based_connection_provider< Source >::is_supported(), ozo::failover::role_based_connection_provider< Source >::rebind_role(), and ozo::unwrap().
|
constexpr |
Rebind the ConnectionProvider
to an other role.
r | — other role to rebind to |
ConnectionProvider
object References ozo::failover::role_based_connection_provider< Source >::is_supported(), and ozo::unwrap().
Referenced by ozo::failover::role_based_connection_provider< Source >::rebind_role().