2023-09-24 21:57:24 +02:00
|
|
|
mod gencrunch;
|
2023-09-24 21:09:40 +02:00
|
|
|
|
2023-09-24 21:57:24 +02:00
|
|
|
use gencrunch::basic::{includes::my_include::MyInclude, my_event::MyEvent};
|
2023-09-24 10:48:41 +02:00
|
|
|
|
|
|
|
#[tokio::main]
|
|
|
|
async fn main() -> anyhow::Result<()> {
|
2023-09-24 22:04:34 +02:00
|
|
|
let crunch = crunch::Builder::default().build()?;
|
2023-09-24 10:48:41 +02:00
|
|
|
|
|
|
|
crunch
|
2023-09-24 21:57:24 +02:00
|
|
|
.subscribe(|item: MyEvent| async move {
|
|
|
|
println!("received item: {:?}", item);
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
})
|
|
|
|
.await?;
|
|
|
|
|
|
|
|
crunch
|
|
|
|
.publish(MyEvent {
|
|
|
|
name: "some-name".into(),
|
|
|
|
include: Some(MyInclude {
|
|
|
|
name: "some-name".into(),
|
|
|
|
}),
|
|
|
|
})
|
2023-09-24 10:48:41 +02:00
|
|
|
.await?;
|
|
|
|
|
2023-09-24 21:57:24 +02:00
|
|
|
// Sleep a while to let subscriber catch item
|
|
|
|
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
|
2023-09-24 10:48:41 +02:00
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|