fixing infinite worker loop
Signed-off-by: Mike Monaghan <mike_monaghan@live.ca>
This commit is contained in:
parent
c862165130
commit
aab08b9050
1 changed files with 8 additions and 8 deletions
|
|
@ -272,6 +272,14 @@ func (w *Worker) eventLoop() {
|
||||||
rnd, _ := rand.Int(rand.Reader, big.NewInt(int64(w.kclConfig.ShardSyncIntervalMillis)))
|
rnd, _ := rand.Int(rand.Reader, big.NewInt(int64(w.kclConfig.ShardSyncIntervalMillis)))
|
||||||
shardSyncSleep := w.kclConfig.ShardSyncIntervalMillis/2 + int(rnd.Int64())
|
shardSyncSleep := w.kclConfig.ShardSyncIntervalMillis/2 + int(rnd.Int64())
|
||||||
|
|
||||||
|
select {
|
||||||
|
case <-*w.stop:
|
||||||
|
log.Infof("Shutting down...")
|
||||||
|
return
|
||||||
|
case <-time.After(time.Duration(shardSyncSleep) * time.Millisecond):
|
||||||
|
log.Debugf("Waited %d ms to sync shards...", shardSyncSleep)
|
||||||
|
}
|
||||||
|
|
||||||
err := w.syncShard()
|
err := w.syncShard()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Error syncing shards: %+v, Retrying in %d ms...", err, shardSyncSleep)
|
log.Errorf("Error syncing shards: %+v, Retrying in %d ms...", err, shardSyncSleep)
|
||||||
|
|
@ -363,14 +371,6 @@ func (w *Worker) eventLoop() {
|
||||||
log.Warnf("Error in rebalance: %+v", err)
|
log.Warnf("Error in rebalance: %+v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
select {
|
|
||||||
case <-*w.stop:
|
|
||||||
log.Infof("Shutting down...")
|
|
||||||
return
|
|
||||||
case <-time.After(time.Duration(shardSyncSleep) * time.Millisecond):
|
|
||||||
log.Debugf("Waited %d ms to sync shards...", shardSyncSleep)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue