Crates.io | yaaf |
lib.rs | yaaf |
version | 0.2.0 |
source | src |
created_at | 2020-12-31 01:54:24.376035 |
updated_at | 2021-01-01 00:17:59.768833 |
description | Yet Another Actor Framework |
homepage | |
repository | https://github.com/mark-burnett/yaaf/ |
max_upload_size | |
id | 329477 |
size | 52,540 |
A simple, local actor framework.
use ::std::time::Duration;
use ::tokio::time::sleep;
use ::yaaf::prelude::*;
#[derive(Clone, Debug)]
struct MyMessage;
#[derive(Actor)]
#[handle(MyMessage)]
struct MyActor;
#[async_trait]
impl Handler<MyMessage> for MyActor {
async fn handle(&mut self, _ctx: &mut Context<Self>, _message: MyMessage) {
println!("Received message");
}
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn ::std::error::Error>> {
let mut system = System::new().await?;
let actor = MyActor;
let addr = system.add_actor(actor).await?;
addr.tell(MyMessage);
sleep(Duration::from_millis(100));
system.shutdown().await?;
Ok(())
}
This software is licensed under the Apache License, Version 2.0.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.