15 #ifndef QC_SERVICEDISCOVERY_H 16 #define QC_SERVICEDISCOVERY_H 19 #include <curl/curl.h> 23 #include <boost/asio/ip/host_name.hpp> 41 ServiceDiscovery(
const std::string& url,
const std::string& name,
const std::string&
id,
const std::string& healthEndpoint = GetDefaultUrl());
48 void _register(
const std::string& objects);
53 static inline std::string GetDefaultUrl()
60 return boost::asio::ip::host_name() +
":" + std::to_string(port);
67 static void deleteCurl(CURL* curl);
70 std::unique_ptr<CURL, decltype(&ServiceDiscovery::deleteCurl)> curlHandle;
72 const std::string mConsulUrl;
73 const std::string mName;
74 const std::string mId;
75 std::string mHealthEndpoint;
76 std::thread mHealthThread;
77 std::atomic<bool> mThreadRunning;
83 void send(
const std::string& path, std::string&& request);
86 void runHealthServer(
unsigned int port);
90 #endif // QC_SERVICEDISCOVERY_H Information service for QC.
Definition: ServiceDiscovery.h:32
void deregister()
Deregisters service.
Definition: ServiceDiscovery.cxx:97
static std::string GetDefaultUrl(size_t port)
Definition: ServiceDiscovery.h:58
~ServiceDiscovery()
Stops the health thread and deregisteres from Consul health checks.
Definition: ServiceDiscovery.cxx:39
ServiceDiscovery(const std::string &url, const std::string &name, const std::string &id, const std::string &healthEndpoint=GetDefaultUrl())
Definition: ServiceDiscovery.cxx:27
static constexpr size_t DefaultHealthPort
Health check default port.
Definition: ServiceDiscovery.h:63
These methods can be used to build a complex processing topology. It spawns 3 separate dummy processi...
Definition: Activity.h:19
void _register(const std::string &objects)
Definition: ServiceDiscovery.cxx:65