MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / record_effect_outcome

Method record_effect_outcome

atomic-repository/src/repository/operation.rs:2126–2170  ·  view source on GitHub ↗
(
        &self,
        operation_lock: &WorkingCopyOperationLockGuard,
        operation_id: OperationId,
        effect_ordinal: u32,
        observed_before: EffectValue,
        observed_after: E

Source from the content-addressed store, hash-verified

2124 }
2125
2126 pub(super) fn record_effect_outcome(
2127 &self,
2128 operation_lock: &WorkingCopyOperationLockGuard,
2129 operation_id: OperationId,
2130 effect_ordinal: u32,
2131 observed_before: EffectValue,
2132 observed_after: EffectValue,
2133 ) -> Result<EffectReceipt, RepositoryError> {
2134 let operation = self.load_operation(operation_id)?;
2135 self.validate_operation_lock(operation_lock, &operation)?;
2136 let effect = effect_at(&operation, effect_ordinal)?;
2137 let classification =
2138 classify_effect_lease(&observed_before, &effect.expected_old, &effect.expected_new);
2139 if classification == LeaseClassification::Diverged || observed_after != effect.expected_new
2140 {
2141 let receipt = deterministic_effect_receipt(
2142 &operation,
2143 Some(effect_ordinal),
2144 EffectReceiptKind::LeaseRejected,
2145 Some(observed_before.clone()),
2146 Some(observed_after.clone()),
2147 )?;
2148 self.append_receipt_immediate(operation_lock, &operation, &receipt)?;
2149 return Err(lease_divergence_error(
2150 effect,
2151 &observed_before,
2152 Some(&observed_after),
2153 ));
2154 }
2155
2156 let kind = match classification {
2157 LeaseClassification::Apply => EffectReceiptKind::Applied,
2158 LeaseClassification::AlreadyApplied => EffectReceiptKind::Recovered,
2159 LeaseClassification::Diverged => unreachable!("handled above"),
2160 };
2161 let receipt = deterministic_effect_receipt(
2162 &operation,
2163 Some(effect_ordinal),
2164 kind,
2165 Some(observed_before),
2166 Some(observed_after),
2167 )?;
2168 self.append_receipt_immediate(operation_lock, &operation, &receipt)?;
2169 Ok(receipt)
2170 }
2171
2172 /// Append the deterministic operation-level `Verified` receipt immediately.
2173 pub(super) fn finalize_operation_verified(

Calls 8

effect_atFunction · 0.85
classify_effect_leaseFunction · 0.85
lease_divergence_errorFunction · 0.85
load_operationMethod · 0.80
cloneMethod · 0.45