HLCC Documentation 2.2.0
Loading...
Searching...
No Matches
Public Member Functions | List of all members
hlcc::cpputil::Requestor< INTERFACE_TYPE > Class Template Reference

#include <requestor.hpp>

Public Member Functions

 Requestor (log4cplus::Logger &logger)
 
 Requestor (log4cplus::Logger &logger, const elt::mal::Uri &uri, const std::optional< elt::mal::Mal::Properties > mal_properties={})
 
void SetConnectionInfo (const elt::mal::Uri &uri, const std::optional< elt::mal::Mal::Properties > mal_properties={})
 
std::shared_ptr< INTERFACE_TYPE > & GetInterface ()
 
bool Connect (std::chrono::seconds conn_timeout)
 
 Requestor (const Requestor &)=delete
 
Requestoroperator= (const Requestor &)=delete
 

Detailed Description

template<typename INTERFACE_TYPE>
class hlcc::cpputil::Requestor< INTERFACE_TYPE >

Variant of rad::cii::Requestor, with some different features. (a) The URI does not need to be passed already in the ctor. This allows classes to have a Requestor as a normal member field (without pointer or std::optional for delayed construction) and yet they can retrieve the URI in their ctor implementation or later, e.g. from Config, and only then call SetConnectionInfo. (b) Separates connection from method invocation, also with separate timeouts. (c) Allows change of URI, e.g. when Nomad propagates this via Config update.

Constructor & Destructor Documentation

◆ Requestor() [1/3]

template<typename INTERFACE_TYPE >
hlcc::cpputil::Requestor< INTERFACE_TYPE >::Requestor ( log4cplus::Logger & logger)
inlineexplicit

Delayed client construction. The user must call SetConnectionInfo later, before GetInterface().

◆ Requestor() [2/3]

template<typename INTERFACE_TYPE >
hlcc::cpputil::Requestor< INTERFACE_TYPE >::Requestor ( log4cplus::Logger & logger,
const elt::mal::Uri & uri,
const std::optional< elt::mal::Mal::Properties > mal_properties = {} )
inlineexplicit

This constructor gets a MAL Client for a given interface type and configures it with the provided server URI and QoS.

Parameters
loggerlogger
uriServer URI.
mal_propertiesQoS for message transmission.

◆ Requestor() [3/3]

template<typename INTERFACE_TYPE >
hlcc::cpputil::Requestor< INTERFACE_TYPE >::Requestor ( const Requestor< INTERFACE_TYPE > & )
delete

Member Function Documentation

◆ Connect()

template<typename INTERFACE_TYPE >
bool hlcc::cpputil::Requestor< INTERFACE_TYPE >::Connect ( std::chrono::seconds conn_timeout)
inline

Waits for the MAL client connection to the remote interface to be established (currently this means only to wait for the connection to the process, see ECII-1042).

Calling this method is optional, because CII creates connections automatically. An advantage of checking connection before calling remote methods is that a separate timeout can be used to probe the connection first, e.g. before calling an interface method that takes a long time and therefore requires a long timeout. This allows failing faster in case of connection problems.

Returns
true if the connection already existed or if it was established within the given timeout. false otherwise.

◆ GetInterface()

template<typename INTERFACE_TYPE >
std::shared_ptr< INTERFACE_TYPE > & hlcc::cpputil::Requestor< INTERFACE_TYPE >::GetInterface ( )
inline

This method returns the CII client interface, with which one can invoke methods of the remote service.

Returns
Pointer to MAL Client.

◆ operator=()

template<typename INTERFACE_TYPE >
Requestor & hlcc::cpputil::Requestor< INTERFACE_TYPE >::operator= ( const Requestor< INTERFACE_TYPE > & )
delete

◆ SetConnectionInfo()

template<typename INTERFACE_TYPE >
void hlcc::cpputil::Requestor< INTERFACE_TYPE >::SetConnectionInfo ( const elt::mal::Uri & uri,
const std::optional< elt::mal::Mal::Properties > mal_properties = {} )
inline

This method may be called frequently. Only when the uri changes then a new CII connection will be established. This allows for config updates of configured service URIs, e.g. when Nomad restarts a service elsewhere.


The documentation for this class was generated from the following file: