20 releases (8 breaking)

0.9.1 Aug 12, 2022
0.8.1 Aug 5, 2022
0.8.0 Apr 21, 2022
0.7.0 Mar 3, 2022
0.5.2 Nov 28, 2021

#150 in Concurrency

Download history 13/week @ 2022-10-14 15/week @ 2022-10-21 5/week @ 2022-10-28 11/week @ 2022-11-04 18/week @ 2022-11-11 12/week @ 2022-11-18 22/week @ 2022-11-25 10/week @ 2022-12-02 25/week @ 2022-12-09 14/week @ 2022-12-16 16/week @ 2022-12-23 20/week @ 2022-12-30 40/week @ 2023-01-06 10/week @ 2023-01-13 18/week @ 2023-01-20 13/week @ 2023-01-27

93 downloads per month

MIT license

9KB
190 lines

norpc = not remote procedure call

Crates.io documentation CI MIT licensed Tokei

Documentation

Example

#[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");

Usage

norpc = { version = "0.9", features = ["runtime", "tokio-executor"] }
  • runtime: Use norpc runtime
  • tokio-executor: Use tokio as async runtime.
  • async-std-executor: Use async-std as async runtime.

Features

  • Support in-process microservices through async channel.
  • Async runtime agnostic.
  • Support non-Send types.
  • Support request cancellation from client.

Performance

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]

Author

Akira Hayakawa (@akiradeveloper)

Dependencies

~1.3–7MB
~113K SLoC