#include <ozo/transaction.h>
Transaction Connection model.
Connection
concept model that describes the open transaction on the underlying connection. The transaction is not an RAII object it does not control transaction flow. It is dedicated to describe the current transaction and represent a transaction on the type level.
Connection
the transaction object may model Nullable
. If the object is in null state call of any member may lead to undefined behaviour.Connection | — the underlying Connection model type. |
Options | — the transaction options type, see ozo::transaction_options for the details. |
Depends on underlying
Connectionmodel
Unsafe
Connection
Types | |
using | lowest_layer_type = unwrap_type< handle_type > |
Lowest level Connection model type - fully unwrapped type. | |
using | native_handle_type = typename lowest_layer_type::native_handle_type |
Native connection handle type. | |
using | oid_map_type = typename lowest_layer_type::oid_map_type |
Oid map of types that are used with the connection. | |
using | error_context_type = typename lowest_layer_type::error_context_type |
Additional error context which could provide context depended information for errors. | |
using | executor_type = typename lowest_layer_type::executor_type |
The type of the executor associated with the object. | |
using | options_type = std::decay_t< Options > |
The type of options specified for the transaction. | |
Public Member Functions | |
transaction ()=default | |
transaction (Connection &&connection, Options options) noexcept(std::is_nothrow_move_constructible_v< Connection > &&std::is_nothrow_move_constructible_v< Options >) | |
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=error_context_type{}) |
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 |
constexpr const options_type & | options () const noexcept |
lowest_layer_type & | lowest_layer () noexcept |
const lowest_layer_type & | lowest_layer () const noexcept |
Friends | |
handle_type | release_connection (transaction &&x) noexcept |
|
default |
Construct a new uninitialized transaction object.
If underlying Connection
model is Nullable
then ozo::is_null()
should return true
for the constructed object.
|
noexcept |
Construct a new transaction object.
ozo::begin()
instead to open a transaction with required options.connection | — connection object to perform transaction on. |
options | — options of the transaction |
void ozo::transaction< Connection, Options >::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. |
References ozo::transaction< Connection, Options >::lowest_layer().
void ozo::transaction< Connection, Options >::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. |
References ozo::transaction< Connection, Options >::lowest_layer().
|
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.
References ozo::transaction< Connection, Options >::lowest_layer().
|
noexcept |
Close the connection.
Any asynchronous operations will be cancelled immediately, and will complete with the boost::asio::error::operation_aborted
error.
References ozo::transaction< Connection, Options >::lowest_layer().
|
noexcept |
Get the additional context object for an error that occurred during the last operation on the connection.
References ozo::transaction< Connection, Options >::lowest_layer().
|
noexcept |
Get the executor associated with the object.
References ozo::transaction< Connection, Options >::lowest_layer().
|
noexcept |
Determine whether the connection is in bad state.
get_error_context()
and ozo::error_message()
. References ozo::transaction< Connection, Options >::lowest_layer().
Referenced by ozo::transaction< Connection, Options >::operator bool().
|
noexcept |
Determine whether the connection is open. The object may be used in noninitialized state for this call.
References ozo::transaction< Connection, Options >::lowest_layer().
|
noexcept |
Get a const reference to the lowest layer.
References ozo::unwrap().
|
noexcept |
Get a reference to the lowest layer.
References ozo::unwrap().
Referenced by ozo::transaction< Connection, Options >::async_wait_read(), ozo::transaction< Connection, Options >::async_wait_write(), ozo::transaction< Connection, Options >::cancel(), ozo::transaction< Connection, Options >::close(), ozo::transaction< Connection, Options >::get_error_context(), ozo::transaction< Connection, Options >::get_executor(), ozo::transaction< Connection, Options >::is_bad(), ozo::transaction< Connection, Options >::is_open(), ozo::transaction< Connection, Options >::native_handle(), and ozo::transaction< Connection, Options >::oid_map().
|
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::transaction< Connection, Options >::lowest_layer().
|
noexcept |
Get a reference to an oid map object for types that are used with the connection.
References ozo::transaction< Connection, Options >::lowest_layer().
|
noexcept |
Determine whether the connection may be used for operations. The object may be used in noninitialized state for this call.
get_error_context()
and ozo::error_message()
. References ozo::transaction< Connection, Options >::is_bad().
|
constexprnoexcept |
Get the transaction options. See ozo::transaction_options
for the details.
Referenced by ozo::get_transaction_deferrability(), ozo::get_transaction_isolation_level(), and ozo::get_transaction_mode().
void ozo::transaction< Connection, Options >::set_error_context | ( | error_context_type | v = error_context_type{} | ) |
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. |
|
friend |
Release ownership of the underlying Connection
model object.
This function may be used to obtain the underlying Connection
model. After calling this function, the transaction object may not be used. The caller is the owner for the connection.
x | — transaction to release connection from, the object should be initialized for this call. |
Connection
model object