notify: drain in-flight deliveries at shutdown (closes #106)
check / check (push) Successful in 1m22s
check / check (push) Successful in 1m22s
Shutdown waits for deliveries already in flight instead of dropping them. Reviewed and green; squashed to next by the dispatcher, dnswatcher having no manager. Model: opus-5
This commit was merged in pull request #113.
This commit is contained in:
@@ -2,6 +2,7 @@ package notify
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math"
|
||||
"math/rand/v2"
|
||||
"time"
|
||||
@@ -121,6 +122,14 @@ func (svc *Service) deliverWithRetry(
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
case <-svc.abandon:
|
||||
// Shutdown drained past its deadline; stop
|
||||
// sleeping rather than outlive the process.
|
||||
// A nil channel (Service built without a
|
||||
// constructor) simply never fires.
|
||||
return fmt.Errorf(
|
||||
"%w: %s", ErrDeliveryAbandoned, endpoint,
|
||||
)
|
||||
case <-svc.sleepFunc(delay):
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user