Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rrichardson opened this issue Dec 7, 2021 · 1 comment
Open

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

rrichardson opened this issue Dec 7, 2021 · 1 comment

Comments

@rrichardson
Copy link

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.

@iopanda
Copy link

iopanda commented Jul 22, 2022

@rrichardson try this:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants