crafty_proto/two_phase.rs
1//! Cross-shard two-phase commit metadata replicated through each Raft group log.
2
3use serde::{Deserialize, Serialize};
4
5/// Prepare staging entry (durable 2PC; not applied to the user state machine).
6#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
7pub struct TwoPhasePrepareCommand {
8 /// Opaque transaction id shared across prepare/commit/abort calls.
9 pub tx_id: Vec<u8>,
10 /// Shard routing key for this prepare step.
11 pub route_key: Vec<u8>,
12 /// Application-encoded command staged at prepare time.
13 pub command: Vec<u8>,
14 /// Unix epoch millis when the prepare was first staged (timeout GC).
15 #[serde(default)]
16 pub prepared_at_ms: u64,
17}
18
19/// Abort/tombstone for a staged prepare (durable 2PC; not applied to the user SM).
20#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
21pub struct TwoPhaseAbortCommand {
22 /// Opaque transaction id.
23 pub tx_id: Vec<u8>,
24 /// Shard routing key for this prepare step.
25 pub route_key: Vec<u8>,
26}