mco-rpc

Crates.iomco-rpc
lib.rsmco-rpc
version0.1.8
sourcesrc
created_at2022-02-27 18:56:20.039372
updated_at2023-12-08 11:37:01.833218
descriptionRPC framework for Rust based on mco.
homepagehttps://github.com/co-rs/mco
repositoryhttps://github.com/co-rs/mco-rpc
max_upload_size
id540472
size50,229
zxj (zhuxiujia)

documentation

https://docs.rs/mco-rpc

README

mco-rpc

mco-rpc

  • based on mco, this is green-thread、coroutines crates
  • based T-L-V.for example: [Tag][Length][Value]
  • support json/bincode
  • support load balance(Round/Random/Hash/MinConnect)

how to use?

mco="0.1"
mco-rpc = "0.1"
  • client
use mco_rpc::client::Client;
let c = Client::dial("127.0.0.1:10000").unwrap();
let resp:i32 = c.call("handle", 1).unwrap();
println!("resp=>>>>>>>>>>>>>> :{}", resp);
  • server
use mco_rpc::server::Server;
use mco::std::errors::Result;

fn handle(req: i32) -> Result<i32> {
    Ok(req)
}
let mut s = Server::default ();
s.register_fn("handle", handle);
s.register_fn("handle_fn2", |arg:i32| -> Result<i32>{
Ok(1)
});
s.serve("0.0.0.0:10000");
Commit count: 122

cargo fmt