Skip to content

Commit

Permalink
fix: reduntant use of watcher.stop
Browse files Browse the repository at this point in the history
  • Loading branch information
GoshaDo committed Jan 11, 2025
1 parent 399a7e6 commit aa2b3d6
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions pkg/event_handler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,25 @@ func Start(ctx context.Context, stop context.CancelFunc, cfg *conf.GlobalConfig,
Notifier: notifier,
}
go func() {
defer func() {
log.Print("[event handler] shutting down, stopping watcher")
watcher.Stop()
}()

for {
select {
case <-ctx.Done():
log.Print("[event handler] context canceled, stopping watcher")
watcher.Stop()
log.Print("[event handler] context canceled, exiting")
return
case event, ok := <-watcher.ResultChan():
if !ok {
log.Print("[event handler] result channel closed")
watcher.Stop()
stop()
return
}
if err2 := handler.Handle(ctx, &event); err2 != nil {
log.Printf("[event handler] failed to Handle workflow event: %v", err2)
log.Printf("[event handler] failed to handle workflow event: %v", err2)
}
}
}

}()
}

0 comments on commit aa2b3d6

Please sign in to comment.