Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/co-rs/mco-rpc

server/client remote call crate
https://github.com/co-rs/mco-rpc

async mco rpc

Last synced: 3 months ago
JSON representation

server/client remote call crate

Awesome Lists containing this project

README

        

# mco-rpc

mco-rpc

* based on [mco](https://github.com/co-rs/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?

```toml
mco="0.1"
mco-rpc = "0.1"
```

* client

```rust
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

```rust
use mco_rpc::server::Server;
use mco::std::errors::Result;

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