Run the background loop that applies committed Raft entries to the local Data Plane. This task reads from the apply channel, deserializes each entry, dispatches the write to the Data Plane via SPSC, and notifies proposers.
(
mut apply_rx: mpsc::Receiver<ApplyBatch>,
state: Arc<SharedState>,
tracker: Arc<ProposeTracker>,
calvin_read_result_senders: Arc<
std::sync::Mutex<std::collections::BTreeMap<
| 96 | /// This task reads from the apply channel, deserializes each entry, dispatches |
| 97 | /// the write to the Data Plane via SPSC, and notifies proposers. |
| 98 | pub async fn run_apply_loop( |
| 99 | mut apply_rx: mpsc::Receiver<ApplyBatch>, |
| 100 | state: Arc<SharedState>, |
| 101 | tracker: Arc<ProposeTracker>, |
| 102 | calvin_read_result_senders: Arc< |
| 103 | std::sync::Mutex<std::collections::BTreeMap<u32, mpsc::Sender<ReadResultEvent>>>, |
| 104 | >, |
| 105 | ) { |
| 106 | while let Some(batch) = apply_rx.recv().await { |
| 107 | for entry in &batch.entries { |
| 108 | // Extract idempotency key once at the top so every |
| 109 | // tracker.complete on this entry can pass it. Returns 0 |
| 110 | // for unparseable / pre-key entries; the tracker treats |
| 111 | // 0 as "no key" (no mismatch detection). |
| 112 | let applied_key = ReplicatedEntry::from_bytes(&entry.data) |
| 113 | .map(|e| e.idempotency_key) |
| 114 | .unwrap_or(0); |
| 115 | |
| 116 | // ── Array CRDT variants — handled on the Control Plane, bypass Data Plane ── |
| 117 | if let Some(replicated) = ReplicatedEntry::from_bytes(&entry.data) { |
| 118 | let target_vshard = replicated.vshard_id; |
| 119 | match replicated.write { |
| 120 | ReplicatedWrite::ArrayOp { |
| 121 | ref array, |
| 122 | ref op_bytes, |
| 123 | .. |
| 124 | } => { |
| 125 | apply_array_op( |
| 126 | &state, |
| 127 | &tracker, |
| 128 | batch.group_id, |
| 129 | entry.index, |
| 130 | applied_key, |
| 131 | array, |
| 132 | op_bytes, |
| 133 | ) |
| 134 | .await; |
| 135 | continue; |
| 136 | } |
| 137 | ReplicatedWrite::ArraySchema { |
| 138 | ref array, |
| 139 | ref snapshot_payload, |
| 140 | schema_hlc_bytes, |
| 141 | } => { |
| 142 | apply_array_schema( |
| 143 | &state, |
| 144 | &tracker, |
| 145 | batch.group_id, |
| 146 | entry.index, |
| 147 | applied_key, |
| 148 | crate::control::array_sync::raft_apply::ArraySchemaPayload { |
| 149 | array, |
| 150 | snapshot_payload, |
| 151 | schema_hlc_bytes, |
| 152 | }, |
| 153 | ); |
| 154 | continue; |
| 155 | } |
nothing calls this directly
no test coverage detected