Closed
Description
Problem statement
Currently, Openraft does not use Protocol Buffers (proto) messages; instead, it passes Rust structs for internal communication. This necessitates that anyone writing a gRPC network layer must rewrite proto files like the example found in databend's source code
Solution
Openraft can have proto file and generated pb file in the repo along with From and Into trait converters that people can use in writing thier network component
Example from kv-memstore:
Instead of
#[post("/add-learner")]
pub async fn add_learner(app: Data<App>, req: Json<(NodeId, String)>) -> actix_web::Result<impl Responder> {
let node_id = req.0 .0;
let node = BasicNode { addr: req.0 .1.clone() };
let res = app.raft.add_learner(node_id, node, true).await;
Ok(Json(res))
}
it will look something like this
#[post("/add-learner")]
pub async fn add_learner(app: Data<App>, req: add_learner_request) -> add_learner_response {
let node_id = req.node_id;
let node = BasicNode { addr: req.addr.clone() };
let res = app.raft.add_learner(node_id, node, true).await;
Ok(res.into())
Scope and tools:
The plan is to utilize prost
and tonic
for handling proto files and generating Rust code. As I delve deeper into the codebase, I will update this section with more details.
Open questions:
- Should protobuf generator be pluggable? Ex:
rust-protobuf
instead ofprost
Metadata
Metadata
Assignees
Labels
No labels