An actor framework in rust with message durability and ingestion order processing of messages. Message persistence via an embedded sqlite instance. Message content can be text or binary. Messages themselves get stored as binany in the backing store.
```rust use crate::{Actor, Mail, Msg, Producer}; use serde::{Deserialize, Serialize};
//A sample actor
pub struct DemoActor;
impl Actor for DemoActor {
fn receive(&mut self, incoming: Mail) -> Option
//Producer implementations are called to produce actor instances.
//Produces DemoActor instances
pub struct ActorProducer;
//Producer implementations need to be tagged with typetag
marker.
impl Producer for ActorProducer {
fn produce(&mut self) -> Box
//The define_actor
- macro actually defines a new actor instance
in the system. The
//actor instance along with the producer - get persisted in the backing store, the actor
//instance gets activated and receives a startup signal and becomes ready to process
//incoming messages. The producer defintion gets used to restart/restore the actor as
//required.
use arrows::define_actor;
let producer = ActorProducer::default(); defineactor!("demoactor", producer);
//At this stage - the actor instance demo_actor
is ready for incoming messages. It
//should have already received the startup signal.
use arrows::send;
let m1 = Msg::fromtext("Message to demo actor"); let m2 = Msg::fromtext("Message to demo actor"); let m3 = Msg::from_text("Message to demo actor");
send!("demo_actor", (m1, m2, m3));
//Create another actor instance - demo_actor1
defineactor!("demoactor1", ActorProducer::default());
let m4 = Msg::fromtext("Message to demo actor1"); let m5 = Msg::fromtext("Message to demo actor1");
let m6 = Msg::fromtext("Message to demo actor"); let m7 = Msg::fromtext("Message to demo actor");
//Send out multiple messages to multiple actors at one go
send!("demoactor1", (m4, m5), "demoactor", (m6, m7));
//Actors running in remote systems - need to be identified by the Addr
construct:
use arrows::Addr;
let remoteactor = Addr::remote("remoteactor", "11.11.11.11:8181");
let m1 = Msg::withtext("Message to remote actor"); let m2 = Msg::withtext("Message to remote actor");
send!("remote_actor", m1, m2);
//While sending to a single actor - its not recessary to group messages within braces. ```
register.sh
script in the project directory.server.sh
script in the same directorysend.sh
script - actors should start receiving messagesThis project is still evolving. Contributions are welcome.