feat: change behaviour
Do not return event with ok status on first run of check. Will only return check result if anything went wrong.
This commit is contained in:
14
watchdog.go
14
watchdog.go
@@ -218,11 +218,8 @@ func (w *Watchdog) copyChecks() []Check {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (w *Watchdog) startMonitoring(wdc *wdCheck) {
|
func (w *Watchdog) startMonitoring(wdc *wdCheck) {
|
||||||
|
|
||||||
wdc.stop = make(chan struct{})
|
wdc.stop = make(chan struct{})
|
||||||
|
|
||||||
state := CheckResult{}
|
|
||||||
ticker := time.Tick(wdc.check.Interval)
|
|
||||||
|
|
||||||
c := wdc.check
|
c := wdc.check
|
||||||
|
|
||||||
// this method is called only with
|
// this method is called only with
|
||||||
@@ -243,6 +240,15 @@ func (w *Watchdog) startMonitoring(wdc *wdCheck) {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
state := CheckResult{
|
||||||
|
// if first run return anything
|
||||||
|
// other that OK, we'll report it
|
||||||
|
// if first run is OK, then we do not need to report
|
||||||
|
Status: StatusOK,
|
||||||
|
}
|
||||||
|
|
||||||
|
ticker := time.Tick(wdc.check.Interval)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
w.limiter <- struct{}{}
|
w.limiter <- struct{}{}
|
||||||
|
|
||||||
|
|||||||
@@ -145,15 +145,11 @@ func TestStartStop(t *testing.T) {
|
|||||||
|
|
||||||
count := 0
|
count := 0
|
||||||
|
|
||||||
for res := range out {
|
for range out {
|
||||||
if res.Status != watchdog.StatusOK || res.Error != nil {
|
|
||||||
t.Errorf("incorrect status for check %s", res.Name)
|
|
||||||
}
|
|
||||||
|
|
||||||
count++
|
count++
|
||||||
}
|
}
|
||||||
|
|
||||||
if count != 2 {
|
if count != 0 {
|
||||||
t.Error("incorrect result count received from chan")
|
t.Error("incorrect result count received from chan")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user