|
relx 0.1.0
A Modern C++23 Type-Safe SQL Query Builder
|
Asynchronous PostgreSQL implementation of the Connection interface. More...
#include <relx/connection/postgresql_async_connection.hpp>
Public Member Functions | |
| PostgreSQLAsyncConnection (boost::asio::io_context &io_context, std::string connection_string) | |
| Constructor with connection parameters and io_context. | |
| PostgreSQLAsyncConnection (boost::asio::io_context &io_context, const PostgreSQLConnectionParams ¶ms) | |
| Constructor with structured connection parameters and io_context. | |
| ~PostgreSQLAsyncConnection () | |
| Destructor that ensures proper cleanup. | |
| PostgreSQLAsyncConnection (const PostgreSQLAsyncConnection &)=delete | |
| PostgreSQLAsyncConnection & | operator= (const PostgreSQLAsyncConnection &)=delete |
| PostgreSQLAsyncConnection (PostgreSQLAsyncConnection &&) noexcept | |
| PostgreSQLAsyncConnection & | operator= (PostgreSQLAsyncConnection &&) noexcept |
| bool | is_connected () const |
| Check if the connection is open. | |
| bool | in_transaction () const |
| Check if a transaction is currently active. | |
| boost::asio::awaitable< ConnectionResult< void > > | connect () |
| Connect to the PostgreSQL database asynchronously. | |
| boost::asio::awaitable< ConnectionResult< void > > | disconnect () |
| Disconnect from the PostgreSQL database asynchronously. | |
| boost::asio::awaitable< ConnectionResult< result::ResultSet > > | execute_raw (std::string sql, std::vector< std::string > params={}) |
| Execute a raw SQL query with parameters asynchronously. | |
| template<query::SqlExpr Query> | |
| boost::asio::awaitable< ConnectionResult< result::ResultSet > > | execute (Query query) |
| Execute a query expression asynchronously. | |
| template<typename T , query::SqlExpr Query> | |
| boost::asio::awaitable< ConnectionResult< T > > | execute (Query query) |
| Execute a query and map results to a user-defined type asynchronously. | |
| template<typename T , query::SqlExpr Query> | |
| boost::asio::awaitable< ConnectionResult< std::vector< T > > > | execute_many (const Query &query) |
| Execute a query and map results to a vector of user-defined types asynchronously. | |
| boost::asio::awaitable< ConnectionResult< void > > | begin_transaction (IsolationLevel isolation_level=IsolationLevel::ReadCommitted) |
| Begin a new transaction asynchronously. | |
| boost::asio::awaitable< ConnectionResult< void > > | commit_transaction () |
| Commit the current transaction asynchronously. | |
| boost::asio::awaitable< ConnectionResult< void > > | rollback_transaction () |
| Rollback the current transaction asynchronously. | |
| pgsql_async_wrapper::Connection & | get_async_conn () |
| Get the underlying async connection wrapper. | |
| boost::asio::io_context & | get_io_context () const |
| Get the IO context associated with this connection. | |
| boost::asio::awaitable< ConnectionResult< void > > | reset_connection_state () |
| Reset connection state after streaming operations. | |
| bool | reset_connection_state_sync () |
| Reset connection state synchronously (for use in destructors) | |
Asynchronous PostgreSQL implementation of the Connection interface.
Definition at line 27 of file postgresql_async_connection.hpp.
|
explicit |
Constructor with connection parameters and io_context.
| io_context | Boost.Asio IO context for async operations |
| connection_string | PostgreSQL connection string (e.g. "host=localhost port=5432 dbname=mydb user=postgres password=password") |
|
explicit |
Constructor with structured connection parameters and io_context.
| io_context | Boost.Asio IO context for async operations |
| params | PostgreSQL connection parameters |
| relx::connection::PostgreSQLAsyncConnection::~PostgreSQLAsyncConnection | ( | ) |
Destructor that ensures proper cleanup.
|
delete |
|
noexcept |
| boost::asio::awaitable< ConnectionResult< void > > relx::connection::PostgreSQLAsyncConnection::begin_transaction | ( | IsolationLevel | isolation_level = IsolationLevel::ReadCommitted | ) |
Begin a new transaction asynchronously.
| isolation_level | The isolation level for the transaction |
| boost::asio::awaitable< ConnectionResult< void > > relx::connection::PostgreSQLAsyncConnection::commit_transaction | ( | ) |
Commit the current transaction asynchronously.
| boost::asio::awaitable< ConnectionResult< void > > relx::connection::PostgreSQLAsyncConnection::connect | ( | ) |
Connect to the PostgreSQL database asynchronously.
| boost::asio::awaitable< ConnectionResult< void > > relx::connection::PostgreSQLAsyncConnection::disconnect | ( | ) |
Disconnect from the PostgreSQL database asynchronously.
|
inline |
Execute a query expression asynchronously.
| query | The query expression to execute |
Definition at line 84 of file postgresql_async_connection.hpp.
|
inline |
Execute a query and map results to a user-defined type asynchronously.
| T | The user-defined type to map results to |
| Query | The query expression type |
| query | The query expression to execute |
Definition at line 96 of file postgresql_async_connection.hpp.
|
inline |
Execute a query and map results to a vector of user-defined types asynchronously.
| T | The user-defined type to map results to |
| Query | The query expression type |
| query | The query expression to execute |
Definition at line 163 of file postgresql_async_connection.hpp.
| boost::asio::awaitable< ConnectionResult< result::ResultSet > > relx::connection::PostgreSQLAsyncConnection::execute_raw | ( | std::string | sql, |
| std::vector< std::string > | params = {} |
||
| ) |
Execute a raw SQL query with parameters asynchronously.
| sql | The SQL query string |
| params | Vector of parameter values |
|
inline |
Get the underlying async connection wrapper.
Definition at line 241 of file postgresql_async_connection.hpp.
|
inline |
Get the IO context associated with this connection.
Definition at line 244 of file postgresql_async_connection.hpp.
| bool relx::connection::PostgreSQLAsyncConnection::in_transaction | ( | ) | const |
Check if a transaction is currently active.
| bool relx::connection::PostgreSQLAsyncConnection::is_connected | ( | ) | const |
Check if the connection is open.
|
delete |
|
noexcept |
| boost::asio::awaitable< ConnectionResult< void > > relx::connection::PostgreSQLAsyncConnection::reset_connection_state | ( | ) |
Reset connection state after streaming operations.
| bool relx::connection::PostgreSQLAsyncConnection::reset_connection_state_sync | ( | ) |
Reset connection state synchronously (for use in destructors)
This is a non-blocking version that can be called from destructors when async streaming result sets go out of scope before completion
| boost::asio::awaitable< ConnectionResult< void > > relx::connection::PostgreSQLAsyncConnection::rollback_transaction | ( | ) |
Rollback the current transaction asynchronously.