fix(middleware): fix plugins Interface

This commit is contained in:
Sodesnei 2021-10-09 18:46:57 +08:00
parent 67747a5b6a
commit 89ee969ef7
3 changed files with 22 additions and 7 deletions

View File

@ -3,7 +3,8 @@ package plugins
import "gitee.com/timedb/wheatCache/pkg/event"
type MiddleToolsInterface interface {
Init() // 初始化
Exec(e event.Event) (event.Event, error) // 处理用户发送事件
Name() string // 获取中间件名称
Init() // 初始化
Exec(e *event.Event) (*event.Event, error) // 处理用户发送事件
Name() string // 获取中间件名称
Describe() string // 描述
}

View File

@ -1,6 +1,8 @@
package log_middle
import (
"fmt"
"gitee.com/timedb/wheatCache/pkg/event"
"gitee.com/timedb/wheatCache/plugins"
)
@ -11,7 +13,9 @@ type logMiddle struct {
func (i *logMiddle) Init() {
}
func (i *logMiddle) Exec(e event.Event) (event.Event, error) {
func (i *logMiddle) Exec(e *event.Event) (*event.Event, error) {
fmt.Println(e.GetEventName())
return e, nil
}
@ -19,6 +23,9 @@ func (i *logMiddle) Name() string {
return "logMiddle"
}
func (i *logMiddle) Describe() string {
return ""
}
func NewMiddleware() plugins.MiddleToolsInterface {
return &logMiddle{}
}

View File

@ -1,6 +1,9 @@
package log_middle
import (
"fmt"
"gitee.com/timedb/wheatCache/pkg/event"
"gitee.com/timedb/wheatCache/plugins"
)
@ -10,15 +13,19 @@ type mapKey struct {
func (i *mapKey) Init() {
}
func (i *mapKey) Exec(interface{}) (interface{}, error) {
return nil, nil
func (i *mapKey) Exec(e *event.Event) (*event.Event, error) {
fmt.Println(e.GetEventName())
return e, nil
}
func (i *mapKey) Name() string {
return "mapKey"
}
func (i *mapKey) Describe() string {
return ""
}
func NewMiddleware() plugins.MiddleToolsInterface {
return &mapKey{}
}