Some output tweaks; and some additional transition events upon resume (paused->unknown->{up|down})

This commit is contained in:
2026-04-11 03:04:47 +02:00
parent 46e78ec36f
commit 56a4a6ba25
4 changed files with 85 additions and 25 deletions

View File

@@ -104,13 +104,15 @@ type Backend struct {
Transitions []Transition // newest first, capped at maxHistory
}
// New creates a Backend in StateUnknown.
// New creates a Backend in StateUnknown with the health counter pre-loaded to
// Rise-1, so the very first probe resolves the state: one pass → Up, any
// fail → Down (via the StateUnknown shortcut in Record).
func New(name string, addr net.IP, rise, fall int) *Backend {
return &Backend{
Name: name,
Address: addr,
State: StateUnknown,
Counter: HealthCounter{Rise: rise, Fall: fall},
Counter: HealthCounter{Rise: rise, Fall: fall, Health: rise - 1},
}
}
@@ -155,7 +157,7 @@ func (b *Backend) Resume(maxHistory int) bool {
return false
}
b.transition(StateUnknown, ProbeResult{}, maxHistory)
b.Counter.Health = 0
b.Counter.Health = b.Counter.Rise - 1
return true
}