Skip to content

co-rs/mco-rpc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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