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

    • Standard Components Overview
    • filter

    • action

      • log
      • functions
        • Configuration
        • Relation Type
        • Execution result
        • Configuration example
        • Application example
        • Difference between config.Udf and functions custom functions
      • delay
      • groupAction
      • iterator
      • for
      • exec
      • join
    • transform

    • external

    • flow

  • Extension Components

  • Custom Components

  • Components marketplace

  • Visualization

  • AOP

  • Trigger

  • Advanced Topic

  • RuleGo-Server

  • FAQ

  • Endpoint Module

  • Support

目录

functions

functions component: execute custom processing functions. Used for lightweight custom node implementation, allowing your Golang custom functions to become components in seconds. Supports getting the function name value from metadata dynamically using ${metadataKey}.

Before using this component, you must register custom processing functions using the following method, and the default framework does not provide any processing functions.

action.Functions.Register(functionName string, f func(ctx types.RuleContext, msg types.RuleMsg))
1

If the function processing is successful, you must use the following method to notify the rule engine that it has been successfully processed:

//TellSuccess notifies the rule engine that the current message processing is successful and sends the message to the next node through the `Success` relationship
ctx.TellSuccess(msg RuleMsg)
//TellNext sends the message to the next node using the specified relationTypes
ctx.TellNext(msg RuleMsg, relationTypes ...string)
1
2
3
4

If the function processing fails, the implementation must call the tellFailure method:

//TellFailure notifies the rule engine that the current message processing failed and sends the message to the next node through the `Failure` relationship
ctx.TellFailure(msg RuleMsg, err error)
1
2
  • ctx: context
  • msg: the message passed in by the previous node

# Configuration

Field Type Description Default value
functionName string The name of the function to call, can using Component Configuration Variables None

# Relation Type

Function custom

# Execution result

Function custom

# Configuration example

{
  "id": "s1",
  "type": "functions",
  "name": "Call function 1",
  "configuration": {
    "functionName": "handleMsg"
  }
}
1
2
3
4
5
6
7
8

# Application example

Example reference: Example (opens new window)

# Difference between config.Udf and functions custom functions

  • config.Udf : custom functions called by js script at runtime, functions have no fixed parameters and return values.
  • functions : custom functions called by the functions node through the configuration function name, functions must be of this type: func(ctx types.RuleContext, msg types.RuleMsg).
Edit this page on GitHub (opens new window)
Last Updated: 2025/04/02, 01:29:50
log
delay

← log delay→

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

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