Show a target paused by its circuit breaker (closes #385)
check / check (push) Successful in 3m21s

While an http or slack target's circuit breaker turns its deliveries
away, the target's row on the webhook page says its deliveries are
paused and until when, in UTC and from now. Each of its retrying
deliveries shows as waiting, with the reason and the same time, in the
event log and on the event's page, instead of a bare "retrying".

The engine gains one read, CooldownRemaining(targetID), over the
breakers it already keeps; the handlers reach it through a one-method
interface wired like Archives.

Model: opus-5-5
This commit is contained in:
2026-10-02 22:04:53 +00:00
parent 9305af4f85
commit f531cf9cdf
16 changed files with 358 additions and 22 deletions
+30
View File
@@ -24,6 +24,34 @@ type TargetRowView struct {
// Archive is a database target's archive file, and nil for a target
// of any other type.
Archive *ArchiveFileView
// Paused is set while the target's circuit breaker is turning its
// deliveries away, and nil otherwise.
Paused *PausedView
}
// PausedView is when a target's circuit breaker will let deliveries to
// it through again: Until is the time in UTC, and Relative how long
// that is from now.
type PausedView struct {
Until string
Relative string
}
// pausedView reads the target's circuit breaker, and returns nil when
// the breaker is not turning the target's deliveries away.
func (h *Handlers) pausedView(targetID string) *PausedView {
remaining := h.breakers.CooldownRemaining(targetID)
if remaining <= 0 {
return nil
}
until := time.Now().Add(remaining)
return &PausedView{
Until: until.UTC().Format(time.TimeOnly) + " UTC",
Relative: humanize.Time(until),
}
}
// TargetDeliveries is how many of a target's deliveries became
@@ -84,6 +112,8 @@ func (h *Handlers) targetRows(
if targets[i].Type == database.TargetTypeDatabase {
rows[i].Archive = h.archiveFileView(webhook, &targets[i])
}
rows[i].Paused = h.pausedView(targets[i].ID)
}
return rows