agent: Adding CheckType which is used to wrap either a CheckMonitor or CheckTTL
This commit is contained in:
parent
344ed9569c
commit
dc11ffd359
|
@ -11,6 +11,31 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// CheckType is used to create either the CheckMonitor
|
||||||
|
// or the CheckTTL. Only one of TTL or Script/Interval
|
||||||
|
// needs to be provided
|
||||||
|
type CheckType struct {
|
||||||
|
Script string
|
||||||
|
Interval time.Duration
|
||||||
|
|
||||||
|
TTL time.Duration
|
||||||
|
}
|
||||||
|
|
||||||
|
// Valid checks if the CheckType is valid
|
||||||
|
func (c *CheckType) Valid() bool {
|
||||||
|
return c.IsTTL() || c.IsMonitor()
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsTTL checks if this is a TTL type
|
||||||
|
func (c *CheckType) IsTTL() bool {
|
||||||
|
return c.TTL != 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsMonitor checks if this is a Monitor type
|
||||||
|
func (c *CheckType) IsMonitor() bool {
|
||||||
|
return c.Script != "" && c.Interval != 0
|
||||||
|
}
|
||||||
|
|
||||||
// CheckNotifier interface is used by the CheckMonitor
|
// CheckNotifier interface is used by the CheckMonitor
|
||||||
// to notify when a check has a status update. The update
|
// to notify when a check has a status update. The update
|
||||||
// should take care to be idempotent.
|
// should take care to be idempotent.
|
||||||
|
|
Loading…
Reference in New Issue