fix(middle): add middle worker function

This commit is contained in:
Sodesnei 2021-10-09 18:33:42 +08:00
parent 12f594b246
commit 67747a5b6a
3 changed files with 13 additions and 5 deletions

View File

@ -3,7 +3,7 @@ package middle_msg
import "time"
var (
EventNameLog = "LogContext"
EventNameLog = "logcontext"
EventKeyLog = "LogContext"
)

View File

@ -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)
}
}
}
}

View File

@ -7,7 +7,7 @@ import (
)
func TestWorker(t *testing.T) {
event := event.NewEvent("LogContext")
event := event.NewEvent("logcontext")
m := NewMiddleWare()
m.eventDriver.Put(event)