#include <ozo/connection_pool.h>
Pool bound model for Connection
concept.
Connection
concept model which is bound to and may be obtained only from the connection pool. On the pooled_connection
object destruction, the underlying handle that contains a connection will be returned to the handle-associated connection pool. If the connection is in a bad state either its current transaction status is different than ozo::transaction_status::idle
then it will not return to the pool and be closed. The class object is non-copyable.
Rep | — underlying connection pool representation for the real connection. |
Executor | — the type of the executor is used to perform IO; currently only boost::asio::io_context::executor_type is supported. |
Safe
Unsafe
Connection
Types | |
using | rep_type = Rep |
Connection representation type. | |
using | native_handle_type = typename connection_traits< rep_type >::native_handle_type |
Native connection handle type. | |
using | oid_map_type = typename connection_traits< rep_type >::oid_map_type |
Oid map of types that are used with the connection. | |
using | error_context_type = typename connection_traits< rep_type >::error_context_type |
Additional error context which could provide context depended information for errors. | |
using | statistics_type = typename connection_traits< rep_type >::statistics_type |
Connection statistics to be collected. | |
using | executor_type = Executor |
The type of the executor associated with the object. | |
Public Member Functions | |
native_handle_type | native_handle () const noexcept |
const oid_map_type & | oid_map () const noexcept |
const error_context_type & | get_error_context () const noexcept |
void | set_error_context (error_context_type v={}) |
executor_type | get_executor () const noexcept |
template<typename WaitHandler > | |
void | async_wait_write (WaitHandler &&handler) |
template<typename WaitHandler > | |
void | async_wait_read (WaitHandler &&handler) |
error_code | close () noexcept |
void | cancel () noexcept |
bool | is_bad () const noexcept |
operator bool () const noexcept | |
bool | is_open () const noexcept |
void ozo::pooled_connection< Rep, Executor >::async_wait_read | ( | WaitHandler && | handler | ) |
Asynchronously wait for the connection socket to become ready to read or to have pending error conditions.
Typically this function is used by the library within the connection establishing process and operation execution. Users should not use it directly other than for custom libpq
-based opeartions.
handler | — wait handler with void(ozo::error_code, int=0) signature. |
void ozo::pooled_connection< Rep, Executor >::async_wait_write | ( | WaitHandler && | handler | ) |
Asynchronously wait for the connection socket to become ready to write or to have pending error conditions.
Typically this function is used by the library within the connection establishing process and operation execution. Users should not use it directly other than for custom libpq
-based opeartions.
handler | — wait handler with void(ozo::error_code, int=0) signature. |
|
noexcept |
Cancel all asynchronous operations associated with the connection.
This function causes all outstanding asynchronous operations to finish immediately, and the handlers for cancelled operations will be passed the boost::asio::error::operation_aborted
error.
|
noexcept |
Close the connection.
Any asynchronous operations will be cancelled immediately, and will complete with the boost::asio::error::operation_aborted
error.
References ozo::unwrap().
|
noexcept |
Get the additional context object for an error that occurred during the last operation on the connection.
References ozo::unwrap().
|
noexcept |
Get the executor associated with the object.
|
noexcept |
Determine whether the connection is in bad state.
get_error_context()
and ozo::error_message()
. Referenced by ozo::pooled_connection< Rep, Executor >::operator bool().
|
noexcept |
Determine whether the connection is open.
References ozo::pooled_connection< Rep, Executor >::native_handle().
|
noexcept |
Get native connection handle object.
This function may be used to obtain the underlying representation of the connection. This is intended to allow access to native libpq
functionality that is not otherwise provided.
References ozo::unwrap().
Referenced by ozo::pooled_connection< Rep, Executor >::is_open().
|
noexcept |
Get a reference to an oid map object for types that are used with the connection.
References ozo::unwrap().
|
noexcept |
Determine whether the connection is not in bad state.
get_error_context()
and ozo::error_message()
. References ozo::pooled_connection< Rep, Executor >::is_bad().
void ozo::pooled_connection< Rep, Executor >::set_error_context | ( | error_context_type | v = {} | ) |
Set the additional error context object. This function may be used to provide additional context-depended data that is related to the current operation error.
v | — new error context. |