pg_async
|
#include <database.hpp>
Public Types | |
typedef boost::system::error_code | error_code |
typedef std::map< std::string, std::string > | connection_params |
typedef boost::optional< size_t > | optional_size |
Static Public Member Functions | |
static void | initialize (size_t pool_size, connection_params const &defaults) |
Initialize the database service with the default pool_size per alias and default connection parameters. More... | |
static void | add_connection (std::string const &connection_string, optional_size pool_size=optional_size()) |
Add a connection specification. More... | |
static void | begin (dbalias const &, transaction_callback const &, error_callback const &) |
Create a connection or retrieve a connection from the connection pool and start a transaction. More... | |
static void | run () |
static void | stop () |
static boost::asio::io_service & | io_service () |
Static Public Attributes | |
static const size_t | DEFAULT_POOOL_SIZE = 4 |
Database connection manager. Synopsis:
Definition at line 57 of file database.hpp.
typedef std::map< std::string, std::string > tip::db::pg::db_service::connection_params |
Definition at line 62 of file database.hpp.
typedef boost::system::error_code tip::db::pg::db_service::error_code |
Opaque connection pointer.
Definition at line 60 of file database.hpp.
typedef boost::optional<size_t> tip::db::pg::db_service::optional_size |
Definition at line 63 of file database.hpp.
|
static |
Add a connection specification.
Requires an alias, for the database to be referenced by it later.
connection_string | |
pool_size | A connection can have a pool size different from other connections. |
tip::db::pg::error::connection_error | if the connection string cannot be used. |
|
static |
Create a connection or retrieve a connection from the connection pool and start a transaction.
Will lookup a connection by alias. If a new connection must be created, it will be created with the connection string associated with the alias. If there is an idle connection in the pool, will return it. If no idle connections are available, and the size of connection pool didn't reach it's limit, will create a new one. If the pool is full and no idle connections are available, will return the first connection that becomes idle.
alias | database alias |
result | callback function that will be called when a connection becomes available and transaction is started. |
error | callback function that will be called in case of an error. |
tip::db::pg::error::connection_error | if the alias is not registered with the database service. |
|
static |
Initialize the database service with the default pool_size per alias and default connection parameters.
pool_size | number of connections per alias |
defaults | default settings for the connection |
|
static |
|
static |
|
static |
|
static |
Definition at line 65 of file database.hpp.