txn_begin
Open a transaction with an id you generate, and a timeout the server may lower.
async fn txn_begin(&self, request: &TxnBeginRequest) -> Result<TxnBeginResponse>Parameters
txn_idUUID bytesrequiredThe id you generate, with the SDK's id helper.
timeout_secondsintegerrequiredHow long the server holds it open. Exceeding it is TransactionTimeout and the transaction is gone — the writes inside it did not land.
act_asActAs | nulloptionalRun the transaction as another space.
Returns
txn_idUUID bytesalwaysEchoed back.
timeout_secondsintegeralwaysThe timeout the server actually granted — which may be lower than you asked for. Schedule your own deadline from this value, not from the one you sent.
started_at_unix_nanos64-bit integeralwaysWhen the server opened it.
Example
use brain_db_sdk::{new_id, EncodeBuilder};
let txn_id = new_id();
client.txn_begin(&TxnBeginRequest { txn_id, timeout_seconds: 30, act_as: None }).await?;
let mut req = EncodeBuilder::new("Priya moved to Lisbon.").build();
req.txn_id = Some(txn_id);
client.encode(&req).await?;
client.txn_commit(&TxnCommitRequest { txn_id }).await?;HTTP has no transactions
The HTTP edge exposes no transaction routes. Each HTTP verb is its own unit. If several writes must land together, you need the wire client — see Wire client.
Joining writes to it
Every mutating wire request type carries a txnId field. Setting it is what
puts the write inside the transaction.
The encode, recall and forget builders all leave txnId null and offer no
method to change it. Build the request, then set the field before sending.
A write you believe is in a transaction but whose txnId is null lands
immediately and is not rolled back by an abort.
Was this page helpful?