Rust RPC library built on top of [fibers] crate.
See [doc/].
Simple echo RPC server: ```rust use bytecodec::bytes::{BytesEncoder, RemainingBytesDecoder}; use fibersrpc::{Call, ProcedureId}; use fibersrpc::client::ClientServiceBuilder; use fibers_rpc::server::{HandleCall, Reply, ServerBuilder}; use futures::Future;
// RPC definition struct EchoRpc; impl Call for EchoRpc { const ID: ProcedureId = ProcedureId(0); const NAME: &'static str = "echo";
type Req = Vec<u8>;
type ReqEncoder = BytesEncoder<Vec<u8>>;
type ReqDecoder = RemainingBytesDecoder;
type Res = Vec<u8>;
type ResEncoder = BytesEncoder<Vec<u8>>;
type ResDecoder = RemainingBytesDecoder;
}
// RPC server
struct EchoHandler;
impl HandleCall
// RPC client let service = ClientServiceBuilder::new().finish(fibersglobal::handle()); let servicehandle = service.handle(); fibersglobal::spawn(service.maperr(|e| panic!("{}", e)));
let request = Vec::from(&b"hello"[..]); let response = EchoRpc::client(&servicehandle).call(serveraddr, request.clone()); let response = fibersglobal::execute(response)?; asserteq!(response, request); ```
Informal benchmark result (v0.2.1):
```console $ uname -a Linux DESKTOP 4.4.0-43-Microsoft #1-Microsoft Wed Dec 31 14:42:53 PST 2014 x8664 x8664 x86_64 GNU/Linux
$ lscpu | grep 'Model name:' Model name: Intel(R) Core(TM) i7-7660U CPU @ 2.50GHz
// Runs the example echo server in a shell. $ cargo run --example echo --release -- server
// Executes a benchmark command in another shell. $ echo "hello" | cargo run --example echo --release -- bench -c 1024 -n 1000000
```