From 0ec555badf84d7eef859baa304f9966d1c78defe Mon Sep 17 00:00:00 2001 From: Tim Vaillancourt Date: Thu, 7 Jul 2022 03:19:53 +0200 Subject: [PATCH] Cleanup --- go/logic/throttler.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/go/logic/throttler.go b/go/logic/throttler.go index 33b08f3..46bd4bc 100644 --- a/go/logic/throttler.go +++ b/go/logic/throttler.go @@ -247,15 +247,14 @@ func (this *Throttler) collectControlReplicasLag() { this.migrationContext.SetControlReplicasLagResult(readControlReplicasLag()) } - aggressiveTicker := time.NewTicker(100 * time.Millisecond) - defer aggressiveTicker.Stop() - relaxedFactor := 10 counter := 0 shouldReadLagAggressively := false + ticker := time.NewTicker(100 * time.Millisecond) + defer ticker.Stop() for { - <-aggressiveTicker.C + <-ticker.C if atomic.LoadInt64(&this.finishedMigrating) > 0 { return } @@ -464,9 +463,6 @@ func (this *Throttler) initiateThrottlerCollection(firstThrottlingCollected chan // initiateThrottlerChecks initiates the throttle ticker and sets the basic behavior of throttling. func (this *Throttler) initiateThrottlerChecks() { - throttlerTick := time.NewTicker(100 * time.Millisecond) - defer throttlerTick.Stop() - throttlerFunction := func() { alreadyThrottling, currentReason, _ := this.migrationContext.IsThrottled() shouldThrottle, throttleReason, throttleReasonHint := this.shouldThrottle() @@ -483,8 +479,11 @@ func (this *Throttler) initiateThrottlerChecks() { this.migrationContext.SetThrottled(shouldThrottle, throttleReason, throttleReasonHint) } throttlerFunction() + + ticker := time.NewTicker(100 * time.Millisecond) + defer ticker.Stop() for { - <-throttlerTick.C + <-ticker.C if atomic.LoadInt64(&this.finishedMigrating) > 0 { return }