...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package recorder
17
18 import (
19 "fmt"
20 "time"
21 )
22
23 type MissedSchedule struct {
24 MissedRun time.Time
25 }
26
27 func (m MissedSchedule) Type() string {
28 return "Warning"
29 }
30
31 func (m MissedSchedule) Reason() string {
32 return "MissSchedule"
33 }
34
35 func (m MissedSchedule) Message() string {
36 return fmt.Sprintf("Missed scheduled time to start a job: %s", m.MissedRun.Format(time.RFC1123Z))
37 }
38
39 type ScheduleSpawn struct {
40 Name string
41 }
42
43 func (s ScheduleSpawn) Type() string {
44 return "Normal"
45 }
46
47 func (s ScheduleSpawn) Reason() string {
48 return "Spawned"
49 }
50
51 func (s ScheduleSpawn) Message() string {
52 return fmt.Sprintf("Create new object: %s", s.Name)
53 }
54
55 type ScheduleForbid struct {
56 RunningName string
57 }
58
59 func (s ScheduleForbid) Type() string {
60 return "Warning"
61 }
62
63 func (s ScheduleForbid) Reason() string {
64 return "Forbid"
65 }
66
67 func (s ScheduleForbid) Message() string {
68 return fmt.Sprintf("Forbid spawning new job because: %s is still running", s.RunningName)
69 }
70
71 type ScheduleSkipRemoveHistory struct {
72 RunningName string
73 }
74
75 func (s ScheduleSkipRemoveHistory) Type() string {
76 return "Warning"
77 }
78
79 func (s ScheduleSkipRemoveHistory) Reason() string {
80 return "Skip"
81 }
82
83 func (s ScheduleSkipRemoveHistory) Message() string {
84 return fmt.Sprintf("Skip removing history: %s is still running", s.RunningName)
85 }
86
87 func init() {
88 register(MissedSchedule{}, ScheduleSpawn{}, ScheduleForbid{}, ScheduleSkipRemoveHistory{})
89 }
90