summaryrefslogtreecommitdiff
path: root/events
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-10-30 15:13:59 +0300
committerValery Piashchynski <[email protected]>2021-10-30 15:13:59 +0300
commit1cac0d3efd40e8950004c8d953fb5d1f2d53197b (patch)
treee71fcd3ed2d8bbc1bb4542290a11d5cb9730a4b1 /events
parent875f0060501fa3f32b21c1670aeb5efe15a37e24 (diff)
remove non rr2 sdk events
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'events')
-rw-r--r--events/events.go75
-rw-r--r--events/events_test.go24
2 files changed, 13 insertions, 86 deletions
diff --git a/events/events.go b/events/events.go
index b7396653..5a417e7f 100644
--- a/events/events.go
+++ b/events/events.go
@@ -3,72 +3,26 @@ package events
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
-
+ EventWorkerConstruct EventType = iota
// 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.
@@ -81,32 +35,6 @@ const (
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:
@@ -127,7 +55,6 @@ func (et EventType) String() string {
return "EventExecTTL"
case EventPoolRestart:
return "EventPoolRestart"
-
case EventWorkerError:
return "EventWorkerError"
case EventWorkerLog:
diff --git a/events/events_test.go b/events/events_test.go
index fd8a8a05..f7cb4205 100644
--- a/events/events_test.go
+++ b/events/events_test.go
@@ -12,15 +12,15 @@ func TestEvenHandler(t *testing.T) {
defer eh.Unsubscribe(id)
ch := make(chan Event, 100)
- err := eh.SubscribeP(id, "http.EventJobOK", ch)
+ err := eh.SubscribeP(id, "http.EventWorkerError", ch)
require.NoError(t, err)
- eh.Send(NewEvent(EventJobOK, "http", "foo"))
+ eh.Send(NewEvent(EventWorkerError, "http", "foo"))
evt := <-ch
require.Equal(t, "foo", evt.Message())
require.Equal(t, "http", evt.Plugin())
- require.Equal(t, "EventJobOK", evt.Type().String())
+ require.Equal(t, "EventWorkerError", evt.Type().String())
}
func TestEvenHandler2(t *testing.T) {
@@ -31,18 +31,18 @@ func TestEvenHandler2(t *testing.T) {
ch := make(chan Event, 100)
ch2 := make(chan Event, 100)
- err := eh2.SubscribeP(id2, "http.EventJobOK", ch)
+ err := eh2.SubscribeP(id2, "http.EventWorkerError", ch)
require.NoError(t, err)
- err = eh.SubscribeP(id, "http.EventJobOK", ch2)
+ err = eh.SubscribeP(id, "http.EventWorkerError", ch2)
require.NoError(t, err)
- eh.Send(NewEvent(EventJobOK, "http", "foo"))
+ eh.Send(NewEvent(EventWorkerError, "http", "foo"))
evt := <-ch2
require.Equal(t, "foo", evt.Message())
require.Equal(t, "http", evt.Plugin())
- require.Equal(t, "EventJobOK", evt.Type().String())
+ require.Equal(t, "EventWorkerError", evt.Type().String())
l := eh.Len()
require.Equal(t, uint(2), l)
@@ -65,7 +65,7 @@ func TestEvenHandler3(t *testing.T) {
defer eh.Unsubscribe(id)
ch := make(chan Event, 100)
- err := eh.SubscribeP(id, "EventJobOK", ch)
+ err := eh.SubscribeP(id, "EventWorkerError", ch)
require.Error(t, err)
}
@@ -73,7 +73,7 @@ func TestEvenHandler4(t *testing.T) {
eh, id := Bus()
defer eh.Unsubscribe(id)
- err := eh.SubscribeP(id, "EventJobOK", nil)
+ err := eh.SubscribeP(id, "EventWorkerError", nil)
require.Error(t, err)
}
@@ -82,15 +82,15 @@ func TestEvenHandler5(t *testing.T) {
defer eh.Unsubscribe(id)
ch := make(chan Event, 100)
- err := eh.SubscribeP(id, "http.EventJobOK", ch)
+ err := eh.SubscribeP(id, "http.EventWorkerError", ch)
require.NoError(t, err)
- eh.Send(NewEvent(EventJobOK, "http", "foo"))
+ eh.Send(NewEvent(EventWorkerError, "http", "foo"))
evt := <-ch
require.Equal(t, "foo", evt.Message())
require.Equal(t, "http", evt.Plugin())
- require.Equal(t, "EventJobOK", evt.Type().String())
+ require.Equal(t, "EventWorkerError", evt.Type().String())
}
type MySuperEvent uint32