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:
parent
1148776d37
commit
697afe8608
|
@ -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))
|
b.logger.Debugf("name: %s, next run: %v", b.name, time.Until(c.Entry(id).Next))
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
// Wait for a context to be canceled or a message on the stopCh
|
// Wait for a context to be canceled
|
||||||
select {
|
select {
|
||||||
case <-b.runningCtx.Done():
|
case <-b.runningCtx.Done():
|
||||||
// Do nothing
|
// Do nothing
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
b.runningCancel()
|
b.resetContext()
|
||||||
}
|
}
|
||||||
b.logger.Debugf("name: %s, stopping schedule: %s", b.name, b.schedule)
|
b.logger.Debugf("name: %s, stopping schedule: %s", b.name, b.schedule)
|
||||||
c.Stop()
|
c.Stop()
|
||||||
|
|
Loading…
Reference in New Issue