Orbit Framework
An ultra-modern, asynchronous, cross-platform C++ Web Framework.
Loading...
Searching...
No Matches
database::MysqlClient Class Reference

An asynchronous MySQL client using coroutines and a network Proactor. More...

#include <MysqlClient.hpp>

Classes

struct  Config
 Configuration options for the MySQL client. More...
 
struct  ConnectAwaiter
 
struct  QueryAwaiter
 

Public Member Functions

 MysqlClient (network::Proactor &proactor, const Config &config)
 Constructs a new MysqlClient.
 
 ~MysqlClient ()
 
 MysqlClient (const MysqlClient &)=delete
 
MysqlClientoperator= (const MysqlClient &)=delete
 
ConnectAwaiter connect_async ()
 Connects to the MySQL database asynchronously.
 
QueryAwaiter query_async (std::string query)
 Executes a query asynchronously.
 
void close ()
 Closes the MySQL connection.
 
network::Proactorget_proactor ()
 Gets the associated network proactor.
 
MYSQL * get_mysql ()
 Gets the underlying MySQL connection object.
 

Detailed Description

An asynchronous MySQL client using coroutines and a network Proactor.

Constructor & Destructor Documentation

◆ MysqlClient() [1/2]

database::MysqlClient::MysqlClient ( network::Proactor proactor,
const Config config 
)

Constructs a new MysqlClient.

Parameters
proactorThe network Proactor to use for async events.
configThe configuration settings for the MySQL connection.

◆ ~MysqlClient()

database::MysqlClient::~MysqlClient ( )

◆ MysqlClient() [2/2]

database::MysqlClient::MysqlClient ( const MysqlClient )
delete

Member Function Documentation

◆ close()

void database::MysqlClient::close ( )

Closes the MySQL connection.

◆ connect_async()

MysqlClient::ConnectAwaiter database::MysqlClient::connect_async ( )

Connects to the MySQL database asynchronously.

Returns
A ConnectAwaiter that can be co_awaited.

◆ get_mysql()

MYSQL * database::MysqlClient::get_mysql ( )
inline

Gets the underlying MySQL connection object.

Returns
Pointer to the MYSQL object.

◆ get_proactor()

network::Proactor & database::MysqlClient::get_proactor ( )
inline

Gets the associated network proactor.

Returns
Reference to the network Proactor.

◆ operator=()

MysqlClient & database::MysqlClient::operator= ( const MysqlClient )
delete

◆ query_async()

MysqlClient::QueryAwaiter database::MysqlClient::query_async ( std::string  query)

Executes a query asynchronously.

Parameters
queryThe SQL query string.
Returns
A QueryAwaiter that can be co_awaited for the result.
auto result = co_await client.query_async("SELECT * FROM users");

The documentation for this class was generated from the following files: