Skip to content

Commit 5f21dd7

Browse files
committed
Minor: etcd connection monitor as a singleton
1 parent f69a618 commit 5f21dd7

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

utils/etcd.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414

1515
var etcdClient *clientv3.Client = nil
1616
var clientMutex sync.Mutex
17+
var startedConnMonitor bool
1718

1819
func GetEtcdClient() (*clientv3.Client, error) {
1920
clientMutex.Lock()
@@ -37,7 +38,10 @@ func GetEtcdClient() (*clientv3.Client, error) {
3738

3839
etcdClient = cli
3940

40-
startConnectionMonitor(etcdClient)
41+
if !startedConnMonitor {
42+
startConnectionMonitor(etcdClient)
43+
startedConnMonitor = true
44+
}
4145

4246
return cli, nil
4347
}

0 commit comments

Comments
 (0)