notify: drain in-flight deliveries at shutdown (closes #106)
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:
2026-09-09 14:26:53 +02:00
parent b8662b8a9c
commit ae06f7e3a1
7 changed files with 780 additions and 72 deletions
+9
View File
@@ -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):
}
}