-
Notifications
You must be signed in to change notification settings - Fork 1
/
escalation.go
47 lines (39 loc) · 1.46 KB
/
escalation.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
package main
import (
"encoding/json"
"time"
)
type EscalationMethod int
const (
NotifyOnDuty EscalationMethod = iota // 0
NotifyNextInRotation // 1
NotifyOtherPerson // 2
NotifyWebhook // 3
NotifyEmail // 4
)
// EscalationStep defines how alerts are escalated when an contact
// does not respond in time. Target takes a different meaning depending on
// the EscalationMethod. It is ignored on NotifyOnDuty or NotifyNextInRotation.
// For NotifyOtherPerson it's the name of another contact, for CallWebhook it's an URL
// and for SendEmail it's an email address.
type EscalationStep struct {
TimeBeforeEscalation time.Duration `yaml:"timebefore" json:"timebefore"` // How long to try the current step
Method EscalationMethod `yaml:"method" json:"method"` // What action to take during this step
Target string `yaml:"target" json:"target"` // Who or what to do the action with
}
func (e *EscalationMethod) Marshal() ([]byte, error) {
je, err := json.Marshal(&e)
return je, err
}
func (e *EscalationMethod) Unmarshal(je string) error {
err := json.Unmarshal([]byte(je), &e)
return err
}
func (e *EscalationStep) Marshal() ([]byte, error) {
je, err := json.Marshal(&e)
return je, err
}
func (e *EscalationStep) Unmarshal(je string) error {
err := json.Unmarshal([]byte(je), &e)
return err
}