in pkg/dispatcher/dispatcher.go [214:246]
func Stop() {
log.Log(log.ShimDispatcher).Info("stopping the dispatcher")
var chanClosed bool
select {
case <-getDispatcher().stopChan:
chanClosed = true
default:
}
if chanClosed {
if getDispatcher().isRunning() {
log.Log(log.ShimDispatcher).Info("dispatcher shutdown in progress")
} else {
log.Log(log.ShimDispatcher).Info("dispatcher is already stopped")
}
return
}
close(getDispatcher().stopChan)
maxTimeout := 5
for getDispatcher().isRunning() && maxTimeout > 0 {
log.Log(log.ShimDispatcher).Info("waiting for dispatcher to be stopped",
zap.Int("remainingSeconds", maxTimeout))
time.Sleep(1 * time.Second)
maxTimeout--
}
if getDispatcher().isRunning() {
log.Log(log.ShimDispatcher).Warn("dispatcher even processing did not stop properly")
} else {
log.Log(log.ShimDispatcher).Info("dispatcher stopped successfully")
}
}