Skip to content

Commit 3d48dbd

Browse files
committed
Allow multiple etcd hosts to be specified in db.etcd.host.
1 parent 72a36da commit 3d48dbd

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

kvdb/etcd/db.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"fmt"
99
"io"
1010
"runtime"
11+
"strings"
1112
"sync"
1213
"time"
1314

@@ -138,7 +139,7 @@ func NewEtcdClient(ctx context.Context, cfg Config) (*clientv3.Client,
138139
context.Context, func(), error) {
139140

140141
clientCfg := clientv3.Config{
141-
Endpoints: []string{cfg.Host},
142+
Endpoints: strings.Split(cfg.Host, ","),
142143
DialTimeout: etcdConnectionTimeout,
143144
Username: cfg.User,
144145
Password: cfg.Pass,

kvdb/etcd/fixture.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package etcd
55

66
import (
77
"context"
8+
"strings"
89
"testing"
910
"time"
1011

@@ -49,7 +50,7 @@ func NewEtcdTestFixture(t *testing.T) *EtcdTestFixture {
4950
t.Cleanup(etcdCleanup)
5051

5152
cli, err := clientv3.New(clientv3.Config{
52-
Endpoints: []string{config.Host},
53+
Endpoints: strings.Split(config.Host, ","),
5354
Username: config.User,
5455
Password: config.Pass,
5556
})

0 commit comments

Comments
 (0)