feat(middle): add middle worker function

This commit is contained in:
Sodesnei 2021-10-09 17:43:34 +08:00
parent f351183ee9
commit 79bef5ba72
2 changed files with 33 additions and 0 deletions

17
pkg/middle/worker.go Normal file
View File

@ -0,0 +1,17 @@
package middle
import (
"context"
)
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)
}
}
}

16
pkg/middle/worker_test.go Normal file
View File

@ -0,0 +1,16 @@
package middle
import (
"testing"
"gitee.com/timedb/wheatCache/pkg/event"
)
func TestWorker(t *testing.T) {
event := event.NewEvent("LogContext")
m := NewMiddleWare()
m.eventDriver.Put(event)
m.middleWorker()
}