pub struct DistributedTransaction {
pub id: TransactionId,
pub coordinator: NodeId,
pub participants: HashMap<NodeId, TransactionParticipant>,
pub state: TransactionState,
pub created_at: u64,
pub timeout_ms: u64,
pub operations: Vec<TransactionOperation>,
}Expand description
A distributed transaction managed by 2PC.
Fields§
§id: TransactionId§coordinator: NodeId§participants: HashMap<NodeId, TransactionParticipant>§state: TransactionState§created_at: u64§timeout_ms: u64§operations: Vec<TransactionOperation>Implementations§
Source§impl DistributedTransaction
impl DistributedTransaction
Sourcepub fn new(id: TransactionId, coordinator: NodeId, timeout_ms: u64) -> Self
pub fn new(id: TransactionId, coordinator: NodeId, timeout_ms: u64) -> Self
Create a new distributed transaction.
Sourcepub fn add_participant(&mut self, node_id: NodeId)
pub fn add_participant(&mut self, node_id: NodeId)
Add a participant to the transaction.
Sourcepub fn add_operation(&mut self, operation: TransactionOperation)
pub fn add_operation(&mut self, operation: TransactionOperation)
Add an operation to the transaction.
Sourcepub fn all_prepared(&self) -> bool
pub fn all_prepared(&self) -> bool
Check if all participants are prepared.
Sourcepub fn all_committed(&self) -> bool
pub fn all_committed(&self) -> bool
Check if all participants have committed.
Sourcepub fn is_timed_out(&self) -> bool
pub fn is_timed_out(&self) -> bool
Check if the transaction has timed out.
Sourcepub fn participant_count(&self) -> usize
pub fn participant_count(&self) -> usize
Get participant count.
Sourcepub fn prepared_count(&self) -> usize
pub fn prepared_count(&self) -> usize
Get prepared count.
Trait Implementations§
Source§impl Clone for DistributedTransaction
impl Clone for DistributedTransaction
Source§fn clone(&self) -> DistributedTransaction
fn clone(&self) -> DistributedTransaction
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DistributedTransaction
impl Debug for DistributedTransaction
Source§impl<'de> Deserialize<'de> for DistributedTransaction
impl<'de> Deserialize<'de> for DistributedTransaction
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for DistributedTransaction
impl RefUnwindSafe for DistributedTransaction
impl Send for DistributedTransaction
impl Sync for DistributedTransaction
impl Unpin for DistributedTransaction
impl UnsafeUnpin for DistributedTransaction
impl UnwindSafe for DistributedTransaction
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more