Skip to content

Instantly share code, notes, and snippets.

@LEW21
Created August 23, 2013 11:44
Show Gist options
  • Save LEW21/6318434 to your computer and use it in GitHub Desktop.
Save LEW21/6318434 to your computer and use it in GitHub Desktop.
#include <string>
#include <iostream>
#include <boost/program_options/parsers.hpp>
#include <boost/program_options/variables_map.hpp>
#include "soa/service/service_utils.h"
using namespace std;
using namespace Datacratic;
auto readConfig(int argc, char** argv) -> ServiceProxyArguments
{
auto config = ServiceProxyArguments();
using namespace boost::program_options;
auto all_opt = options_description();
all_opt.add(config.makeProgramOptions());
all_opt.add_options()
("help,h", "print this message");
auto vm = variables_map();
store(command_line_parser(argc, argv)
.options(all_opt)
//.positional(p)
.run(),
vm);
notify(vm);
if (vm.count("help"))
{
cerr << all_opt << endl;
exit(1);
}
return config;
}
auto main(int argc, char* argv[]) -> int
{
auto config = readConfig(argc, argv);
auto services = config.makeServiceProxies();
auto endpointName = string{"serviceClass/rtbPostAuctionService"};
auto w = ConfigurationService::Watch{};
w.init([&](string path, ConfigurationService::ChangeType changeType){
cout << "CHANGE: " << path << " " << int(changeType) << endl;
services->config->getChildren(endpointName, w);
});
services->config->getChildren(endpointName, w);
while (true) this_thread::sleep_for(chrono::seconds(10));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment