Service Discovery

Since there does not exist a ELT control software wide solution for service discovery yet, the RTC Toolkit introduces a very basic service discovery mechanism that allows lookup and retrieval of service endpoints by name. It uses a ServiceRegistryAdapter to retrieve the service information. Currently there is only an adapter for a file-based service discovery.

The discovery mechanism makes use of the Client-Side Discovery Pattern where a client retrieves endpoints of required services by querying a central service registry (a database).

The service registry is implemented using the same mechanisms as the file based Runtime Configuration Repository and its storage back-end is a single, shared YAML file.

Service endpoints are represented in URI format and retrieved using the elt::mal::Uri class, which is aliased as ServiceEndpoint.

Supported Service Queries

Currently the following service queries are supported:

Service Query

Format

Description

GetPersistentRepoEndpoint

elt::mal::Uri

Service endpoint of the Persistent Configuration Repository.

GetRuntimeRepoEndpoint

elt::mal::Uri

Service endpoint of the Runtime Configuration Repository.

GetOldbEndpoint

elt::mal::Uri

Service endpoint of the Online Database.

GetReqRepEndpoint

elt::mal::Uri

CII MAL request/reply endpoint of an RTC Component.

GetPubSubEndpoint

elt::mal::Uri

CII MAL publish/subscribe endpoint of an RTC Component.

For GetPersistentRepoEndpoint only the file URI scheme is supported (see section Service Discovery Endpoint).

For GetRuntimeRepoEndpoint (see section Data Access for Runtime Configuration Repository) and GetOldbEndpoint (see Data Access for OLDB) either the cii.oldb URI scheme can be used for the fully fledged implementations, or the file scheme for the file based implementations.

Service Discovery API

The service discovery interface rtctk::componentFramework::ServiceDiscovery provides the following methods:

std::vector<std::string> ListComponents();
ServiceEndpoint GetOldbEndpoint ();
ServiceEndpoint GetRuntimeRepoEndpoint ();
ServiceEndpoint GetPersistentRepoEndpoint ();
ServiceEndpoint GetReqRepEndpoint (const std::string& component_name = "");
ServiceEndpoint GetPubSubEndpoint (const std::string& component_name = "");

When a component name is not given, the component name given at construction time of Service Discovery is used. The ListComponents function returns all known components.

Example Code

#include <rtctk/componentFramework/serviceDiscovery.hpp>

using rtctk::componentFramework::ServiceDiscovery;

void service_discovery() {
    ServiceDiscovery service_discovery(elt::mal::Uri{"file:///path/to/file.yaml"}, "my_component");
    elt::mal::Uri oldb_uri = service_discovery.GetOldbEndpoint();
    DoSomethingWithOldb(oldb_uri);
    elt::mal::Uri some_component_reqrep_uri = GetReqRepEndpoint("some_component");
}

Limitations and Known Issues

The current file based implementation of the service registry is only a temporary one, it will be replaced by a CII conformant service registry once this is available.

Currently it is not foreseen that developers define custom service types in the service registry. Users are only supposed to re-use the available service types e.g. to add endpoints for new components to the YAML file or to adjust the endpoints of existing components.