diff options
| author | hilimd <68371223+hilimd@users.noreply.github.com> | 2020-11-05 12:02:47 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-05 12:02:47 +0800 |
| commit | 546f1bcb903dd26ba447cdbedb972736fdb31b42 (patch) | |
| tree | 09b8119faa7162acaa7240de5af6fd0bebe96c2f /weed/wdclient/masterclient.go | |
| parent | 843865f2ca534bb6286b7a3d79c436384d875608 (diff) | |
| parent | 75887ba2a20b9f3f7ff9c4b8998cf3af0c0f48c2 (diff) | |
| download | seaweedfs-546f1bcb903dd26ba447cdbedb972736fdb31b42.tar.xz seaweedfs-546f1bcb903dd26ba447cdbedb972736fdb31b42.zip | |
Merge pull request #34 from chrislusf/master
sync
Diffstat (limited to 'weed/wdclient/masterclient.go')
| -rw-r--r-- | weed/wdclient/masterclient.go | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/weed/wdclient/masterclient.go b/weed/wdclient/masterclient.go index 60753e582..df8c186f2 100644 --- a/weed/wdclient/masterclient.go +++ b/weed/wdclient/masterclient.go @@ -5,6 +5,7 @@ import ( "math/rand" "time" + "github.com/chrislusf/seaweedfs/weed/util" "google.golang.org/grpc" "github.com/chrislusf/seaweedfs/weed/glog" @@ -150,10 +151,12 @@ func (mc *MasterClient) tryConnectToMaster(master string) (nextHintedLeader stri } func (mc *MasterClient) WithClient(fn func(client master_pb.SeaweedClient) error) error { - for mc.currentMaster == "" { - time.Sleep(3 * time.Second) - } - return pb.WithMasterClient(mc.currentMaster, mc.grpcDialOption, func(client master_pb.SeaweedClient) error { - return fn(client) + return util.Retry("master grpc", func() error { + for mc.currentMaster == "" { + time.Sleep(3 * time.Second) + } + return pb.WithMasterClient(mc.currentMaster, mc.grpcDialOption, func(client master_pb.SeaweedClient) error { + return fn(client) + }) }) } |
