node.jsgrpcetcdetcd3

How to use etcd3 nodejs client for differnt port than standard?


I am using https://github.com/microsoft/etcd3 for etcd3 NodeJS client, but it is by default taking default port 2379 or 2380 for gRPC. But I am running multiple etcd docker container instances. How to create multiple clients based on multiple ports.

Thanks.


Solution

  • I think you can provide a single or array of hosts when you construct the client. See the following for hosts and a slightly more involved reference for configuring grpcOptions:

    https://microsoft.github.io/etcd3/interfaces/ioptions.html#hosts

    https://microsoft.github.io/etcd3/interfaces/ioptions.html#grpcoptions

    So use values other than localhost and 2379:

    const client = new Etcd3(options = { hosts: '127.0.0.1:2379' });