We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
send()
Now send() panics if there is an error. Sometimes it's useful to check it.
The text was updated successfully, but these errors were encountered:
so does request().
request()
It would be nice to have it without a built-in panic, so that in the following code, it would be possible to check for request errors.
#[tokio::test] async fn test() { #[message(ret=())] struct Ping { target: u32, } #[message] struct Spawn { target: u32, } #[message] struct Stop { target: u32, } use elfo::{ routers::{MapRouter, Outcome}, ActorGroup, Context, }; fn new() -> Blueprint { ActorGroup::new() .restart_policy(RestartPolicy::never()) .router(MapRouter::new(|envelope| { msg!(match envelope { Spawn { target, .. } => Outcome::Unicast(*target), Ping { target } => Outcome::GentleUnicast(*target), Stop { target, .. } => Outcome::GentleUnicast(*target), _ => Outcome::Default, }) })) .exec(move |ctx| async move { async fn run(mut ctx: Context<(), u32>) -> eyre::Result<()> { info!("i'm awake", id = ctx.key()); while let Some(m) = ctx.recv().await { msg!(match m { Spawn => {} Stop => break, (Ping, token) => {}, }) } info!("stopped", id = ctx.key()); Ok(()) } run(ctx).await }) } let mut test = elfo::test::proxy(new(), AnyConfig::default()).await; test.send(Spawn { target: 1 }).await; test.send(Spawn { target: 2 }).await; test.send(Spawn { target: 3 }).await; test.send(Stop { target: 2 }).await; tokio::time::sleep(Duration::from_secs(1)).await; // ignored test.request(Ping { target: 1}).await; //panics, would be nice to check error here // failed let test = test.request(Ping { target: 2}).await; //panics, would be nice to check error here }
Sorry, something went wrong.
No branches or pull requests
Now
send()
panics if there is an error. Sometimes it's useful to check it.The text was updated successfully, but these errors were encountered: