Options
# RuleContextOption
- WithOnEnd Callback for when a rule chain branch execution ends Note: If the rule chain has multiple endpoints, the callback function will be executed multiple times
types.WithOnEnd(func(ctx types.RuleContext, msg types.RuleMsg, err error) {
}
1
2
3
2
3
- WithContext Context
- Used for sharing data or semaphores between different component instances
- Used for timeout cancellation
types.WithContext(c context.Context)
1
- WithOnAllNodeCompleted Callback function when all branches of the rule chain have completed execution
- Called only once
types.WithOnAllNodeCompleted(func(){
})
1
2
3
2
3
- WithOnRuleChainCompleted Callback function when the rule chain execution is completed, and collects the runtime logs of each node
types.WithOnRuleChainCompleted(func(ctx RuleContext, snapshot RuleChainRunSnapshot){
})
1
2
3
2
3
RuleChainRunSnapshot:
Field | Type | Description | Default Value |
---|---|---|---|
RuleChain | RuleChain | Rule chain snapshot: Reference | None |
id | string | Message ID | None |
startTs | int64 | Rule chain start execution time | None |
endTs | int64 | Rule chain end execution time | None |
logs | []RuleNodeRunLog | Execution log of each node | None |
additionalInfo | object | Additional information | None |
RuleNodeRunLog:
Field | Type | Description | Default Value |
---|---|---|---|
nodeId | string | Node ID | None |
inMsg | RuleMsg | Input message: Reference | None |
outMsg | RuleMsg | Output message: Reference | None |
relationType | string | Connection type with the next node | None |
err | string | Error information | None |
logItems | []string | Other logs during execution | None |
startTs | int64 | Rule chain start execution time | None |
endTs | int64 | Rule chain end execution time | None |
- WithOnNodeCompleted Callback function when a node is completed, and collects the node's runtime log
types.WithOnNodeCompleted(func(ctx RuleContext, nodeRunLog RuleNodeRunLog){
})
1
2
3
2
3
- WithOnNodeDebug Node debug log callback function
Same as
config.OnDebug
. It is called in real-time asynchronously and will only trigger if the node or rule chain is configured withdebugMode
enabled
types.WithOnNodeDebug(func(ctx RuleContext, nodeRunLog RuleNodeRunLog){
})
1
2
3
2
3
Edit this page on GitHub (opens new window)
Last Updated: 2024/06/16, 16:49:02