forked from p93542168/wheat-cache
feat(middle): add middle worker function
This commit is contained in:
parent
f351183ee9
commit
79bef5ba72
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -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()
|
||||
|
||||
}
|
Loading…
Reference in New Issue