AsyncPool

Describes asynchronous connection pool.

Members

Functions

activeConnections
size_t activeConnections()

Returns current alive connections number. Warning: The method displays count of active connections at the moment, returned value can become invalid as soon as it returned due async nature of the pool.

addServer
void addServer(string connString, size_t connNum)

Adds connection string to a SQL server with maximum connections count.

aliveCheckTime
Duration aliveCheckTime()

Free connections are checked over the time by sending senseless queries. Don't make this time too small - huge overhead for network. Don't make this time too big - you wouldn't able to detect failed connections due server restarting or e.t.c.

dateFormat
DateFormat dateFormat()

Returns date format used in ONE OF sql servers. Warning: This method can be trust only the pool conns are connected to the same sql server. TODO: Make a way to get such configs for particular connection.

execTransaction
InputRange!(immutable Bson) execTransaction(string[] commands, string[] params = [], uint[] argnums = [], string[string] vars = null, bool[] oneRowConstraint = [])

Performs several SQL commands on single connection wrapped in a transaction (BEGIN/COMMIT in PostgreSQL). Each command should use '$n' notation to refer params values. Before any command occurs in transaction the local SQL variables is set from vars.

fetchFreeConnection
shared(IConnection) fetchFreeConnection()

Returns first free connection from the pool.

finalize
void finalize()

Awaits all queries to finish and then closes each connection. Calls callback when connections are closed.

freeConnTimeout
Duration freeConnTimeout()

If there is no free connection for specified duration while trying to initialize SQL query, then the pool throws ConnTimeoutException exception.

getTransaction
InputRange!(immutable Bson) getTransaction(immutable ITransaction transaction)

Retrieves SQL result from specified transaction.

inactiveConnections
size_t inactiveConnections()

Returns current frozen connections number. Warning: The method displays count of active connections at the moment, returned value can become invalid as soon as it returned due async nature of the pool.

isTransactionReady
bool isTransactionReady(immutable ITransaction transaction)

Returns true if transaction processing is finished (doesn't matter the actual reason, error or transaction object is invalid, or successful completion).

loggingAllTransactions
bool loggingAllTransactions()

Returns true if the pool logs all transactions.

loggingAllTransactions
void loggingAllTransactions(bool val)

Enables/disables logging for all transactions.

postTransaction
immutable(ITransaction) postTransaction(string[] commands, string[] params = [], uint[] argnums = [], string[string] vars = null, bool[] oneRowConstraint = [])

Asynchronous way to execute transaction. User can check transaction status by calling isTransactionReady method. When isTransactionReady method returns true, the transaction can be finalized by getTransaction method.

reconnectTime
Duration reconnectTime()

If connection to a SQL server is down, the pool tries to reestablish it every time units returned by the method.

timeZone
immutable(TimeZone) timeZone()

Returns server time zone used in ONE OF sql servers. Warning: This method can be trusted only the pool conns are connected to the same sql server. TODO: Make a way to get such configs for particular connection.

timestampFormat
TimestampFormat timestampFormat()

Returns timestamp format used in ONE OF sql servers. Warning: This method can be trust only the pool conns are connected to the same sql server. TODO: Make a way to get such configs for particular connection.

Meta