Skip to content

Commit aa2b3d6

Browse files
committed
fix: reduntant use of watcher.stop
1 parent 399a7e6 commit aa2b3d6

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

pkg/event_handler/main.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,25 @@ func Start(ctx context.Context, stop context.CancelFunc, cfg *conf.GlobalConfig,
2727
Notifier: notifier,
2828
}
2929
go func() {
30+
defer func() {
31+
log.Print("[event handler] shutting down, stopping watcher")
32+
watcher.Stop()
33+
}()
34+
3035
for {
3136
select {
3237
case <-ctx.Done():
33-
log.Print("[event handler] context canceled, stopping watcher")
34-
watcher.Stop()
38+
log.Print("[event handler] context canceled, exiting")
3539
return
3640
case event, ok := <-watcher.ResultChan():
3741
if !ok {
3842
log.Print("[event handler] result channel closed")
39-
watcher.Stop()
40-
stop()
4143
return
4244
}
4345
if err2 := handler.Handle(ctx, &event); err2 != nil {
44-
log.Printf("[event handler] failed to Handle workflow event: %v", err2)
46+
log.Printf("[event handler] failed to handle workflow event: %v", err2)
4547
}
4648
}
4749
}
48-
4950
}()
5051
}

0 commit comments

Comments
 (0)