blob: 09bbf7a7c524fed5f17f1b420a33dcf345bf67ce (
plain)
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
|
package events
import (
"fmt"
)
type EventBus interface {
SubscribeAll(subID string, ch chan<- Event) error
SubscribeP(subID string, pattern string, ch chan<- Event) error
Unsubscribe(subID string)
UnsubscribeP(subID, pattern string)
Send(ev Event)
}
type Event interface {
fmt.Stringer
Plugin() string
Type() EventType
Message() string
}
type RREvent struct {
// event typ
T EventType
// plugin
P string
// message
M string
}
// NewRREvent initializes new event
func NewRREvent(t EventType, msg string, plugin string) *RREvent {
return &RREvent{
T: t,
P: plugin,
M: msg,
}
}
func (r *RREvent) String() string {
return "RoadRunner event"
}
func (r *RREvent) Type() EventType {
return r.T
}
func (r *RREvent) Message() string {
return r.M
}
func (r *RREvent) Plugin() string {
return r.P
}
type EventType uint32
const (
// EventUnaryCallOk represents success unary call response
EventUnaryCallOk EventType = iota
// EventUnaryCallErr raised when unary call ended with error
EventUnaryCallErr
// EventPushOK thrown when new job has been added. JobEvent is passed as context.
EventPushOK
// EventPushError caused when job can not be registered.
EventPushError
// EventJobStart thrown when new job received.
EventJobStart
// EventJobOK thrown when job execution is successfully completed. JobEvent is passed as context.
EventJobOK
// EventJobError thrown on all job related errors. See JobError as context.
EventJobError
// EventPipeActive when pipeline has started.
EventPipeActive
// EventPipeStopped when pipeline has been stopped.
EventPipeStopped
// EventPipePaused when pipeline has been paused.
EventPipePaused
// EventPipeError when pipeline specific error happen.
EventPipeError
// EventDriverReady thrown when broken is ready to accept/serve tasks.
EventDriverReady
// EventWorkerConstruct thrown when new worker is spawned.
EventWorkerConstruct
// EventWorkerDestruct thrown after worker destruction.
EventWorkerDestruct
// EventSupervisorError triggered when supervisor can not complete work.
EventSupervisorError
// EventWorkerProcessExit triggered on process wait exit
EventWorkerProcessExit
// EventNoFreeWorkers triggered when there are no free workers in the stack and timeout for worker allocate elapsed
EventNoFreeWorkers
// EventMaxMemory caused when worker consumes more memory than allowed.
EventMaxMemory
// EventTTL thrown when worker is removed due TTL being reached. TTL defines maximum time worker is allowed to live (seconds)
EventTTL
// EventIdleTTL triggered when worker spends too much time at rest.
EventIdleTTL
// EventExecTTL triggered when worker spends too much time doing the task (max_execution_time).
EventExecTTL
// EventPoolRestart triggered when pool restart is needed
EventPoolRestart
// EventWorkerError triggered after WorkerProcess. Except payload to be error.
EventWorkerError
// EventWorkerLog triggered on every write to WorkerProcess StdErr pipe (batched). Except payload to be []byte string.
EventWorkerLog
// EventWorkerStderr is the worker standard error output
EventWorkerStderr
// EventWorkerWaitExit is the worker exit event
EventWorkerWaitExit
)
func (et EventType) String() string {
switch et {
case EventPushOK:
return "EventPushOK"
case EventPushError:
return "EventPushError"
case EventJobStart:
return "EventJobStart"
case EventJobOK:
return "EventJobOK"
case EventJobError:
return "EventJobError"
case EventPipeActive:
return "EventPipeActive"
case EventPipeStopped:
return "EventPipeStopped"
case EventPipeError:
return "EventPipeError"
case EventDriverReady:
return "EventDriverReady"
case EventPipePaused:
return "EventPipePaused"
case EventUnaryCallOk:
return "EventUnaryCallOk"
case EventUnaryCallErr:
return "EventUnaryCallErr"
case EventWorkerProcessExit:
return "EventWorkerProcessExit"
case EventWorkerConstruct:
return "EventWorkerConstruct"
case EventWorkerDestruct:
return "EventWorkerDestruct"
case EventSupervisorError:
return "EventSupervisorError"
case EventNoFreeWorkers:
return "EventNoFreeWorkers"
case EventMaxMemory:
return "EventMaxMemory"
case EventTTL:
return "EventTTL"
case EventIdleTTL:
return "EventIdleTTL"
case EventExecTTL:
return "EventExecTTL"
case EventPoolRestart:
return "EventPoolRestart"
case EventWorkerError:
return "EventWorkerError"
case EventWorkerLog:
return "EventWorkerLog"
case EventWorkerStderr:
return "EventWorkerStderr"
case EventWorkerWaitExit:
return "EventWorkerWaitExit"
default:
return "UnknownEventType"
}
}
|