From 83e29faa5554d0c3ccae46782991d28f958d9f3d Mon Sep 17 00:00:00 2001 From: Guo Lei Date: Mon, 9 Jan 2023 22:47:08 +0800 Subject: [PATCH] use time.NewTicker instead of time.Tick. (#4119) --- weed/server/volume_grpc_client_to_master.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/weed/server/volume_grpc_client_to_master.go b/weed/server/volume_grpc_client_to_master.go index 921ec0677..e2cae079e 100644 --- a/weed/server/volume_grpc_client_to_master.go +++ b/weed/server/volume_grpc_client_to_master.go @@ -158,8 +158,8 @@ func (vs *VolumeServer) doHeartbeat(masterAddress pb.ServerAddress, grpcDialOpti return "", err } - volumeTickChan := time.Tick(sleepInterval) - ecShardTickChan := time.Tick(17 * sleepInterval) + volumeTickChan := time.NewTicker(sleepInterval) + ecShardTickChan := time.NewTicker(17 * sleepInterval) dataCenter := vs.store.GetDataCenter() rack := vs.store.GetRack() ip := vs.store.Ip @@ -228,14 +228,14 @@ func (vs *VolumeServer) doHeartbeat(masterAddress pb.ServerAddress, grpcDialOpti glog.V(0).Infof("Volume Server Failed to update to master %s: %v", masterAddress, err) return "", err } - case <-volumeTickChan: + case <-volumeTickChan.C: glog.V(4).Infof("volume server %s:%d heartbeat", vs.store.Ip, vs.store.Port) vs.store.MaybeAdjustVolumeMax() if err = stream.Send(vs.store.CollectHeartbeat()); err != nil { glog.V(0).Infof("Volume Server Failed to talk with master %s: %v", masterAddress, err) return "", err } - case <-ecShardTickChan: + case <-ecShardTickChan.C: glog.V(4).Infof("volume server %s:%d ec heartbeat", vs.store.Ip, vs.store.Port) if err = stream.Send(vs.store.CollectErasureCodingHeartbeat()); err != nil { glog.V(0).Infof("Volume Server Failed to talk with master %s: %v", masterAddress, err)