12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- package ruleEngine
- import "time"
- type Message struct {
- QueueName string
- Id string
- Ts time.Time
- Type string
- Data string
- RuleChanId string
- RuleNodeId string
- Callback IMessageCallBack
- }
- // IMessageCallBack message call back
- type IMessageCallBack interface {
- // on success do sth.
- OnSuccess()
- // on failure do sth.
- OnFailure(err error)
- // on process start do sth.
- onProcessingStart(ruleNodeInfo *RuleNodeInfo)
- // on process end do sth.
- onProcessingEnd(ruleNodeId string)
- }
- type emptyCallBack struct {
- }
- func (e emptyCallBack) onProcessingStart(ruleNodeInfo *RuleNodeInfo) {
- }
- func (e emptyCallBack) onProcessingEnd(ruleNodeId string) {
- }
- var EmptyCallBack = emptyCallBack{}
- func (e emptyCallBack) OnSuccess() {
- }
- func (e emptyCallBack) OnFailure(err error) {
- }
- // GetCallBack get message call back
- func (a *Message) GetCallBack() IMessageCallBack {
- if a.Callback == nil {
- return EmptyCallBack
- } else {
- return a.Callback
- }
- }
|