From 3d48dbdd556e5e74982a59a53e50c2d183a1edd8 Mon Sep 17 00:00:00 2001 From: elbandi Date: Sat, 9 Sep 2023 00:11:46 +0200 Subject: [PATCH] Allow multiple etcd hosts to be specified in db.etcd.host. --- kvdb/etcd/db.go | 3 ++- kvdb/etcd/fixture.go | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/kvdb/etcd/db.go b/kvdb/etcd/db.go index acdda382b..03d93c620 100644 --- a/kvdb/etcd/db.go +++ b/kvdb/etcd/db.go @@ -8,6 +8,7 @@ import ( "fmt" "io" "runtime" + "strings" "sync" "time" @@ -138,7 +139,7 @@ func NewEtcdClient(ctx context.Context, cfg Config) (*clientv3.Client, context.Context, func(), error) { clientCfg := clientv3.Config{ - Endpoints: []string{cfg.Host}, + Endpoints: strings.Split(cfg.Host, ","), DialTimeout: etcdConnectionTimeout, Username: cfg.User, Password: cfg.Pass, diff --git a/kvdb/etcd/fixture.go b/kvdb/etcd/fixture.go index d1ef6cd7b..b7a697fad 100644 --- a/kvdb/etcd/fixture.go +++ b/kvdb/etcd/fixture.go @@ -5,6 +5,7 @@ package etcd import ( "context" + "strings" "testing" "time" @@ -49,7 +50,7 @@ func NewEtcdTestFixture(t *testing.T) *EtcdTestFixture { t.Cleanup(etcdCleanup) cli, err := clientv3.New(clientv3.Config{ - Endpoints: []string{config.Host}, + Endpoints: strings.Split(config.Host, ","), Username: config.User, Password: config.Pass, })