-
Notifications
You must be signed in to change notification settings - Fork 0
/
check.go
54 lines (47 loc) · 1.32 KB
/
check.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package types
// CheckStatus possible status of a check.
type CheckStatus string
const (
CheckStatusOK CheckStatus = "ok"
CheckStatusFailed CheckStatus = "failed"
CheckStatusNew CheckStatus = "new"
CheckStatusRunning CheckStatus = "running"
)
// AllValidCheckStatuses all valid statuses for checks.
var AllValidCheckStatuses = [...]CheckStatus{
CheckStatusNew,
CheckStatusOK,
CheckStatusRunning,
CheckStatusFailed,
}
// AllValidCheckProtocols all valid protocols for checks.
var AllValidCheckProtocols = [...]PipelinePortProtocol{
PipelineProtocolUDP,
PipelineProtocolTCP,
}
// Check base check model.
type Check struct {
Protocol PipelinePortProtocol `json:"protocol"`
Status CheckStatus `json:"status"`
Retries uint `json:"retries"`
Port uint `json:"port"`
Host string `json:"host"`
}
// ValidCheckProtocol checks if the given status is a valid check protocol.
func ValidCheckProtocol(p PipelinePortProtocol) bool {
for _, protocol := range AllValidCheckProtocols {
if p == protocol {
return true
}
}
return false
}
// ValidCheckStatus checks if the given string is a valid check status.
func ValidCheckStatus(s CheckStatus) bool {
for _, status := range AllValidCheckStatuses {
if s == status {
return true
}
}
return false
}