增加入口发时间方法
This commit is contained in:
parent
ea3f8df7d1
commit
fb20a61d74
@ -20,7 +20,8 @@ import (
|
||||
|
||||
var (
|
||||
// ReflectTypeInstance 反射实例
|
||||
ReflectTypeInstance *ReflectType
|
||||
ReflectTypeInstance *ReflectType
|
||||
ReflectValueInstance *ReflectValue
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -28,6 +29,7 @@ func init() {
|
||||
lock: &sync.RWMutex{},
|
||||
cacheTable: make(map[string]*StructInfo),
|
||||
}
|
||||
ReflectValueInstance = &ReflectValue{}
|
||||
}
|
||||
|
||||
// ReflectType 反射数据类型
|
||||
|
36
send.go
Normal file
36
send.go
Normal file
@ -0,0 +1,36 @@
|
||||
// Package event ...
|
||||
//
|
||||
// Description : event ...
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 2023-02-02 15:15
|
||||
package event
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"git.zhangdeman.cn/zhangdeman/event/abstract"
|
||||
)
|
||||
|
||||
// SendEvent 发送事件
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 15:16 2023/2/2
|
||||
func SendEvent(dataFlag string, data interface{}, preSendHandler abstract.IPreSendHandler, sendEventHandler abstract.ISendEventHandler) {
|
||||
// 通过反射填充数据
|
||||
ReflectValueInstance.Do(dataFlag, data, preSendHandler)
|
||||
if byteData, err := json.Marshal(data); nil != err {
|
||||
sendEventHandler.FailCallback(map[string]interface{}{
|
||||
"err": err.Error(),
|
||||
"reason": "data marshal fail",
|
||||
}, err)
|
||||
} else {
|
||||
sendResult, sendErr := sendEventHandler.Send(byteData)
|
||||
if nil != sendErr {
|
||||
sendEventHandler.FailCallback(sendResult, sendErr)
|
||||
return
|
||||
}
|
||||
sendEventHandler.SuccessCallback(sendResult)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user