Brain Docs

Reference

Rust SDKInstallationHTTP clientWire client
txn_begintxn_committxn_abort
ErrorsRetriesPagination
Brain/Docs
✦ ASKBrain on GitHubDashboard
Rust SDKTransactionstxn_abort

txn_abort

Discard a transaction's writes without waiting for its timeout.

PURPOSE

Discard the transaction and everything in it. Call it from a finally so a thrown error does not leave the transaction open until its timeout elapses.

Handshake credentialstable
async fn txn_abort(&self, request: &TxnAbortRequest) -> Result<TxnAbortResponse>

Parameters

ParameterTypeRequired
txn_idUUID bytesrequired

The transaction to discard.

Returns

FieldTypePresence
txn_idUUID bytesalways

Echoed back.

operations_discardedintegeralways

How many operations were thrown away.

Example

let txn_id = new_id();
client.txn_begin(&TxnBeginRequest { txn_id, timeout_seconds: 30, act_as: None }).await?;

let outcome = async {
    write_everything(txn_id).await?;
    client.txn_commit(&TxnCommitRequest { txn_id }).await
}
.await;

if outcome.is_err() {
    client.txn_abort(&TxnAbortRequest { txn_id }).await?;
}
outcome?;

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.

See also
txn_begintxn_commit

Was this page helpful?

txn_commit

Apply a transaction's writes atomically, and check that every write actually joined it.

put_llm_credential

Register or replace the namespace's provider key — verified with the provider before it is stored.

On this page

ParametersReturnsExample
Suggest an editOpen in Playground