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

    • Dynamic Components
      • Overview of Dynamic Components
      • Implementation of Dynamic Components
        • 1. Define Components through Sub-Rule Chain DSL
        • 2. Implement Component Logic through Orchestration and Combination of Existing Components:
        • 3. Register the Component DSL with the Engine:
        • 4. Use the Component in Rule Chains:
    • Dynamic Component Installation
    • Dynamic Component Publishing
  • Visualization

  • AOP

  • Trigger

  • Advanced Topic

  • RuleGo-Server

  • FAQ

  • Endpoint Module

  • Support

目录

Dynamic Components

# Overview of Dynamic Components

In addition to native components (nc), RuleGo rule chains can also implement dynamic components (dc) through JSON DSL. Dynamic components are essentially sub-rule chains that combine and orchestrate existing components to create a new component for use in rule chains.

The characteristics of dynamic components are:

  1. Components can be dynamically installed, upgraded, and uninstalled.
  2. Components are defined through JSON DSL, eliminating the need for compilation, which facilitates publishing and upgrading.
  3. Sub-rule chains can be converted into components.
  4. They provide secondary encapsulation and extension of existing components.
  5. Components can be installed and updated online through component marketplace (opens new window) .

# Implementation of Dynamic Components

Dynamic components can be implemented through the following steps:

# 1. Define Components through Sub-Rule Chain DSL

Example:

{
  "ruleChain": {
    "id": "dataTransform",      // Component type identifier
    "name": "Temperature Conversion",// Component name
    "root": false,// Defined as a sub-rule chain
    "additionalInfo": {         // Component metadata
      "category": "custom",    // Component category
      "icon": "custom-node", // Component icon
      "description": "Temperature conversion component", // Component description
      "relationTypes": ["Success"], // Allowed relationship types with the next component
      "author": "admin",
      "version": "1.0.0",
      "inputSchema": {          // Parameter configuration definition (JSON Schema)
        "type": "object",
        "properties": { // Component parameter definition
          "scaleFactor": {
            "type": "number",// Parameter type (supports number, string, bool, object, array)
            "title": "Conversion Factor",// Title
            "default": 1.8 // Default value
          }
        }
      }
    }
  },
  "metadata": {                // Component logic implementation
    "nodes": [
      {
      "type": "jsTransform",
      "configuration": {
        "jsScript": "msg.temperature = msg.temperature * ${vars.scaleFactor} + 32; return {'msg':msg,'metadata':metadata,'msgType':msgType};" // Reference component parameters through ${vars.fieldName}
      }
    }],
    "connections": []
  }
 
  }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

The dynamic component DSL is consistent with the Rule Chain DSL. Among them:

  • ruleChain.id: The component type identifier, used to uniquely identify the component type. Rule chains use this identifier to utilize the component. Component type identifiers can be defined using a namespace format, for example: x/dataTransform
  • ruleChain.additionalInfo describes the component's metadata, including its category, icon, description, relationship types, and input parameter configuration.

additionalInfo Object

Field Name Type Required Description Default Value
category String No Component category, helps users quickly locate the required component type. custom
icon String No Component icon, displayed on the user interface, usually a class name or path of the icon. custom-node
description String No Component description, a brief explanation of the component's functionality to help users understand its purpose.
relationTypes Array No Allowed relationship types with the next component. ["Success","Failure"]
author String No Author.
version String No Version.
inputSchema JSON Schema No Component parameter configuration definition, defines the structure of the component's input parameters, follows the JSON Schema format, specifies parameter types, titles, default values, etc. See the inputSchema table

inputSchema: If the component parameter configuration does not exist, the system automatically generates it by scanning ${vars.fieldName}.

inputSchema Object

Field Name Type Required Description Example Value
type String Yes Parameter type, specifies the parameter type, supports number, string, bool, object, array, etc. "number"
properties Object No Parameter properties, defines the specific attributes of each parameter. See the properties table

properties Object

Field Name Type Required Description Example Value
type String No Parameter type, specifies the type of this parameter. "number"
title String No Parameter title, the display name of the parameter. "Conversion Factor"
default Number No Parameter default value, the default value of the parameter. 1.8

# 2. Implement Component Logic through Orchestration and Combination of Existing Components:

Implement component logic by combining and orchestrating existing components through metadata.nodes and metadata.connections (the same as implementing rule chain logic).

# 3. Register the Component DSL with the Engine:

// Define a component through DSL:
// componentType: Component type identifier, used to uniquely identify the component type. Rule chains use this identifier to utilize the component.
// dsl: Component DSL
dynamicNode := NewDynamicNode(componentType, dsl)
Registry.Register(dynamicNode)
1
2
3
4
5

# 4. Use the Component in Rule Chains:

{
	"ruleChain": {
		"id": "9ehrY6tXl3y6",
		"name": "Test Dynamic Component",
		"debugMode": false,
		"root": false,
		"disabled": false,
		"additionalInfo": {
			"createTime": "2025/03/26 15:42:39",
			"layoutX": "280",
			"layoutY": "280",
			"updateTime": "2025/03/26 15:42:39",
			"username": "admin"
		}
	},
	"metadata": {
		"endpoints": [],
		"nodes": [
			{
				"id": "node_2",
				"additionalInfo": {
					"layoutX": 610,
					"layoutY": 250
				},
				"type": "dataTransform",
				"name": "Convert Temperature",
				"debugMode": false,
				"configuration": {
					"scaleFactor": 1.8
				}
			},
			{
				"id": "node_4",
				"additionalInfo": {
					"layoutX": 920,
					"layoutY": 260
				},
				"type": "log",
				"name": "Print Log",
				"debugMode": false,
				"configuration": {
					"jsScript": "return 'Incoming message:\\n' + JSON.stringify(msg) + '\\nIncoming metadata:\\n' + JSON.stringify(metadata);"
				}
			}
		],
		"connections": [
			{
				"fromId": "node_2",
				"toId": "node_4",
				"type": "Success"
			}
		]
	}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
Edit this page on GitHub (opens new window)
Last Updated: 2025/04/02, 01:29:50
Custom Components Overview
Dynamic Component Installation

← Custom Components Overview Dynamic Component Installation→

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

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