2024-12-03 06:09:01 +00:00
|
|
|
mod publisher;
|
2024-12-03 05:15:10 +00:00
|
|
|
mod validator;
|
2024-11-26 01:30:55 +00:00
|
|
|
|
2024-12-03 06:09:01 +00:00
|
|
|
#[allow(dead_code)]
|
|
|
|
#[derive(Debug)]
|
|
|
|
enum StartupError{
|
|
|
|
Connect(async_nats::ConnectError),
|
|
|
|
Subscribe(async_nats::SubscribeError),
|
|
|
|
}
|
|
|
|
|
2024-12-03 05:15:10 +00:00
|
|
|
#[tokio::main]
|
2024-12-03 06:09:01 +00:00
|
|
|
async fn main()->Result<(),StartupError>{
|
|
|
|
let nasty=async_nats::connect("nats").await.map_err(StartupError::Connect)?;
|
|
|
|
let (publisher,validator)=tokio::try_join!(
|
|
|
|
publisher::Publisher::new(nasty.clone()),
|
|
|
|
validator::Validator::new(nasty)
|
|
|
|
).map_err(StartupError::Subscribe)?;
|
|
|
|
// publisher thread
|
|
|
|
tokio::spawn(publisher.run());
|
|
|
|
// run validator on the main thread indefinitely
|
|
|
|
validator.run().await;
|
|
|
|
Ok(())
|
2024-11-26 01:30:55 +00:00
|
|
|
}
|