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