sui_indexer/backfill/backfill_instances/
mod.rs

1// Copyright (c) Mysten Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4use crate::backfill::backfill_instances::ingestion_backfills::digest_task::DigestBackfill;
5use crate::backfill::backfill_instances::ingestion_backfills::ingestion_backfill_task::IngestionBackfillTask;
6use crate::backfill::backfill_instances::ingestion_backfills::raw_checkpoints::RawCheckpointsBackFill;
7use crate::backfill::backfill_instances::ingestion_backfills::tx_affected_objects::TxAffectedObjectsBackfill;
8use crate::backfill::backfill_task::BackfillTask;
9use crate::backfill::{BackfillTaskKind, IngestionBackfillKind};
10use std::sync::Arc;
11use sui_types::messages_checkpoint::CheckpointSequenceNumber;
12
13mod ingestion_backfills;
14mod sql_backfill;
15mod system_state_summary_json;
16
17pub async fn get_backfill_task(
18    kind: BackfillTaskKind,
19    range_start: usize,
20) -> Arc<dyn BackfillTask> {
21    match kind {
22        BackfillTaskKind::SystemStateSummaryJson => {
23            Arc::new(system_state_summary_json::SystemStateSummaryJsonBackfill)
24        }
25        BackfillTaskKind::Sql { sql, key_column } => {
26            Arc::new(sql_backfill::SqlBackFill::new(sql, key_column))
27        }
28        BackfillTaskKind::Ingestion {
29            kind,
30            remote_store_url,
31        } => match kind {
32            IngestionBackfillKind::Digest => Arc::new(
33                IngestionBackfillTask::<DigestBackfill>::new(
34                    remote_store_url,
35                    range_start as CheckpointSequenceNumber,
36                )
37                .await,
38            ),
39            IngestionBackfillKind::RawCheckpoints => Arc::new(
40                IngestionBackfillTask::<RawCheckpointsBackFill>::new(
41                    remote_store_url,
42                    range_start as CheckpointSequenceNumber,
43                )
44                .await,
45            ),
46            IngestionBackfillKind::TxAffectedObjects => Arc::new(
47                IngestionBackfillTask::<TxAffectedObjectsBackfill>::new(
48                    remote_store_url,
49                    range_start as CheckpointSequenceNumber,
50                )
51                .await,
52            ),
53        },
54    }
55}