Some output tweaks; and some additional transition events upon resume (paused->unknown->{up|down})
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user