From eead61cb6d322df06e45880b5ee063c3e79432a9 Mon Sep 17 00:00:00 2001 From: Tim Vaillancourt Date: Thu, 7 Jul 2022 05:05:37 +0200 Subject: [PATCH] cleanup v4 --- go/logic/applier.go | 3 +-- go/logic/migrator.go | 6 ++---- go/logic/throttler.go | 12 ++++-------- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/go/logic/applier.go b/go/logic/applier.go index 52b3570..ec0ee86 100644 --- a/go/logic/applier.go +++ b/go/logic/applier.go @@ -345,8 +345,7 @@ func (this *Applier) InitiateHeartbeat() { ticker := time.NewTicker(time.Duration(this.migrationContext.HeartbeatIntervalMilliseconds) * time.Millisecond) defer ticker.Stop() - for { - <-ticker.C + for range ticker.C { if atomic.LoadInt64(&this.finishedMigrating) > 0 { return } diff --git a/go/logic/migrator.go b/go/logic/migrator.go index e78aab3..1f94906 100644 --- a/go/logic/migrator.go +++ b/go/logic/migrator.go @@ -813,8 +813,7 @@ func (this *Migrator) initiateStatus() { this.printStatus(ForcePrintStatusAndHintRule) ticker := time.NewTicker(time.Second) defer ticker.Stop() - for { - <-ticker.C + for range ticker.C { if atomic.LoadInt64(&this.finishedMigrating) > 0 { return } @@ -1054,8 +1053,7 @@ func (this *Migrator) initiateStreaming() error { go func() { ticker := time.NewTicker(time.Second) defer ticker.Stop() - for { - <-ticker.C + for range ticker.C { if atomic.LoadInt64(&this.finishedMigrating) > 0 { return } diff --git a/go/logic/throttler.go b/go/logic/throttler.go index 66e7ed5..b7739f8 100644 --- a/go/logic/throttler.go +++ b/go/logic/throttler.go @@ -170,8 +170,7 @@ func (this *Throttler) collectReplicationLag(firstThrottlingCollected chan<- boo ticker := time.NewTicker(time.Duration(this.migrationContext.HeartbeatIntervalMilliseconds) * time.Millisecond) defer ticker.Stop() - for { - <-ticker.C + for range ticker.C { if atomic.LoadInt64(&this.finishedMigrating) > 0 { return } @@ -328,8 +327,7 @@ func (this *Throttler) collectThrottleHTTPStatus(firstThrottlingCollected chan<- collectInterval := time.Duration(this.migrationContext.ThrottleHTTPIntervalMillis) * time.Millisecond ticker := time.NewTicker(collectInterval) defer ticker.Stop() - for { - <-ticker.C + for range ticker.C { if atomic.LoadInt64(&this.finishedMigrating) > 0 { return } @@ -450,8 +448,7 @@ func (this *Throttler) initiateThrottlerCollection(firstThrottlingCollected chan ticker := time.NewTicker(time.Second) defer ticker.Stop() - for { - <-ticker.C + for range ticker.C { if atomic.LoadInt64(&this.finishedMigrating) > 0 { return } @@ -482,8 +479,7 @@ func (this *Throttler) initiateThrottlerChecks() { ticker := time.NewTicker(100 * time.Millisecond) defer ticker.Stop() - for { - <-ticker.C + for range ticker.C { if atomic.LoadInt64(&this.finishedMigrating) > 0 { return }