!44 update middlewareFile name

Merge pull request !44 from Sodesnei/feat-middleware-python
This commit is contained in:
Sodesnei 2021-10-04 13:17:28 +00:00 committed by Gitee
commit 7c6c26c5fa
11 changed files with 84 additions and 77 deletions

View File

@ -1,20 +0,0 @@
// Code generated by gen-middleware. DO NOT EDIT.
// make gen-middleware generated
package config
import (
"gitee.com/timedb/wheatCache/middleware"
logMiddle "gitee.com/timedb/wheatCache/middleware/log-middle"
mapKey "gitee.com/timedb/wheatCache/middleware/map-key"
)
func GetMiddlewareMap() map[string]middleware.MiddleToolsInterface {
return map[string]middleware.MiddleToolsInterface{
"logMiddle": logMiddle.NewMiddleware(),
"mapKey": mapKey.NewMiddleware(),
}
}

View File

@ -1,6 +0,0 @@
package middleware
type MiddleToolsInterface interface {
Init()
Exec(interface{}) (interface{}, error)
}

View File

@ -1,22 +0,0 @@
package log_middle
import (
"fmt"
"gitee.com/timedb/wheatCache/middleware"
)
type A struct {
}
func (i *A) Init() {
}
func (i *A) Exec(interface{}) (interface{}, error) {
fmt.Println(1)
return nil, nil
}
func NewMiddleware() middleware.MiddleToolsInterface {
return &A{}
}

View File

@ -1,22 +0,0 @@
package log_middle
import (
"fmt"
"gitee.com/timedb/wheatCache/middleware"
)
type ABB struct {
}
func (i *ABB) Init() {
}
func (i *ABB) Exec(interface{}) (interface{}, error) {
fmt.Println(1)
return nil, nil
}
func NewMiddleware() middleware.MiddleToolsInterface {
return &ABB{}
}

View File

@ -1,6 +1,6 @@
package middle
import getMiddlewareMap "gitee.com/timedb/wheatCache/middleware/config"
import getMiddlewareMap "gitee.com/timedb/wheatCache/plugins/config"
func Init() {
getMiddlewareMap.GetMiddlewareMap()

View File

@ -0,0 +1,20 @@
// Code generated by gen-middleware. DO NOT EDIT.
// make gen-middleware generated
package config
import (
"gitee.com/timedb/wheatCache/plugins"
logMiddle "gitee.com/timedb/wheatCache/plugins/log-middle"
mapKey "gitee.com/timedb/wheatCache/plugins/map-key"
)
func GetMiddlewareMap() map[string]plugins.MiddleToolsInterface {
return map[string]plugins.MiddleToolsInterface{
"logMiddle": logMiddle.NewMiddleware(),
"mapKey": mapKey.NewMiddleware(),
}
}

View File

@ -4,16 +4,16 @@
package config
import (
"gitee.com/timedb/wheatCache/middleware"
"gitee.com/timedb/wheatCache/plugins"
{%for dir in dirs %}
{{dir[0]}} "gitee.com/timedb/wheatCache/middleware/{{dir[1]}}"
{{dir[0]}} "gitee.com/timedb/wheatCache/plugins/{{dir[1]}}"
{%- endfor%}
)
func GetMiddlewareMap() map[string]middleware.MiddleToolsInterface {
func GetMiddlewareMap() map[string]plugins.MiddleToolsInterface {
return map[string]middleware.MiddleToolsInterface{
return map[string]plugins.MiddleToolsInterface{
{%for dir in dirs %}
"{{dir[0]}}":{{dir[0]}}.NewMiddleware(),
{%- endfor%}

7
plugins/define.go Normal file
View File

@ -0,0 +1,7 @@
package plugins
type MiddleToolsInterface interface {
Init() // 初始化
Exec(interface{}) (interface{}, error) // 处理用户发送事件
Name() string // 获取中间件名称
}

View File

@ -0,0 +1,26 @@
package log_middle
import (
"fmt"
"gitee.com/timedb/wheatCache/plugins"
)
type logMiddle struct {
}
func (i *logMiddle) Init() {
}
func (i *logMiddle) Exec(interface{}) (interface{}, error) {
fmt.Println(1)
return nil, nil
}
func (i *logMiddle) Name() string {
return "logMiddle"
}
func NewMiddleware() plugins.MiddleToolsInterface {
return &logMiddle{}
}

View File

@ -0,0 +1,24 @@
package log_middle
import (
"gitee.com/timedb/wheatCache/plugins"
)
type mapKey struct {
}
func (i *mapKey) Init() {
}
func (i *mapKey) Exec(interface{}) (interface{}, error) {
return nil, nil
}
func (i *mapKey) Name() string {
return "mapKey"
}
func NewMiddleware() plugins.MiddleToolsInterface {
return &mapKey{}
}

View File

@ -3,11 +3,11 @@ from jinja2 import Template
sysPath = os.getcwd()
tempPath = f"{sysPath}/middleware/config"
tempPath = f"{sysPath}/plugins/config"
structurePath = f"{sysPath}/pkg/structure"
protobufPath = f"{sysPath}/protobuf"
storagePath = f"{sysPath}/storage"
middlePath = f"{sysPath}/middleware"
middlePath = f"{sysPath}/plugins"
def go_fmt(path: str):
os.system(f"go fmt {path}")