Is consistency modes exposed via Agent?
Closed this issue · 1 comments
I see your client.KV.Get
supports QueryOptions to set consistency modes. But I'm not seeing any tests or documentation on how to use that on client.Agent.Services
. Or did i misread consul docs and that isn't supported on service lookups?
For reference: https://www.consul.io/docs/agent/http.html#consistency-modes
The Agent endpoint is used to interact with the local agent, where "local" means "the one that the API is connected to" in this context. This means that a consistency mode would have no effect since you're talking to the context of the exact agent you are currently connected to and asking it for information it can provide in authoritative manner, rather than the cluster as a (optionally) consistent whole. Since the agent is authoritative over itself, the information you get from the Agent endpoint is always considered consistent and cannot be "blocked" on since there is no Raft index on the local agent's data, thus there are no QueryOptions
for Agent calls.
If you want to use consistency modes for service lookups, use the client.Catalog endpoint if you don't care about health states or the client.Health endpoint if you want the catalog filtered by health states.
Further, using the Agent endpoint does not incur an RPC roundtrip to the Consul cluster and so is much faster and causes no load on your Consul Servers since it's only traffic between the agent the API is connected to and the API-containing process. If you only care about the services on the box that has the "local" Consul agent, it's much better to use the Agent API vs Catalog/Health.