uActor
Overview
The fastest and most modular actor system that doesn't force you to pay for what you don't need.
Quick Start
Define messages with #[derive(Message)], implement handlers with #[uactor::actor] / #[uactor::handler]:
;
;
generate_actor_ref!;
See the full runnable version: Example: Macro handlers
Examples
Examples can be found here.
Features
- Simplified creation of tokio-based topic-oriented actors
- Minimum boilerplate code
- Support for different tokio channels including
watch,broadcast,oneshot,mpsc - Each actor is able to listen up to 30 channels
- Single channel routing with
generate_actor_ref!Example: Single channel - Tick support (actor called each n seconds/millis/etc) Example: Interval
- Dependency Injection on pre-start stage to solve cross-references ("Actor#1" needs "Actor#2" and vice versa) Example: Dependency injection
- Integration with tokio/tracing, including tracing of actor lifecycle, messages, and handlers
- Multiple message sources (channels) per actor Example: Multi channel
- Shared state for actors Example: Shared state
Derive and macro support
-
#[derive(Message)]-- implement theMessagetrait without boilerplate. Also available asmessage_impl!(MsgA, MsgB)for multiple types at once. -
#[uactor::actor]+#[uactor::handler]-- define message handlers as simple methods instead of manualimpl Handler<M>for each message type.Handler parameters:
- First parameter (after optional
&mut self/&self) -- the message; its type determinesHandler<Type> ctx-- maps to&mut Self::Contextstate-- maps to&Self::State- Any other parameter -- accessed as a field from the
Injectstruct by name
- First parameter (after optional
-
generate_actor_ref!with aliased variants -- map primitive or external types to named enum variants:generate_actor_ref!; // Generates: enum MyActorMsg { PingMsg(PingMsg), NextId(i32), Label(String) }
Actor lifecycle

Other projects
- Actix
- Ractor
- Tokactor
- tiny-tokio-actor
License
This project is licensed under the MIT license.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in uActor by you, shall be licensed as MIT, without any additional terms or conditions.