ifw-slm 0.1.2
 
Loading...
Searching...
No Matches
ifw::slm::ServiceResolver Class Reference

#include <serviceResolver.hpp>

Public Types

using HttpGet = std::function<std::string(const std::string& url)>
 

Public Member Functions

 ServiceResolver ()
 Default constructor: uses a libcurl-based GET.
 
 ServiceResolver (HttpGet http_get)
 Test constructor: inject a fake HTTP GET.
 
std::string GetUri (const std::string &service, const std::string &name_space=DefaultNamespace(), const std::string &scheme="zpb.rr") const
 

Static Public Member Functions

static std::string DefaultNamespace ()
 Default namespace from $NOMAD_NAMESPACE, else "default".
 

Detailed Description

Resolves a service name registered in Nomad (preferred) or Consul to a concrete MAL URI of the form "<scheme>://<address>:<port>" (no trailing path).

Member Typedef Documentation

◆ HttpGet

using ifw::slm::ServiceResolver::HttpGet = std::function<std::string(const std::string& url)>

HTTP GET callback: returns the response body, throws std::runtime_error on transport error or non-200 status.

Constructor & Destructor Documentation

◆ ServiceResolver() [1/2]

ifw::slm::ServiceResolver::ServiceResolver ( )

Default constructor: uses a libcurl-based GET.

◆ ServiceResolver() [2/2]

ifw::slm::ServiceResolver::ServiceResolver ( HttpGet http_get)
explicit

Test constructor: inject a fake HTTP GET.

Member Function Documentation

◆ DefaultNamespace()

std::string ifw::slm::ServiceResolver::DefaultNamespace ( )
static

Default namespace from $NOMAD_NAMESPACE, else "default".

◆ GetUri()

std::string ifw::slm::ServiceResolver::GetUri ( const std::string & service,
const std::string & name_space = DefaultNamespace(),
const std::string & scheme = "zpb.rr" ) const

Resolve service to "<scheme>://<address>:<port>". Tries Nomad first, then Consul. Throws std::runtime_error if it cannot be resolved.

Parameters
serviceRegistered service name (e.g. "fcs-req").
name_spaceNomad namespace (ignored by Consul).
schemeMAL transport scheme (default "zpb.rr").

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