Returns current alive connections number.
Adds connection string to a SQL server with maximum connections count.
Returns date format 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.
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.
Returns first free connection from the pool.
Awaits all queries to finish and then closes each connection.
If there is no free connection for specified duration while trying to initialize SQL query, then the pool throws ConnTimeoutException exception.
Retrieves SQL result from specified transaction.
Returns current frozen connections number.
Returns true if transaction processing is finished (doesn't matter the actual reason, error or transaction object is invalid, or successful completion).
Enables/disables logging for all transactions.
Returns true if the pool logs all transactions.
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.
If connection to a SQL server is down, the pool tries to reestablish it every time units returned by the method.
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.
Returns timestamp format 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.
Transaction that should be executed by one of connections on remote SQL server. Client code shouldn't know anything about the interface but only store it as unique key to acquire finished transaction.
1 scope(exit) pool.finalize(); 2 std.stdio.writeln(pool.timeZone); // know server time zone 3 4 import pgator.db.pq.types.time; // for PGTimeStamp 5 * 6 // blocking quering 7 auto time = pool.execTransaction(["SELECT TIMESTAMP 'epoch' as field;"]).deserializeBson!PGTimeStamp; 8 assert(time == SysTime.fromSimpleString("1970-Jan-01 00:00:00Z")); 9 * 10 // or can use asynchronous alternative 11 auto transaction = pool.postTransaction(["SELECT TIMESTAMP 'epoch' as field;"]); 12 while(!isTransactionReady(transaction)) 13 { 14 // do something 15 } 16 time = getTransaction(transaction).deserializeBson!PGTimeStamp; 17 assert(time == SysTime.fromSimpleString("1970-Jan-01 00:00:00Z"));
Pool handles several connections to one or more SQL servers. If connection is lost, pool tries to reconnect over reconnectTime duration. *