#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". | |
Resolves a service name registered in Nomad (preferred) or Consul to a concrete MAL URI of the form "<scheme>://<address>:<port>" (no trailing path).
| 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.
| ifw::slm::ServiceResolver::ServiceResolver | ( | ) |
Default constructor: uses a libcurl-based GET.
|
explicit |
Test constructor: inject a fake HTTP GET.
|
static |
Default namespace from $NOMAD_NAMESPACE, else "default".
| 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.
| service | Registered service name (e.g. "fcs-req"). |
| name_space | Nomad namespace (ignored by Consul). |
| scheme | MAL transport scheme (default "zpb.rr"). |