Skip to content
/ kameo Public

Fault-tolerant Async Actors Built on Tokio

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

tqwewe/kameo

Repository files navigation

Kameo 🎬

Crates.io Version Crates.io Total Downloads Crates.io License GitHub Repo stars

Kameo banner image

What is Kameo

Kameo is a Rust library to build fault-tolerant async actors in Rust.

Feature highlights

  • Async Rust: tokio task per actor
  • Supervision: link actors together
  • Remote messaging: message actors between nodes
  • Panic safe: gracefully handled panics
  • Back pressure: supports bounded & unbounded mpsc messaging

Reasons to use Kameo

  • Distributed Systems: Use Kameo when building distributed systems that require seamless communication between actors across multiple nodes, leveraging its built-in support for remote actor messaging and registration.
  • Concurrency with Simplicity: Choose Kameo for projects that need efficient concurrency management without the complexity of manually handling threads, as it provides a straightforward API for spawning and managing actors with Tokio.
  • Scalability: Kameo is ideal for applications that need to scale horizontally, thanks to its actor pools and remote actor support, making it easy to scale workloads across multiple machines.

Getting Started

Add kameo as a dependency to your crate.

cargo add kameo

Define an actor and some messages.

use kameo::Actor;
use kameo::message::{Context, Message};
use kameo::request::MessageSend;

#[derive(Actor)]
struct Counter {
    count: i64,
}

struct Inc { amount: u32 }

impl Message<Inc> for Counter {
    type Reply = i64;

    async fn handle(&mut self, msg: Counter, _ctx: Context<'_, Self, Self::Reply>) -> Self::Reply {
        self.count += msg.0 as i64;
        self.count
    }
}

Spawn and message the actor.

let actor_ref = kameo::spawn(Counter { count: 0 });
let count = actor_ref.ask(Inc { amount: 42 }).send().await?;
assert_eq!(count, 42);

Benchmarks

13x higher throughput when compared with Actix

benchmark

Above shows a basic benchmark for sending a message to an actor in Kameo and Actix. Always benchmark for yourself.

Contributing

Contributions are welcome! Feel free to submit pull requests, create issues, or suggest improvements.

License

kameo is dual-licensed under either:

at your option.