bindings.cron: ensure it can resume correctly after context cancellation (#1943)

Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
This commit is contained in:
Alessandro (Ale) Segala 2022-08-09 11:37:07 -07:00 committed by GitHub
parent 1148776d37
commit 697afe8608
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -85,12 +85,12 @@ func (b *Binding) Read(ctx context.Context, handler bindings.Handler) error {
b.logger.Debugf("name: %s, next run: %v", b.name, time.Until(c.Entry(id).Next))
go func() {
// Wait for a context to be canceled or a message on the stopCh
// Wait for a context to be canceled
select {
case <-b.runningCtx.Done():
// Do nothing
case <-ctx.Done():
b.runningCancel()
b.resetContext()
}
b.logger.Debugf("name: %s, stopping schedule: %s", b.name, b.schedule)
c.Stop()