From ec8cea59a4960771b4031a7952198b33ab1455aa Mon Sep 17 00:00:00 2001 From: Sodesnei <1452401269@qq.com> Date: Sun, 10 Oct 2021 22:26:03 +0800 Subject: [PATCH] feat(doc): middleware doc --- doc/pkg/middle/middle.md | 47 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 doc/pkg/middle/middle.md diff --git a/doc/pkg/middle/middle.md b/doc/pkg/middle/middle.md new file mode 100644 index 0000000..51eec50 --- /dev/null +++ b/doc/pkg/middle/middle.md @@ -0,0 +1,47 @@ +### 中间件调用 + + +### 创建事件 + +event := event.NewEvent("logcontext") + + +### 创建驱动 + +middleware := NewMiddleWare() + +### 将事件推入驱动 + +middleware.eventProduce.Call(ctx, event) + + +### 获取驱动的事件 +middleware.eventConsumer.Reciver(ctx) + + + +### 插件接口 +type MiddleToolsInterface interface { + Init() // 初始化 + Exec(interface{}) (interface{}, error) // 处理用户发送事件 + Name() string // 获取中间件名称 + Describe() string // 描述 +} + +### 插件的New方法规定为 NewMiddleWare() + 每个插件都要定义NewMiddleWare() + + + +### 将插件名 “logMiddle” 注册到配置文件wheat-cache.yaml,其他插件注册 +plugins-control: + logcontext: ["logMiddle"] + + + + + + + + +