Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add FAQ to book #59

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion docs.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"name": "Kameo",
"description": "Fault-tolerant Async Actors Built on Tokio",
"description": "Distributed, Fault-tolerant Async Actors Powered by Tokio",
"socialPreview": "https://repository-images.githubusercontent.com/779318723/b1ce92be-760d-427b-b3a6-ffca8cbc2e6a",
"logo": {
"light": "https://github.com/tqwewe/kameo/raw/refs/heads/main/docs/farron.png",
"dark": "https://github.com/tqwewe/kameo/raw/refs/heads/main/docs/farron.png"
},
"scripts": {
"googleAnalytics": "G-FES40CNKHX"
},
Expand Down Expand Up @@ -85,6 +89,16 @@
"icon": "envelope-open-text"
}
]
},
{
"group": "Additional Resources",
"pages": [
{
"title": "FAQ",
"href": "/faq",
"icon": "question-circle"
}
]
}
]
}
63 changes: 63 additions & 0 deletions docs/faq.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
---
title: Frequently Asked Questions (FAQ)
---

## How does Kameo handle communication over a network?

Kameo uses [libp2p](https://libp2p.io) for networking, with Kademlia Distributed Hash Table (DHT) under the hood for actor registration and lookup. This allows actors to communicate across nodes without needing a predefined schema, and messages are routed using multiaddresses, supporting a variety of protocols such as TCP/IP and QUIC.

---

## How do I query an actor's state?

You can query an actor’s state by sending a message using the `ask` pattern, which allows you to request a response without modifying the actor's state.

```rust
let result = actor_ref.ask(QueryState).send().await?;
println!("Actor state: {:?}", result);
```

However, it’s often better to design actors in a way where they notify each other of state changes. In this push model, actors send updates when their state changes, reducing the need for constant querying and keeping interactions more efficient and decoupled.

---

## How is Kameo different from gRPC?

Unlike gRPC, which requires predefined schemas and often involves significant boilerplate, Kameo allows dynamic communication with actors across nodes without the need for code generation or schema management. Actors communicate via `RemoteActorRef`, and messages are passed just like with local actors, making it more flexible and less rigid than gRPC.

---

## Why does Kameo use async for actors?

Kameo's async nature allows multiple actors to run on a single thread using Tokio's runtime, which is highly efficient for handling IO-bound tasks. While many actors may be CPU-bound, async ensures that non-blocking tasks, such as network operations, can proceed without stalling other actors.

---

## Can Kameo be used for distributed systems?

Yes, Kameo is built for distributed systems. Using libp2p and Kademlia DHT, actors can be registered and discovered across nodes, and they can communicate as if they were local. This makes Kameo ideal for distributed microservices or systems where actors are spread across different machines.

---

## Can Kameo be used for building parallel applications?

Yes. Kameo runs on the Tokio runtime, which can be configured with the `rt-multi-thread` feature to utilize multiple cores. This allows actors to be distributed across all CPU cores, handling parallel workloads efficiently.

---

## Is Kameo production-ready?

Kameo is still relatively new and under active development. It is being tested in real-world projects, but the API has seen many iterations. While Kameo is not yet widely adopted in production, it is rapidly maturing to meet production-level standards.

---

## Why are messages processed sequentially in an actor?

Messages are processed sequentially within each actor to maintain consistency and correctness. This ensures that state changes happen in a well-defined order, which is crucial in applications where message processing order matters.

---

## How does Kameo compare to other Rust actor libraries like Actix or Ractor?

- **Actix**: Kameo offers a simpler API with less boilerplate, especially for async use cases. Actix has seen many changes in its runtime over time, while Kameo is built directly on Tokio for more native async support.
- **Ractor**: Kameo differs in several ways. Messages in Kameo are implemented as separate structs with their own `Message` trait, while Ractor uses a single enum for messages. Additionally, in Kameo, the actor itself is the state, while Ractor separates the state and actor.
Binary file added docs/farron.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.