RuleGo RuleGo
🏠Home
  • Quick Start
  • Rule Chain
  • Standard Components
  • Extension Components
  • Custom Components
  • Visualization
  • RuleGo-Server
  • RuleGo-MCP-Server
  • AOP
  • Trigger
  • Advanced Topics
  • Performance
  • Standard Components
  • Extension Components
  • Custom Components
  • Components Marketplace
  • Overview
  • Quick Start
  • Routing
  • DSL
  • API
  • Options
  • Components
🔥Editor (opens new window)
  • RuleGo Editor (opens new window)
  • RuleGo Server (opens new window)
  • Github (opens new window)
  • Gitee (opens new window)
  • Changelog (opens new window)
  • English
  • 简体中文
🏠Home
  • Quick Start
  • Rule Chain
  • Standard Components
  • Extension Components
  • Custom Components
  • Visualization
  • RuleGo-Server
  • RuleGo-MCP-Server
  • AOP
  • Trigger
  • Advanced Topics
  • Performance
  • Standard Components
  • Extension Components
  • Custom Components
  • Components Marketplace
  • Overview
  • Quick Start
  • Routing
  • DSL
  • API
  • Options
  • Components
🔥Editor (opens new window)
  • RuleGo Editor (opens new window)
  • RuleGo Server (opens new window)
  • Github (opens new window)
  • Gitee (opens new window)
  • Changelog (opens new window)
  • English
  • 简体中文

广告采用随机轮播方式显示 ❤️成为赞助商
  • Quick Start

  • Rule Chain

  • Standard Components

  • Extension Components

  • Custom Components

  • Components marketplace

  • Visualization

  • AOP

  • Trigger

  • Advanced Topic

    • Config
    • Options
      • Share data
      • Execute Rule Chain
      • Component Configuration Variables
      • Component Connection Reuse
      • Performance
      • Other
    • RuleGo-Server

    • FAQ

    • Endpoint Module

    • Support

    目录

    Options

    # RuleContextOption

    Configuration items for the execution of a rule engine instance. Usage: ruleEngine.OnMsg(msg, ...RuleContextOption), example:

    ruleEngine.OnMsg(msg, types.WithOnEnd(func(ctx types.RuleContext, msg types.RuleMsg, err error) {
        // do something
    }), types.WWithOnRuleChainCompleted(func(ctx RuleContext, snapshot RuleChainRunSnapshot){
        // do something
    }))
    
    1
    2
    3
    4
    5

    The following options are available:

    # WithOnEnd

    Callback for when a rule chain branch execution ends. 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

    # 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

    # 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
    • 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

    # 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 with debugMode enabled

    types.WithOnNodeDebug(func(ruleChainId string, flowType string, nodeId string, msg RuleMsg, relationType string, err error)){
    
    })
    
    1
    2
    3

    TIP

    WithOnNodeDebug callback function contains custom logic that is triggered asynchronously, and the execution order cannot be guaranteed. It may be executed after WithOnAllNodeCompleted and WithOnRuleChainCompleted.

    # WithStartNode

    Set the first start execution node of the rule chain.

    types.WithStartNode(nodeId string) 
    
    1

    # WithTellNext

    Set to search for the next or multiple execution nodes by specifying the node ID. Used to restore the execution link of the rule chain.

    types.WithTellNext(fromNodeId string, relationTypes ...string) 
    
    1
    Edit this page on GitHub (opens new window)
    Last Updated: 2025/04/02, 01:29:50
    Config
    Share data

    ← Config Share data→

    Theme by Vdoing | Copyright © 2023-2025 RuleGo Team | Apache 2.0 License

    • 跟随系统
    • 浅色模式
    • 深色模式
    • 阅读模式