Skip to content

v0.1.7

Compare
Choose a tag to compare
@vertexclique vertexclique released this 12 May 08:55
· 62 commits to master since this release

This release contains manual commit mechanism inside agents.

async fn manual_commit_counter_agent(mut stream: CStream, ctx: Context<SharedState>) -> Result<()> {
    while let Some(msg) = stream.next().await {
        let m = msg.unwrap();
        // Read the incoming bytes as string
        let strm = m.payload_view::<str>().unwrap().unwrap().to_owned();
        println!("Received payload: `{}`", strm);

        // Increment message counter and print it.
        // Show how you can store an application state.
        let state = ctx.state();
        let msgcount = state.value.fetch_add(1, Ordering::AcqRel);
        println!("Message count: `{}`", msgcount);

        // We are done here.
        ctx.commit_async(m).await?;
    }

    Ok(())
}