Kameo 🧚🏻
Fault-tolerant Async Actors Built on Tokio
- Async: Built on tokio, actors run asyncronously in their own isolated spawned tasks.
- Supervision: Link actors, creating dependencies through child/parent/sibbling relationships.
- MPSC Unbounded Channels: Uses mpsc channels for messaging between actors.
- Concurrent Queries: Support concurrent processing of queries when mutable state isn't necessary.
- Panic Safe: Catches panics internally, allowing actors to be restarted.
Installing
Install using cargo add
:
or adding to your dependencies manually:
[]
= "*"
Defining an Actor without Macros
use Actor;
use ;
// Define the actor state
// Define messages
Defining an Actor with Macros
use ;
// Define the actor state
// Define messages
// Derive Actor
// Messages
Spawning an Actor & Messaging
let counter_ref = spawn;
let count = counter_ref.send.await?;
println!;
Benchmarks
13x higher throughput when compared with Actix
Above shows a basic benchmark for sending a message to an actor in Kameo and Actix. Always benchmark for yourself.
Sending a message to an actor
Benchmark | Time |
---|---|
Kameo Unsync Message | 432.26 ns |
Kameo Sync Message | 503.89 ns |
Kameo Query | 1.3000 µs |
Actix Message | 5.7545 µs |
Processing fibonachi sequence in an actor up to 20
Benchmark | Time |
---|---|
Kameo Unsync Message | 18.229 µs |
Kameo Sync Message | 18.501 µs |
Kameo Query | 19.257 µs |
Actix Message | 27.442 µs |
Contributing
Contributions are welcome! Feel free to submit pull requests, create issues, or suggest improvements.
License
kameo
is dual-licensed under either:
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
at your option.