Crates.io | act_rs |
lib.rs | act_rs |
version | 0.2.0 |
source | src |
created_at | 2023-07-20 04:39:44.900611 |
updated_at | 2024-05-20 05:11:41.38884 |
description | Act.rs is an actor library built to be used with the standard library and Tokio. |
homepage | https://coruscateor.com/projects/act_rs |
repository | https://github.com/coruscateor/act_rs |
max_upload_size | |
id | 920951 |
size | 54,330 |
X | Twitch | Youtube | Mastodon | GitHub | GitHub Sponsors
Act.rs is an actor library built to be used with the standard library and Tokio.
An actor is an object that runs in its own thread or task. You usually might communicate with it via a message queue.
Actors have their own state, so you can just send a message indicating what you want done to a particular actor without necessarily having to move everything to do it into its scope.
Act.rs actors have these three essential components:
Create a state struct that contains the state of your actor, this includes an interactor.
This state struct should implement either ActorState or AsyncActorState depending on whether or not the actor is async (Macro generated actors don't have this requirement and the state can implement the required methods directly)
The interactor is exposed via HasInteractor which is required by both ActorState and AsyncActorState.
Finally pass the state into the actor constructor and there you have your actor (see the examples).
Another potential benefit of actors is they can make it reasonably straight-forward to setup pipelines.
You might setup a pipeline to divide work into stages to be performed on different threads.
When setting up your actors with input message queues, you should:
If you follow these guidelines you should have a pleasant time using Act.rs.
Feature | Description |
---|---|
tokio | Enable Tokio based actors and interactors. |
std | Enable std based actors and interactors. |
This project uses a coding style that emphasises the use of white space over keeping the line and column counts as low as possible.
So this:
fn foo()
{
bar();
}
Not this:
fn foo()
{
bar();
}
Licensed under either of:
at your discretion
Please clone the repository and create an issue explaining what feature or features you'd like to add or bug or bugs you'd like to fix and perhaps how you intend to implement these additions or fixes. Try to include details though it doesn't need to be exhaustive and we'll take it from there (dependant on availability).
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.