v0.3.6-pre.008

This commit is contained in:
2026-09-01 15:14:57 +02:00
parent 138395ac35
commit 75cbf9df09
18 changed files with 1483 additions and 104 deletions

View File

@@ -1,5 +1,5 @@
// file: crates/ksp-job-backfill-lib/src/persistence.rs
// version: 1
// version: 2
/// Canonical entity disposition produced by one Backfill Store persistence attempt.
#[non_exhaustive]
@@ -43,6 +43,15 @@ pub struct BackfillPersistenceOutcome {
}
impl BackfillPersistenceOutcome {
/// Creates one internally classified persistence result.
pub(crate) fn new(
reference: ksp_store_lib::RawTransactionReference,
entity: BackfillEntityPersistence,
observation: BackfillObservationPersistence,
) -> Self {
return Self { reference, entity, observation };
}
/// Returns the network-scoped canonical transaction identity classified by this result.
#[must_use]
pub fn reference(&self) -> &ksp_store_lib::RawTransactionReference {
@@ -112,11 +121,11 @@ where
return std::result::Result::Err(persistence_error("store.network"));
}
return match hydration {
crate::BackfillHydrationOutcome::Missing(_) => std::result::Result::Ok(BackfillPersistenceOutcome {
crate::BackfillHydrationOutcome::Missing(_) => std::result::Result::Ok(BackfillPersistenceOutcome::new(
reference,
entity: BackfillEntityPersistence::Missing,
observation: BackfillObservationPersistence::NotApplicable,
}),
BackfillEntityPersistence::Missing,
BackfillObservationPersistence::NotApplicable,
)),
crate::BackfillHydrationOutcome::Available(acquisition) => {
let (transaction, observation) = acquisition.into_parts();
persist_available_with_port(port, reference, transaction, observation).await
@@ -144,11 +153,11 @@ where
std::result::Result::Ok(outcome) => map_store_outcome(reference, outcome),
std::result::Result::Err(error) => {
if error.code() == ksp_store_lib::ERROR_CODE_RAW_CONFLICT {
return std::result::Result::Ok(BackfillPersistenceOutcome {
return std::result::Result::Ok(BackfillPersistenceOutcome::new(
reference,
entity: BackfillEntityPersistence::Conflict,
observation: BackfillObservationPersistence::NotRecorded,
});
BackfillEntityPersistence::Conflict,
BackfillObservationPersistence::NotRecorded,
));
}
std::result::Result::Err(error)
},
@@ -162,32 +171,32 @@ fn map_store_outcome(
let entity = outcome.entity();
let observation = outcome.observation();
if entity == ksp_store_lib::RawEntityWriteOutcome::Inserted && observation == ksp_store_lib::RawObservationWriteOutcome::Inserted {
return std::result::Result::Ok(BackfillPersistenceOutcome {
return std::result::Result::Ok(BackfillPersistenceOutcome::new(
reference,
entity: BackfillEntityPersistence::Inserted,
observation: BackfillObservationPersistence::Inserted,
});
BackfillEntityPersistence::Inserted,
BackfillObservationPersistence::Inserted,
));
}
if entity == ksp_store_lib::RawEntityWriteOutcome::AlreadyPresent && observation == ksp_store_lib::RawObservationWriteOutcome::Inserted {
return std::result::Result::Ok(BackfillPersistenceOutcome {
return std::result::Result::Ok(BackfillPersistenceOutcome::new(
reference,
entity: BackfillEntityPersistence::AlreadyPresent,
observation: BackfillObservationPersistence::Inserted,
});
BackfillEntityPersistence::AlreadyPresent,
BackfillObservationPersistence::Inserted,
));
}
if entity == ksp_store_lib::RawEntityWriteOutcome::AlreadyPresent && observation == ksp_store_lib::RawObservationWriteOutcome::AlreadyPresent {
return std::result::Result::Ok(BackfillPersistenceOutcome {
return std::result::Result::Ok(BackfillPersistenceOutcome::new(
reference,
entity: BackfillEntityPersistence::AlreadyPresent,
observation: BackfillObservationPersistence::AlreadyPresent,
});
BackfillEntityPersistence::AlreadyPresent,
BackfillObservationPersistence::AlreadyPresent,
));
}
if entity == ksp_store_lib::RawEntityWriteOutcome::SkippedPurged && observation == ksp_store_lib::RawObservationWriteOutcome::NotRecorded {
return std::result::Result::Ok(BackfillPersistenceOutcome {
return std::result::Result::Ok(BackfillPersistenceOutcome::new(
reference,
entity: BackfillEntityPersistence::SkippedPurged,
observation: BackfillObservationPersistence::NotRecorded,
});
BackfillEntityPersistence::SkippedPurged,
BackfillObservationPersistence::NotRecorded,
));
}
return std::result::Result::Err(persistence_error("store.outcome"));
}