OZO 「お象」
Boost.Asio and libpq based asynchronous PostgreSQL unofficial header-only C++17 client library.
ozo::failover::role_based_connection_provider< Source > Class Template Reference

#include <ozo/failover/role_based.h>

Description

template<typename Source>
class ozo::failover::role_based_connection_provider< Source >

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.

Template Parameters
SourceConnectionSource implementation
Models
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 &)
 

Types

◆ connection_type

template<typename Source >
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.

Note
Connection type depends on role type via source_type and maybe different for a different role.

◆ source_type

template<typename Source >
using ozo::failover::role_based_connection_provider< Source >::source_type = std::decay_t<Source>

Current source type.

Note
Source type depends on role type and maybe different for a different role.

Constructors

◆ role_based_connection_provider()

template<typename Source >
template<typename T >
ozo::failover::role_based_connection_provider< Source >::role_based_connection_provider ( T &&  source,
io_context &  io 
)

Construct a new role_based_connection_provider object

Parameters
sourceConnectionSource implementation
ioio_context for asynchronous IO

Member Function Documentation

◆ is_supported()

template<typename Source >
template<typename OtherRole >
static constexpr auto ozo::failover::role_based_connection_provider< Source >::is_supported ( const OtherRole &  )
staticconstexpr

Indicates if a given role is supported by the source. The role is supported if source.rebind_role(role) can be invoked successful.

Parameters
OtherRole— role to examine.

Referenced by ozo::failover::role_based_connection_provider< Source >::rebind_role().

◆ rebind_role() [1/3]

template<typename Source >
template<typename OtherRole >
constexpr decltype(auto) ozo::failover::role_based_connection_provider< Source >::rebind_role ( OtherRole  r) &
constexpr

Rebind the ConnectionProvider to an other role.

Parameters
r— other role to rebind to
Returns
new ConnectionProvider object

References ozo::failover::role_based_connection_provider< Source >::is_supported(), and ozo::unwrap().

◆ rebind_role() [2/3]

template<typename Source >
template<typename OtherRole >
constexpr decltype(auto) ozo::failover::role_based_connection_provider< Source >::rebind_role ( OtherRole  r) &&
constexpr

◆ rebind_role() [3/3]

template<typename Source >
template<typename OtherRole >
constexpr decltype(auto) ozo::failover::role_based_connection_provider< Source >::rebind_role ( OtherRole  r) const &
constexpr