fix(middle-driver):updata middledriver Init() func

This commit is contained in:
Sodesnei 2021-10-05 10:39:53 +08:00
parent 96c8a6d53e
commit 02b048a24f
2 changed files with 47 additions and 3 deletions

View File

@ -1,7 +1,17 @@
package middle
import getMiddlewareMap "gitee.com/timedb/wheatCache/plugins/config"
import (
"sync"
func Init() {
getMiddlewareMap.GetMiddlewareMap()
"gitee.com/timedb/wheatCache/plugins"
getMiddlewareMap "gitee.com/timedb/wheatCache/plugins/config"
)
func Init() map[string]plugins.MiddleToolsInterface {
return getMiddlewareMap.GetMiddlewareMap()
}
var (
oneMiddle sync.Once
MiddleWareDriver *MiddleWare
)

View File

@ -0,0 +1,34 @@
package middle
import (
"context"
"fmt"
"gitee.com/timedb/wheatCache/pkg/event"
)
type MiddleWare struct {
eventDriver event.DriverInterface
eventConsumer event.ConsumerInterface
}
func NewMiddleWare() *MiddleWare {
oneMiddle.Do(func() {
driver := event.NewDriver(1000)
MiddleWareDriver = &MiddleWare{
eventDriver: driver,
eventConsumer: event.NewConsumer(driver),
}
})
return MiddleWareDriver
}
func (m *MiddleWare) GetEventDriver() event.DriverInterface {
return m.eventDriver
}
func (m *MiddleWare) work(ctx context.Context) {
getMiddlewareMap := Init()
fmt.Println(getMiddlewareMap)
}