Closed jtackaberry closed 4 months ago
Yeah, you need to "disable cluster discovery". An example of how to do this:
`conn, err := gorqlite.Open("http://localhost:14001?disableClusterDiscovery=true")`
From the README:
When cluster discovery is disabled, only the provided URL will be used to communicate with the API instead of discovering the leader and peers and retrying failed requests with different peers. This is helpful when using a Kubernetes service to handle the load balancing of the requests across healthy nodes.
Maybe you can close the issue if this meets your needs.
Huh, staring me in the face the whole time, can't believe I missed that. Thanks Philip.
I do find the fact that it's an endpoint url query param to be a bit surprising as my intuition is that'd be used to influence server side behavior rather than client side. I looked through the API docs looking for indications in function signatures or things like options structs, but obviously I was looking in the wrong place. 🤦
Most of my client usage with rqlite has been using the HTTP API directly, mostly in Python (not using pyrqlite). I decided to port my client to Go, and figured I would take gorqlite out for a spin.
As you know, I host rqlite in Kubernetes, but while developing the client app, it runs from a VM outside the K8s cluster. It connects to the K8s service for rqlite, and relies on K8s internal load balancing. rqlite has always been quite well behaved with this model, transparently proxying queries and writes to the leader as needed.
Rather than submitting queries/writes to the endpoint passed in
gorqlite.Open()
, gorqlite just seems to use that endpoint to discover the cluster topology, and then connects to the API address advertised by each node. The problem in my case is that the nodes aren't directly accessible -- or indeed can't even be resolved in DNS -- by things outside the K8s cluster. So I get the following:Is it possible to optionally disable this implicit discovery with gorqlite and have it use the endpoint passed to Open() for statements?