RTC Toolkit 4.0.1
Loading...
Searching...
No Matches
consulServiceRegistryAdapter.hpp
Go to the documentation of this file.
1
13#ifndef CONSULSERVICEREGISTRYADAPTER_HPP
14#define CONSULSERVICEREGISTRYADAPTER_HPP
15
16#include <memory>
17#include <ppconsul/agent.h>
18#include <string>
19
20#include <mal/Cii.hpp>
21
24
26
34public:
35 inline static const std::string SUPPORTED_URI_SCHEME = "consul";
36
37 ConsulServiceRegistryAdapter(const elt::mal::Uri& endpoint);
38 std::vector<std::string> ListComponents() override;
39 ServiceEndpoint Get(const std::string& comp_name,
40 const std::string& service_name,
41 const bool health_check) override;
45 bool IsComponent(const ppconsul::ServiceInfo& service_info);
46 ppconsul::ServiceInfo
47 GetComponentDefinedInConsul(const std::string& comp_name, const std::string& service_name);
48
49private:
50 static const std::string CONSUL_COMMON_SERVICE;
51 static const std::string CONSUL_COMPONENT_NAME_KEY;
52 static const std::string CONSUL_ENDPOINT_TYPE_KEY;
53 static const std::string CONSUL_ENDPOINT_URI_KEY;
54 static const std::string RUNTIME_REPO_ENDPOINT;
55 static const std::string PERSISTENT_REPO_ENDPOINT;
56 static const std::string OLDB_ENDPOINT;
57 std::unique_ptr<ppconsul::Consul> m_consul_client;
58 std::unique_ptr<ppconsul::agent::Agent> m_consul_agent;
59 std::map<std::string, ppconsul::ServiceInfo> services;
60 elt::mal::Uri sde;
61};
62
63} // namespace rtctk::componentFramework
64
65#endif // CONSULSERVICEREGISTRYADAPTER_HPP
Class that implements a very basic service discovery mechanism using Consul.
Definition: consulServiceRegistryAdapter.hpp:33
ServiceEndpoint GetPersistentRepoEndpoint() override
Get the Persistent Repository Endpoint from the service registry.
Definition: consulServiceRegistryAdapter.cpp:208
std::vector< std::string > ListComponents() override
Get known components.
Definition: consulServiceRegistryAdapter.cpp:161
static const std::string SUPPORTED_URI_SCHEME
Definition: consulServiceRegistryAdapter.hpp:35
bool IsComponent(const ppconsul::ServiceInfo &service_info)
Definition: consulServiceRegistryAdapter.cpp:212
ServiceEndpoint GetRuntimeRepoEndpoint() override
Get the Runtime Repository Endpoint from the service registry.
Definition: consulServiceRegistryAdapter.cpp:203
ServiceEndpoint GetOldbEndpoint() override
Get the Oldb Endpoint from the service registry.
Definition: consulServiceRegistryAdapter.cpp:198
ServiceEndpoint Get(const std::string &comp_name, const std::string &service_name, const bool health_check) override
Get endpoint of specific service of a specific component.
Definition: consulServiceRegistryAdapter.cpp:58
ppconsul::ServiceInfo GetComponentDefinedInConsul(const std::string &comp_name, const std::string &service_name)
Definition: consulServiceRegistryAdapter.cpp:224
Class that implements a service registry to be used by the service discovery.
Definition: serviceRegistryIf.hpp:31
elt::mal::Uri ServiceEndpoint
Definition: serviceRegistryIf.hpp:43
Header file for DataPointPath.
Definition: commandReplier.cpp:22
Class that implements the service registry interface.