chore: standardize agent main files

buddies-main-deployment
James Prestwich 3 years ago
parent aff52ce2a9
commit b2cdab4721
No known key found for this signature in database
GPG Key ID: 7CC174C250AD83AD
  1. 5
      rust/kathy/src/main.rs
  2. 18
      rust/processor/src/main.rs
  3. 19
      rust/relayer/src/main.rs
  4. 19
      rust/updater/src/main.rs
  5. 19
      rust/watcher/src/main.rs

@ -15,12 +15,11 @@ use crate::{kathy::Kathy, settings::KathySettings as Settings};
async fn _main() -> Result<()> { async fn _main() -> Result<()> {
color_eyre::install()?; color_eyre::install()?;
let settings = Settings::new()?; let settings = Settings::new()?;
settings.base.tracing.try_init_tracing()?; settings.base.tracing.try_init_tracing()?;
let kathy = Kathy::from_settings(settings).await?; let agent = Kathy::from_settings(settings).await?;
kathy.run_all().await?; agent.run_all().await?;
Ok(()) Ok(())
} }

@ -17,26 +17,20 @@ use color_eyre::Result;
use crate::{processor::Processor, settings::ProcessorSettings as Settings}; use crate::{processor::Processor, settings::ProcessorSettings as Settings};
use optics_base::agent::OpticsAgent; use optics_base::agent::OpticsAgent;
async fn _main(settings: Settings) -> Result<()> { async fn _main() -> Result<()> {
let processor = Processor::from_settings(settings).await?;
processor.run_all().await?;
Ok(())
}
fn setup() -> Result<Settings> {
color_eyre::install()?; color_eyre::install()?;
let settings = Settings::new()?; let settings = Settings::new()?;
settings.base.tracing.try_init_tracing()?; settings.base.tracing.try_init_tracing()?;
Ok(settings)
let agent = Processor::from_settings(settings).await?;
agent.run_all().await?;
Ok(())
} }
fn main() -> Result<()> { fn main() -> Result<()> {
let settings = setup()?;
tokio::runtime::Builder::new_current_thread() tokio::runtime::Builder::new_current_thread()
.enable_all() .enable_all()
.build() .build()
.unwrap() .unwrap()
.block_on(_main(settings)) .block_on(_main())
} }

@ -19,29 +19,20 @@ use optics_base::agent::OpticsAgent;
use crate::{relayer::Relayer, settings::RelayerSettings as Settings}; use crate::{relayer::Relayer, settings::RelayerSettings as Settings};
async fn _main(settings: Settings) -> Result<()> { async fn _main() -> Result<()> {
let relayer = Relayer::from_settings(settings).await?;
relayer.run_all().await?;
Ok(())
}
fn setup() -> Result<Settings> {
color_eyre::install()?; color_eyre::install()?;
let settings = Settings::new()?; let settings = Settings::new()?;
settings.base.tracing.try_init_tracing()?; settings.base.tracing.try_init_tracing()?;
Ok(settings) let agent = Relayer::from_settings(settings).await?;
agent.run_all().await?;
Ok(())
} }
fn main() -> Result<()> { fn main() -> Result<()> {
let settings = setup()?;
tokio::runtime::Builder::new_current_thread() tokio::runtime::Builder::new_current_thread()
.enable_all() .enable_all()
.build() .build()
.unwrap() .unwrap()
.block_on(_main(settings)) .block_on(_main())
} }

@ -16,29 +16,20 @@ use optics_base::agent::OpticsAgent;
use crate::{settings::UpdaterSettings as Settings, updater::Updater}; use crate::{settings::UpdaterSettings as Settings, updater::Updater};
async fn _main(settings: Settings) -> Result<()> { async fn _main() -> Result<()> {
let updater = Updater::from_settings(settings).await?;
updater.run("").await??;
Ok(())
}
fn setup() -> Result<Settings> {
color_eyre::install()?; color_eyre::install()?;
let settings = Settings::new()?; let settings = Settings::new()?;
settings.base.tracing.try_init_tracing()?; settings.base.tracing.try_init_tracing()?;
Ok(settings) let agent = Updater::from_settings(settings).await?;
agent.run_all().await?;
Ok(())
} }
fn main() -> Result<()> { fn main() -> Result<()> {
let settings = setup()?;
tokio::runtime::Builder::new_current_thread() tokio::runtime::Builder::new_current_thread()
.enable_all() .enable_all()
.build() .build()
.unwrap() .unwrap()
.block_on(_main(settings)) .block_on(_main())
} }

@ -18,29 +18,20 @@ use optics_base::agent::OpticsAgent;
use crate::{settings::WatcherSettings as Settings, watcher::Watcher}; use crate::{settings::WatcherSettings as Settings, watcher::Watcher};
async fn _main(settings: Settings) -> Result<()> { async fn _main() -> Result<()> {
let watcher = Watcher::from_settings(settings).await?;
watcher.run_all().await?;
Ok(())
}
fn setup() -> Result<Settings> {
color_eyre::install()?; color_eyre::install()?;
let settings = Settings::new()?; let settings = Settings::new()?;
settings.base.tracing.try_init_tracing()?; settings.base.tracing.try_init_tracing()?;
Ok(settings) let agent = Watcher::from_settings(settings).await?;
agent.run_all().await?;
Ok(())
} }
fn main() -> Result<()> { fn main() -> Result<()> {
let settings = setup()?;
tokio::runtime::Builder::new_current_thread() tokio::runtime::Builder::new_current_thread()
.enable_all() .enable_all()
.build() .build()
.unwrap() .unwrap()
.block_on(_main(settings)) .block_on(_main())
} }

Loading…
Cancel
Save