Options
# RuleContextOption
- WithOnEnd 规则链分支执行结束回调 注意:如果规则链有多个结束点,回调函数则会执行多次
types.WithOnEnd(func(ctx types.RuleContext,msg types.RuleMsg, err error) {
}
1
2
3
2
3
- WithContext 上下文
- 用于不同组件实例数据或者信号量共享
- 用于超时取消
types.WithContext(c context.Context)
1
- WithOnAllNodeCompleted 规则链所有分支执行完回调函数
- 只回调一次
types.WithOnAllNodeCompleted(func(){
})
1
2
3
2
3
- WithOnRuleChainCompleted 规则链执行完回调函数,并收集每个节点的运行日志
types.WithOnRuleChainCompleted(func(ctx RuleContext, snapshot RuleChainRunSnapshot){
})
1
2
3
2
3
RuleChainRunSnapshot:
字段 | 类型 | 说明 | 默认值 |
---|---|---|---|
RuleChain | RuleChain | 规则链快照:参考 | 无 |
id | string | 消息ID | 无 |
startTs | int64 | 规则链开始执行时间 | 无 |
endTs | int64 | 规则链结束执行时间 | 无 |
logs | []RuleNodeRunLog | 每个节点执行日志 | 无 |
additionalInfo | object | 扩展信息 | 无 |
RuleNodeRunLog:
字段 | 类型 | 说明 | 默认值 |
---|---|---|---|
nodeId | string | 节点ID | 无 |
inMsg | RuleMsg | 输入消息:参考 | 无 |
outMsg | RuleMsg | 输出消息 :参考 | 无 |
relationType | string | 和下一个节点连接类型 | 无 |
err | string | 错误信息 | 无 |
logItems | []string | 执行过程中其他日志 | 无 |
startTs | int64 | 规则链开始执行时间 | 无 |
endTs | int64 | 规则链结束执行时间 | 无 |
- WithOnNodeCompleted 节点执行完回调函数,并收集节点的运行日志
types.WithOnNodeCompleted(func(ctx RuleContext, nodeRunLog RuleNodeRunLog){
})
1
2
3
2
3
- WithOnNodeDebug 节点调试日志回调函数
和
config.OnDebug
一样。实时异步调用,必须节点或者规则链配置开启debugMode
才会触发
types.WithOnNodeCompleted(func(ctx RuleContext, nodeRunLog RuleNodeRunLog){
})
1
2
3
2
3
在 GitHub 上编辑此页 (opens new window)
上次更新: 2024/06/16, 16:49:02