etcd3 icon indicating copy to clipboard operation
etcd3 copied to clipboard

Need a way to alter the hosts/endpoints at runtime?

Open rrichardson opened this issue 4 years ago • 1 comments

In order for services to behave themselves while the underlying etcd cluster is mutating (old nodes being replaced by new nodes) how can I tell my Etcd3 instance to abandon certain endpoints and adopt new ones?

As I understand it, ClusterClient is for altering the shape of the cluster itself, which is not what I want.
I just want to just read/write data from the cluster, and to adapt the shape of a cluster after it has changed.

Presently, I use an SRV record to initialize the client with something like:

      ...
      let result = await resolveSrv(cfg.discoverySrv);
      cfg.hosts = result.filter((r) => r.port == 2379).map((r) => `https://${r.name}:${r.port}`);
      const root = new etcd3(cfg);
      ...

I would like to periodically check the SRV record at runtime, and update the hosts value in the Etcd client, but I don't see a way to do that.

rrichardson avatar Dec 07 '21 20:12 rrichardson

@rrichardson try this:

const { Etcd3 } = require('etcd3')
const etcd = new Etcd3({
    hosts: ['localhost:2379']
})

iopanda avatar Jul 22 '22 14:07 iopanda