![]() |
RTBKit
0.9
Open-source framework to create real-time ad bidding systems.
|
00001 00009 #pragma once 00010 00011 #include "service_base.h" 00012 00013 #include <boost/program_options/options_description.hpp> 00014 #include <vector> 00015 #include <string> 00016 #include <sys/utsname.h> 00017 00018 00019 namespace Datacratic { 00020 00021 /******************************************************************************/ 00022 /* SERVICE PROXIES ARGUMENTS */ 00023 /******************************************************************************/ 00024 00026 struct ServiceProxyArguments 00027 { 00028 boost::program_options::options_description 00029 makeProgramOptions(const std::string& title = "General Options") 00030 { 00031 using namespace boost::program_options; 00032 00033 options_description options(title); 00034 options.add_options() 00035 ("bootstrap,B", value(&bootstrapPath), "path to bootstrap.json") 00036 00037 ("zookeeper-uri,Z", value(&zookeeperUri), "URI of zookeeper to use") 00038 ("carbon-connection,c", value<std::vector<std::string> >(&carbonUris), 00039 "URI of connection to carbon daemon") 00040 00041 ("installation,I", value(&installation), 00042 "Name of the installation that is running") 00043 ("node-name,N", value(&nodeName), "Name of the node we're running"); 00044 00045 return options; 00046 } 00047 00048 std::shared_ptr<ServiceProxies> makeServiceProxies() 00049 { 00050 auto services = std::make_shared<ServiceProxies>(); 00051 00052 if (!bootstrapPath.empty()) 00053 services->bootstrap(bootstrapPath); 00054 00055 if (!zookeeperUri.empty()) { 00056 ExcCheck(!installation.empty(), "installation is required"); 00057 services->useZookeeper(zookeeperUri, installation); 00058 } 00059 00060 if (!carbonUris.empty()) { 00061 ExcCheck(!installation.empty(), "installation is required"); 00062 00063 if (nodeName.empty()) { 00064 struct utsname s; 00065 int ret = uname(&s); 00066 ExcCheckErrno(!ret, "Unable to call uname"); 00067 00068 nodeName = std::string(s.nodename); 00069 } 00070 00071 services->logToCarbon(carbonUris, installation + "." + nodeName); 00072 } 00073 00074 return services; 00075 } 00076 00077 std::string bootstrapPath; 00078 00079 std::string zookeeperUri; 00080 std::vector<std::string> carbonUris; 00081 00082 std::string installation; 00083 std::string nodeName; 00084 }; 00085 00086 } // namespace Datacratic