A rust library for communicating with Apache Pekko JVM actors. Allows rust applications to send messages to and receive replies from Pekko actors.
https://docs.rs/rukko/latest/rukko/
Add Rukko to your Cargo.toml:
[dependencies]
rukko = "0.1.0"
tokio = "1.47.0"use rukko::{ActorSystem, Message};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create an actor system
let system = ActorSystem::new("RustClient").await?;
// Connect to a remote Pekko actor
let remote_actor = system
.actor_selection("pekko://MySystem@127.0.0.1:25552/user/myActor")
.await?;
// Send a fire-and-forget message (tell pattern)
remote_actor.tell(Message::text("One-way message"));
// Send a message and wait for its response (ask pattern)
let response = remote_actor
.ask(Message::text("Hello from Rust!"))
.await?;
println!("Response: {:?}", response);
system.shutdown().await;
Ok(())
}If your actor path is wrong or something else makes an ask hang until timeout, you will be waiting for 30 seconds for your error. If you can't wait half a minute, set your own timeout like this:
use tokio::time::Duration;
...
// Default timeout (30 seconds)
let response = actor.ask(message).await?;
// Custom timeout
let response = actor
.ask_with_timeout(important_question, Duration::from_secs(1))
.await?;This project is licensed under the MIT License.
Contributions are welcome! Please feel free to submit issues and PRs.