2025-07-12 22:01:23 +03:00
|
|
|
package watchdog
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"time"
|
|
|
|
|
)
|
|
|
|
|
|
2025-07-25 18:42:16 +03:00
|
|
|
// CheckFunc is a function that does the actual work.
|
|
|
|
|
// This package provides a number of check functions but
|
|
|
|
|
// any function matching the signature may be provided.
|
2025-07-12 22:01:23 +03:00
|
|
|
// It must obey context dealine and cancellation.
|
2025-09-23 23:14:13 +03:00
|
|
|
type CheckFunc func(context.Context) error
|
2025-07-12 22:01:23 +03:00
|
|
|
|
|
|
|
|
// Check represents a check that must be run by Watchdog.
|
|
|
|
|
type Check struct {
|
|
|
|
|
Name string // indentifier of this check
|
|
|
|
|
Interval time.Duration // how often the check must run (if running periodically with Start method)
|
|
|
|
|
Check CheckFunc // function to run
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type CheckResult struct {
|
2025-09-23 23:14:13 +03:00
|
|
|
Name string // identifier of check
|
|
|
|
|
Error error // error returned by CheckFunc
|
2025-07-12 22:01:23 +03:00
|
|
|
}
|