Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ns;
- service Hoge {
- rpc Foo(FooReq) returns (FooRep) {}
- rpc Bar(BarReq) returns (BarRep) {}
- }
- |
- V
- #### client
- io = qrpc::Client()
- rpc = ns::HogeService::Client(io, host, port);
- //rpc2 = ns2::FugaService::Client(io, host, port); compose multiple rpc on single connection, if host and port same. otherwise new connection created
- //or funny idea with variable template argument...
- //qrpc::Fuse<ns::HogeService, ns2::FugaService>::Client(io, host, port);
- io.PollBackground();
- or
- while (true) {
- io.Poll();
- }
- rpc.Call(BarReq *req, [context...](BarRep *rep, Error *error) {
- //run as background poller thread
- //or
- //thread which calls rpc.Poll
- });
- Future<BarRep> f = rpc.CallAsync(BarReq *req);
- unique_ptr<BarRep> rep; //or unique_ptr<IMessage>
- unique_ptr<Error> err;
- rep.get(rep, err); //may block
- vector<FutureBase> af;
- unique_ptr<IMessage> msg;
- for (int i = 0; i < concurrency; i++) {
- af.push_back(rpc.CallAsync(FooReq *req);
- }
- rpc.WaitAll(af);
- for (auto &fb : af) {
- fb.get(msg, err);
- }
- FutureBase fb = rpc.WaitOne(af);
- fb.get(msg, err);
- #### server
- io = qrpc::Server(cert, key);
- sv = ns::HogeService::Server<Handler>(io, host, port);
- //sv2 = ns2::FugaService::Server<Handler2>(io, host, port); compose multiple rpc on single accepted connection, if host and port is same.
- //or funny idea with variable template argument...
- //qrpc::Fuse<ns::HogeService, ns2::FugaService>::Server<Handler>(io, host, port);
- io.Serve(number_of_thread);
Add Comment
Please, Sign In to add comment