![]() |
RTBKit
0.9
Open-source framework to create real-time ad bidding systems.
|
00001 /* named_endpoint.h -*- C++ -*- 00002 Jeremy Barnes, 14 September 2012 00003 Copyright (c) 2012 Datacratic Inc. All rights reserved. 00004 00005 */ 00006 00007 #ifndef __service__named_endpoint_h__ 00008 #define __service__named_endpoint_h__ 00009 00010 #include "service_base.h" 00011 #include "jml/utils/exc_assert.h" 00012 #include <net/if.h> 00013 #include <arpa/inet.h> 00014 #include <set> 00015 00016 00017 namespace Datacratic { 00018 00019 00020 /*****************************************************************************/ 00021 /* NAMED ENDPOINT */ 00022 /*****************************************************************************/ 00023 00032 struct NamedEndpoint { 00033 00035 void init(std::shared_ptr<ConfigurationService> config, 00036 const std::string & endpointName); 00037 00039 void publishAddress(const std::string & address, 00040 const Json::Value & addressConfig); 00041 00045 void activate(); 00046 00047 struct Interface { 00048 int family; 00049 uint64_t flags; 00050 00052 uint32_t up:1; 00053 uint32_t running:1; 00054 uint32_t loopback:1; 00055 uint32_t pointtopoint:1; 00056 uint32_t noarp:1; 00057 00058 std::string name; 00059 std::string addr; 00060 std::string netmask; 00061 std::string broadcast; 00062 std::string hostScope; 00063 }; 00064 00066 static std::string addrToString(const sockaddr * addr); 00067 00069 static std::string addrToIp(const std::string & addr); 00070 00072 static std::vector<Interface> 00073 getInterfaces(const std::set<int> & families = std::set<int>({ AF_INET }), 00074 int flagsRequired = IFF_UP, 00075 int flagsExcluded = 0); 00076 00077 std::vector<std::string> getPublishedUris() const; 00078 00079 private: 00081 std::shared_ptr<ConfigurationService> config; 00082 std::string endpointName; 00083 00084 std::vector<std::string> publishedUris; 00085 }; 00086 00087 00088 00089 } // namespace Datacratic 00090 00091 #endif /* __service__named_endpoint_h__ */