-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathevent.go
131 lines (102 loc) · 3.49 KB
/
event.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
package vabastegi
import "time"
// Event is what Vabastegi event look like.
type Event interface {
event() // it's private to prevent outside implementation.
}
// EventHandlers is list of EventHandler.
type EventHandlers []EventHandler
// Publish passed event using event handlers.
func (e EventHandlers) Publish(event Event) {
for _, handler := range e {
handler.OnEvent(event)
}
}
// EventHandler used if you need to handle the events.
type EventHandler interface {
OnEvent(event Event)
}
func (p *OnBuildsExecuting) event() {}
func (p *OnBuildsExecuted) event() {}
func (p *OnBuildExecuting) event() {}
func (p *OnBuildExecuted) event() {}
func (p *OnShutdownExecuting) event() {}
func (p *OnShutdownExecuted) event() {}
func (p *OnApplicationShutdownExecuting) event() {}
func (p *OnApplicationShutdownExecuted) event() {}
func (p *OnLog) event() {}
// OnBuildsExecuting is emitted before a Builds is executed.
type OnBuildsExecuting struct {
// BuildAt is the time build happened.
BuildAt time.Time
}
// OnBuildsExecuted is emitted after a Builds has been executed.
type OnBuildsExecuted struct {
// Runtime specifies how long it took to run this hook.
Runtime time.Duration
// Err is non-nil if the hook failed to execute.
Err error
}
// OnBuildExecuting is emitted before a Build is executed.
type OnBuildExecuting struct {
// BuildAt is the time build happened.
BuildAt time.Time
// ProviderName is the name of the function that will be executed.
ProviderName string
// CallerPath is the path of provider if from.
CallerPath string
}
// OnBuildExecuted is emitted after a Provider has been executed.
type OnBuildExecuted struct {
// ProviderName is the name of the function that was executed.
ProviderName string
// CallerPath is the path of provider if from.
CallerPath string
// Runtime specifies how long it took to run this hook.
Runtime time.Duration
// Err is non-nil if the hook failed to execute.
Err error
}
// OnShutdownExecuting is emitted before a Shutdown is executed.
type OnShutdownExecuting struct {
// ShutdownAt is the time shutdown happened.
ShutdownAt time.Time
// ProviderName is the name of the function that will be executed.
ProviderName string
// CallerPath is the path of provider if from.
CallerPath string
}
// OnShutdownExecuted is emitted after a Shutdown has been executed.
type OnShutdownExecuted struct {
// ProviderName is the name of the function that was executed.
ProviderName string
// CallerPath is the path of provider if from.
CallerPath string
// Runtime specifies how long it took to run this hook.
Runtime time.Duration
// Err is non-nil if the hook failed to execute.
Err error
}
// OnApplicationShutdownExecuting is emitted before the application Shutdown is executed.
type OnApplicationShutdownExecuting struct {
// ShutdownAt is the time shutdown happened.
ShutdownAt time.Time
// Reason is the reason for shutdown the application.
Reason string
}
// OnApplicationShutdownExecuted is emitted after the application Shutdown has been executed.
type OnApplicationShutdownExecuted struct {
// Reason is the reason for shutdown the application.
Reason string
// Runtime specifies how long it took to run this hook.
Runtime time.Duration
// Err is non-nil if the hook failed to execute.
Err error
}
// OnLog is used if a log event is sent.
type OnLog struct {
LogAt time.Time
Level logLevel
Message string
Args []interface{}
}