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:
@@ -32,11 +32,27 @@ func NewRequestForTest(
|
||||
// NewTestService creates a Service suitable for unit testing.
|
||||
// It discards log output and uses the given transport.
|
||||
func NewTestService(transport http.RoundTripper) *Service {
|
||||
return &Service{
|
||||
log: slog.New(slog.DiscardHandler),
|
||||
transport: transport,
|
||||
history: NewAlertHistory(),
|
||||
}
|
||||
return newService(slog.New(slog.DiscardHandler), transport)
|
||||
}
|
||||
|
||||
// NewTestServiceWithLogger creates a Service that writes to the
|
||||
// given handler, so tests can assert on emitted log records.
|
||||
func NewTestServiceWithLogger(
|
||||
transport http.RoundTripper,
|
||||
handler slog.Handler,
|
||||
) *Service {
|
||||
return newService(slog.New(handler), transport)
|
||||
}
|
||||
|
||||
// Drain exports drain for testing.
|
||||
func (svc *Service) Drain(ctx context.Context) {
|
||||
svc.drain(ctx)
|
||||
}
|
||||
|
||||
// OutstandingDeliveries reports how many delivery goroutines
|
||||
// are currently tracked as in flight.
|
||||
func (svc *Service) OutstandingDeliveries() int64 {
|
||||
return svc.outstanding.Load()
|
||||
}
|
||||
|
||||
// SetNtfyURL sets the ntfy URL on a Service for testing.
|
||||
|
||||
Reference in New Issue
Block a user