Skip to content

Commit 0f5c6d5

Browse files
committed
move config to sdk
1 parent 051a77e commit 0f5c6d5

File tree

8 files changed

+420
-3
lines changed

8 files changed

+420
-3
lines changed

aptos-indexer-processors-sdk/Cargo.lock

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

aptos-indexer-processors-sdk/sdk-server-framework/src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use anyhow::{Context, Result};
44
use aptos_indexer_processor_sdk::{
55
instrumented_channel::channel_metrics::init_channel_metrics_registry,
6-
utils::step_metrics::init_step_metrics_registry,
6+
traits::processor_trait::ProcessorTrait, utils::step_metrics::init_step_metrics_registry,
77
};
88
#[cfg(target_os = "linux")]
99
use aptos_system_utils::profiling::start_cpu_profiling;
@@ -20,6 +20,8 @@ use tokio::runtime::Handle;
2020
use tracing::error;
2121
use tracing_subscriber::EnvFilter;
2222

23+
// pub mod config;
24+
2325
/// ServerArgs bootstraps a server with all common pieces. And then triggers the run method for
2426
/// the specific service.
2527
#[derive(Parser)]
@@ -29,9 +31,10 @@ pub struct ServerArgs {
2931
}
3032

3133
impl ServerArgs {
32-
pub async fn run<C>(&self, handle: Handle) -> Result<()>
34+
pub async fn run<C, P>(&self, handle: Handle) -> Result<()>
3335
where
3436
C: RunnableConfig,
37+
P: ProcessorTrait,
3538
{
3639
// Set up the server.
3740
setup_logging();

aptos-indexer-processors-sdk/sdk/Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,12 @@ tiny-keccak = { workspace = true }
3838
tokio = { workspace = true }
3939
tracing = { workspace = true }
4040
url = { workspace = true }
41+
42+
autometrics = { workspace = true }
43+
axum = { workspace = true }
44+
backtrace = { workspace = true }
45+
clap = { workspace = true }
46+
serde_yaml = { workspace = true }
47+
tempfile = { workspace = true }
48+
toml = { workspace = true }
49+
tracing-subscriber = { workspace = true }
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// Copyright © Aptos Foundation
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
use crate::{
5+
aptos_indexer_transaction_stream::TransactionStreamConfig, common_steps::ProcessorStatusSaver,
6+
};
7+
use anyhow::Result;
8+
use serde::{de::DeserializeOwned, Deserialize, Serialize};
9+
use std::any::Any;
10+
11+
pub const QUERY_DEFAULT_RETRIES: u32 = 5;
12+
pub const QUERY_DEFAULT_RETRY_DELAY_MS: u64 = 500;
13+
14+
#[derive(Clone, Debug, Deserialize, Serialize)]
15+
#[serde(deny_unknown_fields)]
16+
pub struct IndexerProcessorConfig<D> {
17+
pub processor_name: String,
18+
pub transaction_stream_config: TransactionStreamConfig,
19+
pub db_config: D,
20+
pub backfill_config: Option<BackfillConfig>,
21+
}
22+
23+
// #[async_trait::async_trait]
24+
// impl RunnableConfig for IndexerProcessorConfig {
25+
// async fn run(&self) -> Result<()> {
26+
// match self.processor_config {
27+
// ProcessorConfig::EventsProcessor => {
28+
// let events_processor = EventsProcessor::new(self.clone()).await?;
29+
// events_processor.run_processor().await
30+
// },
31+
// }
32+
// }
33+
34+
// fn get_server_name(&self) -> String {
35+
// // Get the part before the first _ and trim to 12 characters.
36+
// let before_underscore = self
37+
// .processor_config
38+
// .name()
39+
// .split('_')
40+
// .next()
41+
// .unwrap_or("unknown");
42+
// before_underscore[..before_underscore.len().min(12)].to_string()
43+
// }
44+
// }
45+
46+
// Note: You'll need to create a concrete implementation of this trait
47+
// for your specific database configuration
48+
pub trait DbConfig: Any + Clone + DeserializeOwned + ProcessorStatusSaver + Serialize {}
49+
50+
// #[derive(Clone, Debug, Deserialize, Serialize)]
51+
// #[serde(deny_unknown_fields)]
52+
// pub struct PostgresConfig {
53+
// pub postgres_connection_string: String,
54+
// // Size of the pool for writes/reads to the DB. Limits maximum number of queries in flight
55+
// #[serde(default = "PostgresConfig::default_db_pool_size")]
56+
// pub db_pool_size: u32,
57+
// }
58+
59+
// impl DbConfig for PostgresConfig {}
60+
61+
// impl PostgresConfig {
62+
// pub const fn default_db_pool_size() -> u32 {
63+
// 150
64+
// }
65+
// }
66+
67+
#[derive(Clone, Debug, Deserialize, Serialize)]
68+
#[serde(deny_unknown_fields)]
69+
pub struct BackfillConfig {
70+
pub backfill_alias: String,
71+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod indexer_processor_config;

aptos-indexer-processors-sdk/sdk/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
pub mod builder;
22
pub mod common_steps; // TODO: Feature gate this?
3+
pub mod config;
4+
pub mod server_framework;
35
pub mod test;
46
pub mod traits;
57
pub mod types;

0 commit comments

Comments
 (0)