forked from p93542168/wheat-cache
fix(middle-driver):updata middledriver Init() func
This commit is contained in:
parent
96c8a6d53e
commit
02b048a24f
|
@ -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
|
||||
)
|
||||
|
|
|
@ -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)
|
||||
|
||||
}
|
Loading…
Reference in New Issue