Hi @maxb , Thank you for your reply.
I think I have a general understanding of: The /agent/service
API, strictly speaking, can only interact with services that are registered to this Agent. In the usual deployment structure, these services are the services on the machine where the Agent is located.
I have a few more questions and thoughts. To describe them clearly, I will divide them into three parts:
(English is not my native language, so please understand any reading difficulties this may cause for you. Thank you very much for reading and I hope to hear back from you!)
1. Confirmation of a question
I would like to confirm a question:
Suppose I have two services and two client agents running on two cloud hosts. I have written code in each service to register itself and discover the service, and these codes connect to the client agent on the respective machine.
So: should the code for discovering services be implemented using the /catalog
API? Because if /agent/service
is used, each service will only be able to query itself?
2. If the above question exists, thoughts arising
If so, /agent/service
seems a bit hard to use because the code is coupled to where the service is deployed – the service you want to discover using the /agent/service
API must be deployed locally.
So, is it common to use the /catalog
API to discover services? Because that’s how I can guarantee that I can always look up the service I need.
In terms of pure experience, I think /agent/service
+ /agent/health/service/id
works better than /catalog
+ /health
. Because the latter two both return arrays of service instances, /health
cannot be queried by id.
Am I right in thinking this way?
3. About the deployment of client agent
In the first sentence of your reply, you mentioned that a consul agent is usually deployed for each machine (I think you mean client agent)
I found a description in this document: “In a typical deployment, you must run client agents on every compute node in your datacenter”
May I ask if the “compute node” mentioned here refers to a single machine?