From 05176bd1bb5af94bfbabbb524ed9e65448134e39 Mon Sep 17 00:00:00 2001 From: Helin Wang Date: Thu, 24 Aug 2017 01:23:27 +0000 Subject: [PATCH] master server will wait etcd forever --- go/master/client.go | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/go/master/client.go b/go/master/client.go index 199690d48..f04cf50ce 100644 --- a/go/master/client.go +++ b/go/master/client.go @@ -60,18 +60,6 @@ func WithAddr(addr string) func(c *Client) error { } } -func retry(f func() error, dur time.Duration, count int) error { - err := f() - if err != nil { - if count > 0 { - time.Sleep(dur) - return retry(f, dur, count-1) - } - return err - } - return nil -} - // WithEtcd sets the client to use etcd for master discovery. func WithEtcd(endpoints []string, timeout time.Duration) func(*Client) error { return func(c *Client) error { @@ -84,9 +72,14 @@ func WithEtcd(endpoints []string, timeout time.Duration) func(*Client) error { }) return err } - err := retry(f, time.Second, 10) - if err != nil { - return err + for { + err := f() + if err != nil { + log.Warningln(err) + } else { + break + } + time.Sleep(time.Second) } ch := make(chan string, 1) -- GitLab