You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Define new host functions for acquiring, committing, aborting a transaction. Expose these to module bindings as the following interface:
implProcedureContext{/// Acquire a mutable transaction and execute `body` with read-write access to the database.////// If the `body` returns `Ok`, the transaction will be committed and its mutations persisted./// If the `body` returns `Err`, the transaction will be rolled back and its mutations discarded.////// Regardless of the transaction's success or failure,/// the return value of `body` is not persisted to the commitlog or broadcast to subscribed clients./// Clients attribute mutations performed by this transaction to `Event::UnknownTransaction`.////// If the transaction fails to commit after `body` returns (e.g. due to a conflict with a concurrent transaction),/// this method will re-invoke `body` with a new transaction in order to retry.pubfnwith_transaction<Res,Err>(&mutself,body:implFn(&TxContext) -> Result<Res,Err>)) -> Result<Res,Err>{todo!()}}
The TxContext is a lot like a ReducerContext: it has a db field which allows access to the database, offers the rng method, has a timestamp, and probably some other stuff I'm forgetting. It inherits auth information from the enclosing ProcedureContext.
Name the new host functions with the prefix procedure_.
Attempting to perform any of the other procedure_ host calls while a transaction is open should error.
After completing this, create follow-up tickets to implement the same in C#, C++ and TypeScript.
Activity
Add `ProcedureContext::with_tx` (#3638)