RTC Toolkit 5.0.0
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>
39 ListComponents(const std::string& service_type = COMPONENT_TYPE) override;
40 ServiceEndpoint Get(const std::string& comp_name,
41 const std::string& service_name,
42 const std::string& service_type,
43 const bool health_check) override;
47 bool IsComponent(const ppconsul::ServiceInfo& service_info,
48 const std::string& service_type = COMPONENT_TYPE);
49 ppconsul::ServiceInfo GetComponentDefinedInConsul(const std::string& comp_name,
50 const std::string& service_name,
51 const std::string& service_type);
52
53private:
54 static const std::string CONSUL_COMMON_SERVICE;
55 static const std::string CONSUL_NAME_KEY;
56 static const std::string CONSUL_TYPE_KEY;
57 static const std::string CONSUL_ENDPOINT_TYPE_KEY;
58 static const std::string CONSUL_ENDPOINT_URI_KEY;
59 static const std::string RUNTIME_REPO_ENDPOINT;
60 static const std::string PERSISTENT_REPO_ENDPOINT;
61 static const std::string OLDB_ENDPOINT;
62 std::unique_ptr<ppconsul::Consul> m_consul_client;
63 std::unique_ptr<ppconsul::agent::Agent> m_consul_agent;
64 std::map<std::string, ppconsul::ServiceInfo> services;
65 elt::mal::Uri sde;
66};
67
68} // namespace rtctk::componentFramework
69
70#endif // CONSULSERVICEREGISTRYADAPTER_HPP
Class that implements a very basic service discovery mechanism using Consul.
Definition consulServiceRegistryAdapter.hpp:33
std::vector< std::string > ListComponents(const std::string &service_type=COMPONENT_TYPE) override
Get known components.
Definition consulServiceRegistryAdapter.cpp:168
ServiceEndpoint GetPersistentRepoEndpoint() override
Get the Persistent Repository Endpoint from the service registry.
Definition consulServiceRegistryAdapter.cpp:226
bool IsComponent(const ppconsul::ServiceInfo &service_info, const std::string &service_type=COMPONENT_TYPE)
Definition consulServiceRegistryAdapter.cpp:230
ConsulServiceRegistryAdapter(const elt::mal::Uri &endpoint)
Definition consulServiceRegistryAdapter.cpp:44
ppconsul::ServiceInfo GetComponentDefinedInConsul(const std::string &comp_name, const std::string &service_name, const std::string &service_type)
Definition consulServiceRegistryAdapter.cpp:244
static const std::string SUPPORTED_URI_SCHEME
Definition consulServiceRegistryAdapter.hpp:35
ServiceEndpoint GetRuntimeRepoEndpoint() override
Get the Runtime Repository Endpoint from the service registry.
Definition consulServiceRegistryAdapter.cpp:215
ServiceEndpoint GetOldbEndpoint() override
Get the Oldb Endpoint from the service registry.
Definition consulServiceRegistryAdapter.cpp:210
ServiceEndpoint Get(const std::string &comp_name, const std::string &service_name, const std::string &service_type, const bool health_check) override
Get endpoint of specific service of a specific component.
Definition consulServiceRegistryAdapter.cpp:59
Class that implements a service registry to be used by the service discovery.
Definition serviceRegistryIf.hpp:31
static const std::string COMPONENT_TYPE
the string for component type (default)
Definition serviceRegistryIf.hpp:60
elt::mal::Uri ServiceEndpoint
Definition serviceRegistryIf.hpp:43
Header file for DataPointPath.
Definition commandReplier.cpp:22
elt::mal::future< std::string > InjectReqRepEvent(StateMachineEngine &engine)
Definition malEventInjector.hpp:23
Class that implements the service registry interface.