Crates.io | drpc |
lib.rs | drpc |
version | 0.2.3 |
source | src |
created_at | 2022-03-08 08:30:01.951167 |
updated_at | 2023-12-29 09:18:41.349136 |
description | Rust High Performance Async RPC Framework |
homepage | |
repository | https://github.com/darkrpc/drpc |
max_upload_size | |
id | 546121 |
size | 481,515 |
Drpc - Correct, high performance, robust, easy use Remote invocation framework
drpc
[Tag][Length][Value]
T-L-V layout
// Frame layout
// id(u64) + ok(u8) + len(u64) + payload([u8; len])
// request frame layout. payload = method([u8;len])+'\n'(u8)+arg_data([u8;len])
// id(u64) + ok(u8) + len(u64) + payload([u8; len])
// response frame layout.ok=0? payload = error string,ok=1? payload = data
// id(u64) + ok(u8) + len(u64) + payload ([u8; len])
// Header Length layout
// head(8(id)+1(ok)+8(length)=17)
Framework | Platform(1-server-1-client) | ns/operation(lower is better) | Qps(higher is better) |
---|---|---|---|
drpc/tokio | AMD 5950x-16 CPU, 32G mem | 49213 ns/op | 20317 QPS/s |
tarpc/tokio | AMD 5950x-16 CPU, 32G mem | 105644 ns/op | 9465 QPS/s |
tokio = { version = "1", features = ["full"] }
drpc = "0.1"
use drpc::client::Client;
use drpc::codec::BinCodec;
let c = Client::<BinCodec>::dial("127.0.0.1:10000").await.unwrap();
let resp:i32 = c.call("handle", 1).await.unwrap();
println!("resp=>>>>>>>>>>>>>> :{}", resp);
use drpc::server::Server;
use drpc::Result;
use drpc::codec::BinCodec;
async fn handle(req: i32) -> Result<i32> {
Ok(req)
}
let mut s = Server::<BinCodec>::new();
s.register_fn("handle", handle);
s.register_fn("handle2", | arg:i32| async move{
Ok(arg + 1)
});
s.serve("0.0.0.0:10000").await;