I have a Go service which is pluggable and based on the plugin serve different purposes. At the start it's register the address and port into the Consul's service discovery and it's tags like plugin1
, plugin2
, plugin3
, etc.
On the client-side I want to connect to the services based on the plugin what it implements. I can get them from consul, call the grpc.Dial
and pass it to the proto's client implementation. When I call the right endpoint I just close the connection and go on.
The problem with this, the grpc.Dial
can be a reusable connection, so not necessary to call it anytime when I want to connect to a service, but it's too dynamic to have a persistent connection to the services, because services could be removed or new services can appear.
What is the best way to have persistent connection to the services based on this requirements/problems?