Allow multiple etcd hosts to be specified in db.etcd.host.

This commit is contained in:
elbandi
2023-09-09 00:11:46 +02:00
parent 72a36da9c6
commit 3d48dbdd55
2 changed files with 4 additions and 2 deletions

View File

@@ -8,6 +8,7 @@ import (
"fmt" "fmt"
"io" "io"
"runtime" "runtime"
"strings"
"sync" "sync"
"time" "time"
@@ -138,7 +139,7 @@ func NewEtcdClient(ctx context.Context, cfg Config) (*clientv3.Client,
context.Context, func(), error) { context.Context, func(), error) {
clientCfg := clientv3.Config{ clientCfg := clientv3.Config{
Endpoints: []string{cfg.Host}, Endpoints: strings.Split(cfg.Host, ","),
DialTimeout: etcdConnectionTimeout, DialTimeout: etcdConnectionTimeout,
Username: cfg.User, Username: cfg.User,
Password: cfg.Pass, Password: cfg.Pass,

View File

@@ -5,6 +5,7 @@ package etcd
import ( import (
"context" "context"
"strings"
"testing" "testing"
"time" "time"
@@ -49,7 +50,7 @@ func NewEtcdTestFixture(t *testing.T) *EtcdTestFixture {
t.Cleanup(etcdCleanup) t.Cleanup(etcdCleanup)
cli, err := clientv3.New(clientv3.Config{ cli, err := clientv3.New(clientv3.Config{
Endpoints: []string{config.Host}, Endpoints: strings.Split(config.Host, ","),
Username: config.User, Username: config.User,
Password: config.Pass, Password: config.Pass,
}) })