Last active
November 21, 2017 17:57
-
-
Save umegaya/d2818bfba217f067ebb569d899a1c46e to your computer and use it in GitHub Desktop.
qrpc code generation image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment