增加处理接口约束以及枚举值定义

This commit is contained in:
2023-02-01 14:29:27 +08:00
commit 2a67a8b165
4 changed files with 164 additions and 0 deletions

View File

@ -0,0 +1,62 @@
// Package abstract ...
//
// Description : 事件发送前预处理接口约束
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 2023-02-01 14:06
package abstract
import (
"net/http"
)
// IPreSendHandler ...
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 14:06 2023/2/1
type IPreSendHandler interface {
// GetEventID 为每一条事件生成唯一的ID, 此方法若返回空值, 则会自动生成一个随机的md5字符串作为事件ID
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 14:10 2023/2/1
GetEventID() string
// GetRequestParam 构造 base info 时, 可能需要从请求参数中提取公共数据
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 14:13 2023/2/1
GetRequestParam() map[string]interface{}
// GetRequestHeader ...
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 14:14 2023/2/1
// 构造 base info 时, 可能需要从请求参数中提取公共数据
GetRequestHeader() http.Header
// GetResponseData 响应数据
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 14:15 2023/2/1
GetResponseData() map[string]interface{}
// GetExtensionData 获取扩展数据
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 14:19 2023/2/1
GetExtensionData() map[string]interface{}
// GetEventData 获取事件数据, 建议返回结构体或者结构体指针, 内部会自动补齐缺失的数据
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 14:16 2023/2/1
GetEventData() interface{}
}

View File

@ -0,0 +1,38 @@
// Package abstract ...
//
// Description : abstract ...
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 2023-02-01 14:21
package abstract
// ISendEventHandler 发送事件处理器
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 14:21 2023/2/1
type ISendEventHandler interface {
// Send ...
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 14:21 2023/2/1
// 事件发送成功之后, 可以返回一些业务数据, 这些业务数据会回调给SuccessCallback
// 事件发送成功之后, 可以返回一些业务数据 以及 err, 这些业务数据会回调给FailCallback
Send(data []byte) (map[string]interface{}, error)
// SuccessCallback 事件发送成功的回调
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 14:21 2023/2/1
SuccessCallback(data map[string]interface{})
// FailCallback 事件发送失败的回调
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 14:22 2023/2/1
FailCallback(data map[string]interface{}, err error)
}