co-rs / mco-rpc

server/client remote call crate

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

server/client remote call crate

License:Apache License 2.0


Languages

Language:Rust 100.0%