sgns::crdt::AtomicTransaction¶
AtomicTransaction provides atomic multi-key operations for CRDT datastore All operations within a transaction are combined into a single delta and published atomically to ensure consistency.
#include <atomic_transaction.hpp>
Public Types¶
| Name | |
|---|---|
| using base::Buffer | Buffer |
| using pb::Delta | Delta |
Public Functions¶
| Name | |
|---|---|
| AtomicTransaction(std::shared_ptr< CrdtDatastore > datastore) Constructor for AtomicTransaction. |
|
| ~AtomicTransaction() Destructor ensures rollback if not committed. |
|
| outcome::result< void > | Put(HierarchicalKey key, Buffer value) Add a key-value pair to the transaction. |
| outcome::result< void > | Remove(const HierarchicalKey & key) Delete a key in the transaction. |
| outcome::result< Buffer > | Get(const HierarchicalKey & key) const Get a value for a key. |
| outcome::result< void > | Erase(const HierarchicalKey & key) Erase a key from the transaction (alias for Remove). |
| bool | HasKey(const HierarchicalKey & key) const Check if a key has been modified in this transaction. |
| outcome::result< CID > | Commit(const std::unordered_set< std::string > & topics) Commits all pending operations atomically. Combines all pending operations into a single Delta and publishes it. |
Public Types Documentation¶
using Buffer¶
using Delta¶
Public Functions Documentation¶
function AtomicTransaction¶
Constructor for AtomicTransaction.
Parameters:
- datastore pointer to CRDT datastore
function ~AtomicTransaction¶
Destructor ensures rollback if not committed.
function Put¶
Add a key-value pair to the transaction.
Parameters:
- key hierarchical key to add
- value buffer value to store
Return: outcome::success or failure if already committed
function Remove¶
Delete a key in the transaction.
Parameters:
- key hierarchical key to remove
Return: outcome::success or failure if already committed
function Get¶
Get a value for a key.
Parameters:
- key hierarchical key to retrieve
Return: Buffer containing the value if found, or error if not found/committed
Note: This method checks pending operations first, then falls back to datastore
function Erase¶
Erase a key from the transaction (alias for Remove).
Parameters:
- key hierarchical key to erase
Return: outcome::success or failure if already committed
function HasKey¶
Check if a key has been modified in this transaction.
Parameters:
- key hierarchical key to check
Return: true if key has pending operations in this transaction
function Commit¶
Commits all pending operations atomically. Combines all pending operations into a single Delta and publishes it.
Parameters:
- topics Optional topic name for targeted publishing. If not provided, the default broadcast behavior is used.
Return: outcome::success on successful commit, or outcome::failure if an error occurs.
Updated on 2026-03-04 at 13:10:43 -0800