How to make a client for multiple hosts

first, i build the consul cluster on my three server machine, which have three consul server and three consul client.

And i try to use https://github.com/hashicorp/consul/api for my golang code to connect consul cluster.

but it seems that the config param of <api.NewClient> function can only fill the string type Address, so that i can’t fill my three hosts

how should i config correctly ?
thanks !

Hi @linsijia1002,

Normally API clients just make a connection to a single Consul agent for all operations.

Is there a particular reason your application needs to communicate with multiple Consul agents?

hi @blake ,
yes , because the high available.
When the machine which is connected is down, it means the application is lose connection with the consul cluster.
Normally like redis cluster, or kafka cluster , client application fill multiple hosts to insure the high available.
So i want to know what should i do in consul cluster

In this case, you should run multiple instances of your application on each server that is running a Consul agent. The application should register itself into the Consul catalog by communicating with the Consul agent running on the same machine.

When other services query the catalog (https://learn.hashicorp.com/tutorials/consul/get-started-service-discovery#query-services) for the service name, Consul will respond with the IP addresses of each registered, healthy service instance.

Ok,i get you mean,i will try. thank you.
By the way, in your plan, is HTTP API better or DNS more recommended ?
I usually use the HTTP API.
Thank you.