| Crates.io | norpc |
| lib.rs | norpc |
| version | 0.9.1 |
| created_at | 2021-11-20 05:09:46.932037+00 |
| updated_at | 2022-08-12 01:38:43.19668+00 |
| description | Framework for in-process microservices |
| homepage | |
| repository | https://github.com/akiradeveloper/norpc |
| max_upload_size | |
| id | 484776 |
| size | 9,206 |
#[norpc::service]
trait HelloWorld {
fn hello(s: String) -> String;
}
struct HelloWorldApp;
#[async_trait::async_trait]
impl HelloWorld for HelloWorldApp {
async fn hello(&self, s: String) -> String {
format!("Hello, {}", s)
}
}
let rep = tokio_test::block_on(async {
use norpc::runtime::*;
let app = HelloWorldApp;
let svc = HelloWorldService::new(app);
let (chan, server) = ServerBuilder::new(svc).build();
tokio::spawn(server.serve(TokioExecutor));
let mut cli = HelloWorldClient::new(chan);
cli.hello("World".to_owned()).await
});
assert_eq!(rep, "Hello, World");
norpc = { version = "0.9", features = ["runtime", "tokio-executor"] }
Send types.norpc is about 2x faster than google/tarpc.
To compare the pure overhead, he benchmark program launches a no-op server and send requests from the client.
noop request/1 time: [8.9181 us 8.9571 us 9.0167 us]
noop request (tarpc)/1 time: [15.476 us 15.514 us 15.554 us]
Akira Hayakawa (@akiradeveloper)