SIDS - An Actor Model Approach to Data Collection in RUST
This is an experimental actor-model system library built in rust. The repository has a few Mermaid diagrams and exxamples available for you to examine if you are interested in implementing the approach yourself.
Getting Started
Run the example logging demonstration.
git clone https://github.com/professor-greebie/sids
cd sids
cargo run --example loggers
What this does
This project demonstrates a simple approach to building actors in Rust, allowing for some abstraction between Tokio-type and blocking actors.
This is still a project in development, but it does illustrate how you might develop an actor system from scratch in Rust.
Basic Concepts:
An actor - an actor implements an Actor Trait to include a receive function that accepts a message type of Message<MType>.
The Message struct covers the most common Actor behaviors (stop, responses etc.), but you can add more as part of the payload, which is of type MType.
MType can be any base type (String, u32 etc.) or an enum provided that it has Send features and can have static lifetime. Enums are powerful in Rust, so they are highly recommended. See the Rust documentation on enum types for more information
Once you choose an MType, then the ActorSystem will use the same message type throughout the system. Currently, only one MType is allowed, however, with Rust's enums, there is a lot of capacity for variance on the types of messages that can be sent.
let mut actor_system = ;
Starting an actor system initializes the system and runs a 'boss' actor called the Guardian with an id of 0. You can ping the boss using sids::actors::ping_actor_system(&actor_system);
You can add an actor to the system, by creating a structure that implements the Actor trait. All actors in the system must receive a Message.
use Actor;
use Message;
use info;
// Messages can be any valid enum that can derive Clone.
// you can include some attributes like a name if you wish
;
// Actors must have static lifetime
,
async
## The Future
From a prototype perspective, this is final version of this project, except for performance and safety tweaks.
We will also include some more advanced examples, including using the Actor System to do Actor-Critic Machine Learning work.
## Citations
The following resources helped me a lot during the building of this demonstration.
- Mara Bos *Rust Atomics and Locks: Low-level concurrency in Practice.* O'Reilly Press.
- Alice Ryhl