Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

indexer-alt: simplify duration command-line parsing #20459

Merged
merged 27 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
68fb7be
indexer-alt: IngestionConfig::retry_interval_ms
amnn Nov 22, 2024
75dd2a4
indexer-alt: PipelineConfig::{commit,watermark}_interval_ms
amnn Nov 22, 2024
62a037e
indexer-alt: ConsistencyConfig::{consistent_pruning_interval,pruner_d…
amnn Nov 22, 2024
c2181d6
indexer-alt: PrunerConfig::{interval,delay}_ms
amnn Nov 23, 2024
ef8e731
indexer-alt: DbConfig::connection_timeout_ms
amnn Nov 24, 2024
1e5c1cc
indexer-alt: generalize GraphQLConfig
amnn Nov 23, 2024
e81e26e
indexer-alt: sui-default-config simplify auto-derives
amnn Nov 24, 2024
ad67683
indexer-alt: support custom renaming of config fields
amnn Nov 25, 2024
93626ed
indexer-alt: file-based configs
amnn Nov 24, 2024
ac6c569
indexer-alt: generate-config command
amnn Nov 24, 2024
1786a51
indexer-alt: shared committer config with overrides
amnn Nov 25, 2024
4c5ee65
indexer-alt: make `skip_watermarks` a command-line argument
amnn Nov 25, 2024
f688e2b
indexer-alt: enable pipelines by file-based config
amnn Nov 25, 2024
257e781
indexer-alt: pass ingestion client over CLI
amnn Nov 26, 2024
7ce41ca
indexer-alt: error on unexpected pipeline config
amnn Nov 26, 2024
5357d39
indexer-alt: Remove WRITE_CONCURRENCY_OVERRIDE
amnn Nov 26, 2024
09cc8d7
indexer-alt: IngestionArgs -> ClientArgs
amnn Nov 26, 2024
8bf56df
refactor(indexer-alt): configuration layers
amnn Nov 26, 2024
4e5ea38
indexer-alt: file-based configs -- add back --pipeline flag
amnn Nov 29, 2024
293d47e
doc(indexer-alt): file-based configs add comment for macros
amnn Nov 29, 2024
a98a76d
indexer-alt: configuration merging
amnn Nov 26, 2024
8d60b0d
indexer-alt: shared pruner configs with overrides
amnn Nov 26, 2024
b09c57b
indexer-alt: detect and warn against unrecognised fields.
amnn Nov 27, 2024
8f4d58f
indexer-alt: generate example config
amnn Nov 27, 2024
92f3a37
indexer-alt: Merge trait for configs
amnn Nov 29, 2024
18b79b7
chore(indexer-alt): explicit `extra: _` in patterns
amnn Nov 29, 2024
9d82995
chore(indexer-alt): rename TxAffectedAddress(es)
amnn Nov 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
indexer-alt: file-based configs -- add back --pipeline flag
## Description

Add back the `--pipeline` command-line argument, layered on top of the
file-based configuration.

## Test plan

```
sui$ cargo run -p sui-indexer-alt -- generate-config > /tmp/indexer.toml
# Remove some pipelines

sui$ cargo run -p sui-indexer-alt -- indexer            \
  --last-checkpoint 10000                               \
  --remote-store-url https://checkpoints.mainnet.sui.io \
  --config /tmp/indexer.toml                            \
  --pipeline i_dont_exist

sui$ cargo run -p sui-indexer-alt -- indexer            \
  --last-checkpoint 10000                               \
  --remote-store-url https://checkpoints.mainnet.sui.io \
  --config /tmp/indexer.toml                            \
  --pipeline kv_objects --pipeline kv_transactions

sui$ cargo run -p sui-indexer-alt -- indexer            \
  --last-checkpoint 10000                               \
  --remote-store-url https://checkpoints.mainnet.sui.io \
  --config /tmp/indexer.toml
```
  • Loading branch information
amnn committed Nov 29, 2024
commit 4e5ea38cf8267a51d749953f6ba32c688c3577a8
11 changes: 10 additions & 1 deletion crates/sui-indexer-alt/src/benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,22 @@ pub struct BenchmarkArgs {
/// Path to the local ingestion directory to read checkpoints data from.
#[arg(long)]
ingestion_path: PathBuf,

/// Only run the following pipelines. If not provided, all pipelines found in the
/// configuration file will be run.
#[arg(long, action = clap::ArgAction::Append)]
pipeline: Vec<String>,
}

pub async fn run_benchmark(
db_args: DbArgs,
benchmark_args: BenchmarkArgs,
indexer_config: IndexerConfig,
) -> anyhow::Result<()> {
let BenchmarkArgs { ingestion_path } = benchmark_args;
let BenchmarkArgs {
ingestion_path,
pipeline,
} = benchmark_args;

let ingestion_data = read_ingestion_data(&ingestion_path).await?;
let first_checkpoint = *ingestion_data.keys().next().unwrap();
Expand All @@ -34,6 +42,7 @@ pub async fn run_benchmark(
let indexer_args = IndexerArgs {
first_checkpoint: Some(first_checkpoint),
last_checkpoint: Some(last_checkpoint),
pipeline,
..Default::default()
};

Expand Down
32 changes: 32 additions & 0 deletions crates/sui-indexer-alt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ pub struct IndexerArgs {
#[arg(long)]
pub last_checkpoint: Option<u64>,

/// Only run the following pipelines. If not provided, all pipelines found in the
/// configuration file will be run.
#[arg(long, action = clap::ArgAction::Append)]
pipeline: Vec<String>,

/// Don't write to the watermark tables for concurrent pipelines.
#[arg(long)]
pub skip_watermark: bool,
Expand Down Expand Up @@ -90,6 +95,11 @@ pub struct Indexer {
/// Don't write to the watermark tables for concurrent pipelines.
skip_watermark: bool,

/// Optional filter for pipelines to run. If `None`, all pipelines added to the indexer will
/// run. Any pipelines that are present in this filter but not added to the indexer will yield
/// a warning when the indexer is run.
enabled_pipelines: Option<BTreeSet<String>>,

/// Pipelines that have already been registered with the indexer. Used to make sure a pipeline
/// with the same name isn't added twice.
added_pipelines: BTreeSet<&'static str>,
Expand Down Expand Up @@ -117,6 +127,7 @@ impl Indexer {
let IndexerArgs {
first_checkpoint,
last_checkpoint,
pipeline,
skip_watermark,
metrics_address,
} = indexer_args;
Expand Down Expand Up @@ -148,6 +159,11 @@ impl Indexer {
first_checkpoint,
last_checkpoint,
skip_watermark,
enabled_pipelines: if pipeline.is_empty() {
None
} else {
Some(pipeline.into_iter().collect())
},
added_pipelines: BTreeSet::new(),
cancel,
first_checkpoint_from_watermark: u64::MAX,
Expand Down Expand Up @@ -274,6 +290,14 @@ impl Indexer {
/// Ingestion will stop after consuming the configured `last_checkpoint`, if one is provided,
/// or will continue until it tracks the tip of the network.
pub async fn run(mut self) -> Result<JoinHandle<()>> {
if let Some(enabled_pipelines) = self.enabled_pipelines {
ensure!(
enabled_pipelines.is_empty(),
"Tried to enable pipelines that this indexer does not know about: \
{enabled_pipelines:#?}",
);
}

let metrics_handle = self
.metrics_service
.run()
Expand Down Expand Up @@ -328,6 +352,13 @@ impl Indexer {
P::NAME,
);

if let Some(enabled_pipelines) = &mut self.enabled_pipelines {
if !enabled_pipelines.remove(P::NAME) {
info!(pipeline = P::NAME, "Skipping");
return Ok(None);
}
}

let mut conn = self.db.connect().await.context("Failed DB connection")?;

let watermark = CommitterWatermark::get(&mut conn, P::NAME)
Expand All @@ -349,6 +380,7 @@ impl Default for IndexerArgs {
Self {
first_checkpoint: None,
last_checkpoint: None,
pipeline: vec![],
skip_watermark: false,
metrics_address: "0.0.0.0:9184".parse().unwrap(),
}
Expand Down