forked from daniel-j-h/DistributedSearch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RecursiveSearch.cc
29 lines (20 loc) · 864 Bytes
/
RecursiveSearch.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <iostream>
#include "Common.h"
#include "Service.h"
int main(int argc, char** argv) try {
Common::init();
const auto args = Common::args(argc, argv);
const auto bind = args.size() >= 2 ? args[1] : "tcp://*:9996";
const auto conn = args.size() == 3 ? args[2] : "tcp://localhost:9995";
// requester represents attaching services
Service::Requester requester{bind, 500}; // lower timeout, since we have to respond, too
// responder represents service we send the results to
Service::Responder responder{conn};
// recursively query attached services; pass request on
const auto recursiveRequestHandler = [&requester](const Common::Request& req) -> Common::Response {
return requester.query(req);
};
responder.onRequest(recursiveRequestHandler);
} catch (const std::exception& e) {
std::cerr << e.what() << std::endl;
}