Around Advice
Node around advice (Around Advice): executes before and after the node OnMsg method. This type of advice can replace the original node logic. It can implement node failover, retry, caching and other functions.
Before, After, Around Advice execution order: Around->Before->Around
# Interface
// Order returns the execution order, the smaller the value, the higher the priority
Order() int
// New creates a new instance
New() Aspect
// PointCut declares a cut-in point, used to determine whether to execute the advice
//For example: specify some component types or relationType to execute the aspect logic;return ctx.Self().Type()=="mqttClient"
PointCut(ctx RuleContext, msg RuleMsg, relationType string) bool
//Around is the advice that executes around the node OnMsg method. The returned Msg will be used as the input for the next advice and the next node OnMsg method.
//If it returns false: the engine will not call the next node's OnMsg method, and the aspect needs to execute the tellNext method, otherwise the rule chain will not end.
//If it returns true: the engine will call the next node's OnMsg method.
Around(ctx RuleContext, msg RuleMsg, relationType string) (RuleMsg, bool)
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
Edit this page on GitHub (opens new window)
Last Updated: 2024/09/02, 13:16:41