Skip to content

Commit

Permalink
small improvement epoch indexer config
Browse files Browse the repository at this point in the history
  • Loading branch information
kobayurii committed Feb 2, 2024
1 parent 1ba97b1 commit c46b0cb
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 13 deletions.
7 changes: 0 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion configuration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ aws-sdk-s3 = { version = "0.39.1", features = ["behavior-version-latest"] }
aws-types = "1.0.0"
dotenv = "0.15.0"
lazy_static = "1.4.0"
project-root = "0.2.2"
regex = "1.10.2"
serde = "1.0.145"
serde_derive = "1.0.145"
Expand Down
2 changes: 0 additions & 2 deletions configuration/src/configs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ impl Config for StateIndexerConfig {
#[derive(Debug, Clone)]
pub struct EpochIndexerConfig {
pub general: general::GeneralEpochIndexerConfig,
pub rightsizing: rightsizing::RightsizingConfig,
pub lake_config: lake::LakeConfig,
pub database: database::DatabaseConfig,
}
Expand All @@ -160,7 +159,6 @@ impl Config for EpochIndexerConfig {
fn from_common_config(common_config: CommonConfig) -> Self {
Self {
general: common_config.general.into(),
rightsizing: common_config.rightsizing.into(),
lake_config: common_config.lake_config,
database: database::DatabaseStateIndexerConfig::from(common_config.database).into(),
}
Expand Down
18 changes: 16 additions & 2 deletions configuration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ pub async fn read_configuration<T>() -> anyhow::Result<T>
where
T: configs::Config + Send + Sync + 'static,
{
let path_root = project_root::get_project_root()?;
let path_root = find_configs_root().await?;
load_env(path_root.clone()).await?;
let common_config = read_toml_file(path_root).await?;
Ok(T::from_common_config(common_config))
}

pub async fn init_tracing(service_name: &str) -> anyhow::Result<()> {
let path_root = project_root::get_project_root()?;
let path_root = find_configs_root().await?;
load_env(path_root.clone()).await?;

let mut env_filter = tracing_subscriber::EnvFilter::new(format!("{}=info", service_name));
Expand Down Expand Up @@ -112,3 +112,17 @@ async fn read_toml_file(mut path_root: PathBuf) -> anyhow::Result<configs::Commo
}
}
}

async fn find_configs_root() -> anyhow::Result<PathBuf> {
let current_path = std::env::current_dir()?;

for path_config in current_path.as_path().ancestors() {
let has_config = std::fs::read_dir(path_config)?.any(|path| {
path.unwrap().file_name() == std::ffi::OsString::from(String::from("config.toml"))
});
if has_config {
return Ok(PathBuf::from(path_config));
}
}
anyhow::bail!("Ran out of places to find config.toml")
}
4 changes: 3 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ services:
environment:
<<: *common-variables
SERVER_PORT: 8000
RUST_LOG: "read_rpc_server=debug,shadow_data_consistency=debug"
RUST_LOG: "read_rpc_server=debug,shadow_data_consistency=debug,info"
restart: on-failure
ports:
- 8000:8000
Expand All @@ -43,6 +43,7 @@ services:
environment:
<<: *common-variables
STATE_INDEXER_ID: state-indexer-local
RUST_LOG: "info"
command: [ "from-interruption" ]
ports:
- 8080:8080
Expand All @@ -60,6 +61,7 @@ services:
environment:
<<: *common-variables
TX_INDEXER_ID: tx-indexer-local
RUST_LOG: "info"
command: [ "from-interruption" ]
ports:
- 8081:8081
Expand Down

0 comments on commit c46b0cb

Please sign in to comment.