-
-
Save chinnurtb/10098326 to your computer and use it in GitHub Desktop.
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
BOOST_AUTO_TEST_CASE( test_service_zk_disconnect ) | |
{ | |
cerr << "Starting multiple service zk disconnect " << endl; | |
auto proxies = std::make_shared<ServiceProxies>(); | |
// proxies->useZookeeper(ML::format("localhost:%d", zookeeper.getPort())); | |
proxies->useZookeeper(ML::format("localhost:2181")); | |
ZmqMultipleNamedClientBusProxy connection(proxies->zmqContext); | |
connection.init(proxies->config, "client1"); | |
connection.connectHandler = [&] (const std::string & svc) | |
{ | |
cerr << "connected to " << svc << endl; | |
}; | |
connection.disconnectHandler = [&] (const std::string & svc) | |
{ | |
cerr << "disconnected from " << svc << endl; | |
}; | |
connection.start(); | |
BOOST_CHECK_EQUAL(connection.connectionCount(), 0); | |
connection.connectAllServiceProviders("echo", "echo"); | |
BOOST_CHECK_EQUAL(connection.connectionCount(), 0); | |
std::vector<unique_ptr<EchoService> > services; | |
auto startService = [&] () | |
{ | |
services.emplace_back(new EchoService(proxies, "echo" + to_string(services.size()))); | |
EchoService & service = *services.back(); | |
service.init(); | |
auto addr = service.bindTcp(); | |
cerr << "echo service is listening on " << addr << endl; | |
service.start(); | |
}; | |
startService(); | |
// proxies->config->dump(cerr); | |
std::cerr <<"going to sleep for 1000 seconds " << std::endl; | |
ML::sleep(1000); | |
cerr << "shutting down" << endl; | |
connection.shutdown(); | |
for (unsigned i = 0; i < services.size(); ++i) | |
services[i]->shutdown(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment