forked from p93542168/wheat-cache
fix(middle): add middle worker function
This commit is contained in:
parent
12f594b246
commit
67747a5b6a
|
@ -3,7 +3,7 @@ package middle_msg
|
|||
import "time"
|
||||
|
||||
var (
|
||||
EventNameLog = "LogContext"
|
||||
EventNameLog = "logcontext"
|
||||
|
||||
EventKeyLog = "LogContext"
|
||||
)
|
||||
|
|
|
@ -2,15 +2,23 @@ package middle
|
|||
|
||||
import (
|
||||
"context"
|
||||
|
||||
msg "gitee.com/timedb/wheatCache/pkg/middle-msg"
|
||||
)
|
||||
|
||||
func (m *MiddleWare) middleWorker() {
|
||||
ctx := context.Background()
|
||||
workEvent := m.eventConsumer.Receive(ctx)
|
||||
m.loadPlugins()
|
||||
for _, singles := range m.plugins {
|
||||
for _, single := range singles {
|
||||
single.Exec(workEvent)
|
||||
switch workEvent.GetEventName() {
|
||||
case msg.EventNameLog:
|
||||
for middleMsg, singles := range m.plugins {
|
||||
|
||||
if middleMsg == msg.EventNameLog {
|
||||
for _, single := range singles {
|
||||
single.Exec(workEvent)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
)
|
||||
|
||||
func TestWorker(t *testing.T) {
|
||||
event := event.NewEvent("LogContext")
|
||||
event := event.NewEvent("logcontext")
|
||||
|
||||
m := NewMiddleWare()
|
||||
m.eventDriver.Put(event)
|
||||
|
|
Loading…
Reference in New Issue