Created
March 9, 2023 06:12
-
-
Save steezeburger/0e83f65a86e88f27b08dbee3f00443c5 to your computer and use it in GitHub Desktop.
Hierarchical configuration with printlns for auditing purposes.
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
use std::time::Duration; | |
use clap::Parser; | |
use color_eyre::eyre::Result; | |
use figment::{providers::{Env, Format, Serialized, Toml}, Figment, Provider}; | |
use tokio::{signal, time}; | |
use crate::alert::Alert; | |
use crate::cli::Cli; | |
use crate::config::Config; | |
use crate::driver::{spawn, DriverCommand}; | |
pub(crate) mod alert; | |
pub(crate) mod cli; | |
pub(crate) mod config; | |
pub(crate) mod driver; | |
pub(crate) mod executor; | |
pub(crate) mod logger; | |
pub(crate) mod reader; | |
pub async fn run() -> Result<()> { | |
// logs | |
logger::initialize(); | |
// hierarchical config. cli args override Envars which override toml config values | |
let mut figment = Figment::new(); | |
if let toml_config = Toml::file("ConductorConfig.toml") { | |
println!("{:#?}", toml_config.data()); | |
figment = figment.merge(toml_config); | |
} | |
if let env_config = Env::prefixed("ASTRIA_") { | |
println!("{:#?}", env_config.data()); | |
figment = figment.merge(env_config); | |
} | |
if let cli_config = Serialized::defaults(Cli::parse()) { | |
println!("{:#?}", cli_config.data()); | |
figment = figment.merge(cli_config); | |
} | |
let conf: Config = figment.extract()?; | |
log::info!("Using node at {}", conf.celestia_node_url); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment