Closed kinnalru closed 4 years ago
Hello @kinnalru ,
The endpoint already implemented in diplomat: https://github.com/WeAreFarmGeek/diplomat/blob/master/lib/diplomat/agent.rb#L31
It of course works only for a single agent (aka it find agent only for a single Consul Agent). For me, it has little usage as it is not really unique (it is unique ONLY per agent, not within cluster).
Still, the serviceID is available for the whole cluster as well in Diplomat::Service.get
.
So, if I understand clearly, it means that what you want it:
# Return nil or the service having given ID for Consul agent we are configured with
def agent_service_from_id(id_to_lookup)
Diplomat::Agent.services.select{|i,s| s['ID'] == serviceid_to_look_at}.first
end
Can we close the issue or did I miss something?
Yep. Thanx.
Diplomat::Service.get
uses"/v1/catalog/service/#{key}"
path which returns not service configuration butnodes providing a service in a given datacenter
. See here: https://www.consul.io/api/catalog.html#list-nodes-for-serviceSo there is no method in
Diplomat::Service
to retrieve configuratiom registered withDiplomat::Service.register
by unique service ID.Do you intrested in implementation of such method? https://www.consul.io/api/agent/service.html#get-service-configuration