Scoped transactions and bounded admission for existing moondb AsyncDriver implementations
Dependencies
// acquire/release/close are callbacks for the caller's connection source.
let db = @sessions.database(acquire~, release~, close~, max_leases=4)
defer @async.protect_from_cancel(async fn() { db.close_and_wait() })
db.with_transaction((), async fn(tx) {
let rows = tx.query("SELECT value FROM counters WHERE id = $1", params=[@moondb.Int(1)])
ignore(tx.execute("UPDATE counters SET value = $1 WHERE id = $2",
params=[@moondb.Int64(rows[0].int64(0) + 1L), @moondb.Int(1)]))
})fn[C : AsyncDriver] database(acquire~ : async () -> C, release~ : async (C, Bool) -> Unit, close~ : () -> Unit, max_leases~ : Int, max_waiters? : Int, checkout_timeout_ms? : Int) -> Database[Value, Row, ExecResult, Unit] raisefn[C : AsyncDriver, O] database_with_options(acquire~ : async () -> C, release~ : async (C, Bool) -> Unit, close~ : () -> Unit, begin~ : async (C, O) -> Unit, max_leases~ : Int, max_waiters? : Int, checkout_timeout_ms? : Int) -> Database[Value, Row, ExecResult, O] raiseInstall
Download zipScoped transactions and bounded admission for existing moondb AsyncDriver implementations
Dependencies