-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[docs] Local ingestion custom indexer docs update and example (#18957)
## Description Added the local ingestion custom indexer example as well as doc improvement ## Test plan Manually --- ## Release notes Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required. For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates. - [ ] Protocol: - [ ] Nodes (Validators and Full nodes): - [ ] Indexer: - [ ] JSON-RPC: - [ ] GraphQL: - [ ] CLI: - [ ] Rust SDK: - [ ] REST API: --------- Co-authored-by: ronny-mysten <118224482+ronny-mysten@users.noreply.github.com>
- Loading branch information
1 parent
7d103a9
commit 5ed526a
Showing
5 changed files
with
106 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use tokio::sync::oneshot; | ||
use anyhow::Result; | ||
use async_trait::async_trait; | ||
use sui_types::full_checkpoint_content::CheckpointData; | ||
use sui_data_ingestion_core as sdic; | ||
use sdic::{Worker, WorkerPool, ReaderOptions}; | ||
use sdic::{DataIngestionMetrics, FileProgressStore, IndexerExecutor}; | ||
use prometheus::Registry; | ||
use std::path::PathBuf; | ||
use std::env; | ||
|
||
struct CustomWorker; | ||
|
||
#[async_trait] | ||
impl Worker for CustomWorker { | ||
async fn process_checkpoint(&self, checkpoint: CheckpointData) -> Result<()> { | ||
// custom processing logic | ||
println!("Processing Local checkpoint: {}", checkpoint.checkpoint_summary.to_string()); | ||
Ok(()) | ||
} | ||
} | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<()> { | ||
let concurrency = 5; | ||
let (exit_sender, exit_receiver) = oneshot::channel(); | ||
let metrics = DataIngestionMetrics::new(&Registry::new()); | ||
let backfill_progress_file_path = | ||
env::var("BACKFILL_PROGRESS_FILE_PATH").unwrap_or("/tmp/local_reader_progress".to_string()); | ||
let progress_store = FileProgressStore::new(PathBuf::from(backfill_progress_file_path)); | ||
let mut executor = IndexerExecutor::new(progress_store, 1 /* number of workflow types */, metrics); | ||
let worker_pool = WorkerPool::new(CustomWorker, "local_reader".to_string(), concurrency); | ||
|
||
executor.register(worker_pool).await?; | ||
executor.run( | ||
PathBuf::from("./chk".to_string()), // path to a local directory | ||
None, | ||
vec![], // optional remote store access options | ||
ReaderOptions::default(), /* remote_read_batch_size */ | ||
exit_receiver, | ||
).await?; | ||
Ok(()) | ||
} |
File renamed without changes.