-
Notifications
You must be signed in to change notification settings - Fork 0
/
debug.go
50 lines (41 loc) · 870 Bytes
/
debug.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
package debug
import (
"context"
"log"
"math/rand"
"github.com/csmith/goplum"
)
type Plugin struct{}
func (p Plugin) Alert(kind string) goplum.Alert {
switch kind {
case "sysout":
return SysOutAlert{}
default:
return nil
}
}
func (p Plugin) Check(kind string) goplum.Check {
switch kind {
case "random":
return RandomCheck{PercentGood: 0.5}
default:
return nil
}
}
type RandomCheck struct {
PercentGood float64 `config:"percent_good"`
}
func (t RandomCheck) Execute(_ context.Context) goplum.Result {
r := rand.Float64()
if r <= t.PercentGood {
return goplum.GoodResult()
} else {
return goplum.FailingResult("Random value %f greater than percent_good %f", r, t.PercentGood)
}
}
type SysOutAlert struct {
}
func (s SysOutAlert) Send(details goplum.AlertDetails) error {
log.Printf("DEBUG ALERT - %s\n", details.Text)
return nil
}