v0.3.6-pre.009-fix.001
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-job-backfill-lib/src/persistence.rs
|
||||
// version: 2
|
||||
// version: 3
|
||||
|
||||
/// Canonical entity disposition produced by one Backfill Store persistence attempt.
|
||||
#[non_exhaustive]
|
||||
@@ -38,16 +38,16 @@ pub enum BackfillObservationPersistence {
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct BackfillPersistenceOutcome {
|
||||
reference: ksp_store_lib::RawTransactionReference,
|
||||
entity: BackfillEntityPersistence,
|
||||
observation: BackfillObservationPersistence,
|
||||
entity: crate::BackfillEntityPersistence,
|
||||
observation: crate::BackfillObservationPersistence,
|
||||
}
|
||||
|
||||
impl BackfillPersistenceOutcome {
|
||||
impl crate::BackfillPersistenceOutcome {
|
||||
/// Creates one internally classified persistence result.
|
||||
pub(crate) fn new(
|
||||
reference: ksp_store_lib::RawTransactionReference,
|
||||
entity: BackfillEntityPersistence,
|
||||
observation: BackfillObservationPersistence,
|
||||
entity: crate::BackfillEntityPersistence,
|
||||
observation: crate::BackfillObservationPersistence,
|
||||
) -> Self {
|
||||
return Self { reference, entity, observation };
|
||||
}
|
||||
@@ -60,13 +60,13 @@ impl BackfillPersistenceOutcome {
|
||||
|
||||
/// Returns the canonical transaction persistence disposition.
|
||||
#[must_use]
|
||||
pub const fn entity(&self) -> BackfillEntityPersistence {
|
||||
pub const fn entity(&self) -> crate::BackfillEntityPersistence {
|
||||
return self.entity;
|
||||
}
|
||||
|
||||
/// Returns the acquisition-observation persistence disposition.
|
||||
#[must_use]
|
||||
pub const fn observation(&self) -> BackfillObservationPersistence {
|
||||
pub const fn observation(&self) -> crate::BackfillObservationPersistence {
|
||||
return self.observation;
|
||||
}
|
||||
}
|
||||
@@ -81,7 +81,7 @@ impl BackfillPersistenceOutcome {
|
||||
pub async fn persist_backfill_hydration(
|
||||
store: &ksp_store_lib::Store,
|
||||
hydration: crate::BackfillHydrationOutcome,
|
||||
) -> ksp_core_lib::Result<BackfillPersistenceOutcome> {
|
||||
) -> ksp_core_lib::Result<crate::BackfillPersistenceOutcome> {
|
||||
return persist_hydration_with_port(store, hydration).await;
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ impl RawTransactionPersistencePort for ksp_store_lib::Store {
|
||||
}
|
||||
}
|
||||
|
||||
async fn persist_hydration_with_port<P>(port: &P, hydration: crate::BackfillHydrationOutcome) -> ksp_core_lib::Result<BackfillPersistenceOutcome>
|
||||
async fn persist_hydration_with_port<P>(port: &P, hydration: crate::BackfillHydrationOutcome) -> ksp_core_lib::Result<crate::BackfillPersistenceOutcome>
|
||||
where
|
||||
P: RawTransactionPersistencePort,
|
||||
{
|
||||
@@ -121,10 +121,10 @@ where
|
||||
return std::result::Result::Err(persistence_error("store.network"));
|
||||
}
|
||||
return match hydration {
|
||||
crate::BackfillHydrationOutcome::Missing(_) => std::result::Result::Ok(BackfillPersistenceOutcome::new(
|
||||
crate::BackfillHydrationOutcome::Missing(_) => std::result::Result::Ok(crate::BackfillPersistenceOutcome::new(
|
||||
reference,
|
||||
BackfillEntityPersistence::Missing,
|
||||
BackfillObservationPersistence::NotApplicable,
|
||||
crate::BackfillEntityPersistence::Missing,
|
||||
crate::BackfillObservationPersistence::NotApplicable,
|
||||
)),
|
||||
crate::BackfillHydrationOutcome::Available(acquisition) => {
|
||||
let (transaction, observation) = acquisition.into_parts();
|
||||
@@ -138,7 +138,7 @@ async fn persist_available_with_port<P>(
|
||||
reference: ksp_store_lib::RawTransactionReference,
|
||||
transaction: ksp_store_lib::RawTransaction,
|
||||
observation: ksp_store_lib::RawTransactionObservation,
|
||||
) -> ksp_core_lib::Result<BackfillPersistenceOutcome>
|
||||
) -> ksp_core_lib::Result<crate::BackfillPersistenceOutcome>
|
||||
where
|
||||
P: RawTransactionPersistencePort,
|
||||
{
|
||||
@@ -153,10 +153,10 @@ 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::new(
|
||||
return std::result::Result::Ok(crate::BackfillPersistenceOutcome::new(
|
||||
reference,
|
||||
BackfillEntityPersistence::Conflict,
|
||||
BackfillObservationPersistence::NotRecorded,
|
||||
crate::BackfillEntityPersistence::Conflict,
|
||||
crate::BackfillObservationPersistence::NotRecorded,
|
||||
));
|
||||
}
|
||||
std::result::Result::Err(error)
|
||||
@@ -167,35 +167,35 @@ where
|
||||
fn map_store_outcome(
|
||||
reference: ksp_store_lib::RawTransactionReference,
|
||||
outcome: ksp_store_lib::RawAcquisitionWriteOutcome,
|
||||
) -> ksp_core_lib::Result<BackfillPersistenceOutcome> {
|
||||
) -> ksp_core_lib::Result<crate::BackfillPersistenceOutcome> {
|
||||
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::new(
|
||||
return std::result::Result::Ok(crate::BackfillPersistenceOutcome::new(
|
||||
reference,
|
||||
BackfillEntityPersistence::Inserted,
|
||||
BackfillObservationPersistence::Inserted,
|
||||
crate::BackfillEntityPersistence::Inserted,
|
||||
crate::BackfillObservationPersistence::Inserted,
|
||||
));
|
||||
}
|
||||
if entity == ksp_store_lib::RawEntityWriteOutcome::AlreadyPresent && observation == ksp_store_lib::RawObservationWriteOutcome::Inserted {
|
||||
return std::result::Result::Ok(BackfillPersistenceOutcome::new(
|
||||
return std::result::Result::Ok(crate::BackfillPersistenceOutcome::new(
|
||||
reference,
|
||||
BackfillEntityPersistence::AlreadyPresent,
|
||||
BackfillObservationPersistence::Inserted,
|
||||
crate::BackfillEntityPersistence::AlreadyPresent,
|
||||
crate::BackfillObservationPersistence::Inserted,
|
||||
));
|
||||
}
|
||||
if entity == ksp_store_lib::RawEntityWriteOutcome::AlreadyPresent && observation == ksp_store_lib::RawObservationWriteOutcome::AlreadyPresent {
|
||||
return std::result::Result::Ok(BackfillPersistenceOutcome::new(
|
||||
return std::result::Result::Ok(crate::BackfillPersistenceOutcome::new(
|
||||
reference,
|
||||
BackfillEntityPersistence::AlreadyPresent,
|
||||
BackfillObservationPersistence::AlreadyPresent,
|
||||
crate::BackfillEntityPersistence::AlreadyPresent,
|
||||
crate::BackfillObservationPersistence::AlreadyPresent,
|
||||
));
|
||||
}
|
||||
if entity == ksp_store_lib::RawEntityWriteOutcome::SkippedPurged && observation == ksp_store_lib::RawObservationWriteOutcome::NotRecorded {
|
||||
return std::result::Result::Ok(BackfillPersistenceOutcome::new(
|
||||
return std::result::Result::Ok(crate::BackfillPersistenceOutcome::new(
|
||||
reference,
|
||||
BackfillEntityPersistence::SkippedPurged,
|
||||
BackfillObservationPersistence::NotRecorded,
|
||||
crate::BackfillEntityPersistence::SkippedPurged,
|
||||
crate::BackfillObservationPersistence::NotRecorded,
|
||||
));
|
||||
}
|
||||
return std::result::Result::Err(persistence_error("store.outcome"));
|
||||
|
||||
Reference in New Issue
Block a user