txn_begin
Open a transaction with an id you generate, and a timeout the server may lower.
txn_begin(request: TxnBeginRequest) -> TxnBeginResponseParameters
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
from brain_db_sdk import new_id, EncodeBuilder
from dataclasses import replace
txn_id = new_id()
client.txn_begin(TxnBeginRequest(txn_id=txn_id, timeout_seconds=30))
req = EncodeBuilder("Priya moved to Lisbon.").build()
client.encode(replace(req, txn_id=txn_id))
client.txn_commit(TxnCommitRequest(txn_id=txn_id))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?