RuleGo RuleGo
🏠首页
  • 快速入门
  • 规则链
  • 标准组件
  • 扩展组件
  • 自定义组件
  • 可视化
  • RuleGo-Server
  • RuleGo-MCP-Server
  • AOP
  • 触发器
  • 高级主题
  • 性能
  • 标准组件
  • 扩展组件
  • 自定义组件
  • 组件市场
  • 概述
  • 快速入门
  • 路由
  • DSL
  • API
  • Options
  • 组件
🔥编辑器 (opens new window)
  • 可视化编辑器 (opens new window)
  • RuleGo-Server (opens new window)
  • ❓问答

    • FAQ
💖支持
👥加入社区
  • Github (opens new window)
  • Gitee (opens new window)
  • GitCode (opens new window)
  • 更新日志 (opens new window)
  • English
  • 简体中文
🏠首页
  • 快速入门
  • 规则链
  • 标准组件
  • 扩展组件
  • 自定义组件
  • 可视化
  • RuleGo-Server
  • RuleGo-MCP-Server
  • AOP
  • 触发器
  • 高级主题
  • 性能
  • 标准组件
  • 扩展组件
  • 自定义组件
  • 组件市场
  • 概述
  • 快速入门
  • 路由
  • DSL
  • API
  • Options
  • 组件
🔥编辑器 (opens new window)
  • 可视化编辑器 (opens new window)
  • RuleGo-Server (opens new window)
  • ❓问答

    • FAQ
💖支持
👥加入社区
  • Github (opens new window)
  • Gitee (opens new window)
  • GitCode (opens new window)
  • 更新日志 (opens new window)
  • English
  • 简体中文

广告采用随机轮播方式显示 ❤️成为赞助商
  • 快速入门

  • 规则链

  • 标准组件

    • 标准组件概述
    • 过滤器

    • 动作

      • 记录日志
      • 函数处理
      • 延迟
      • 节点组
        • 配置
        • Relation Type
        • 执行结果
        • 配置示例
      • 迭代器
      • 遍历
      • 命令
      • 汇聚
    • 转换器

    • 外部的

    • 流

  • 扩展组件

  • 自定义组件

  • 组件市场

  • 可视化

  • AOP

  • 触发器

  • 高级主题

  • RuleGo-Server

  • 问题

目录

节点组

groupAction组件:节点组。用于将多个节点组成一个分组,异步并行执行所有节点,等待所有节点执行完成后,合并执行结果并发送到下一个节点。类似于子规则链的功能。

组件工作原理:

  1. 接收到消息后,并行执行组内所有节点
  2. 等待所有节点执行完成或超时
  3. 合并所有节点的执行结果(metadata和data)
  4. 根据匹配条件(matchNum和matchRelationType)决定路由方向:
    • 如果满足匹配条件,通过Success链路由
    • 否则通过Failure链路由

# 配置

字段 类型 必填 说明 默认值
nodeIds []string 是 组内节点ID列表 -
matchRelationType string 否 匹配的节点关系类型 Success
matchNum int 否 需要匹配的节点数量 0
timeout int 否 执行超时时间(秒),0表示不设置超时 0

matchNum说明:

  • 默认为0:表示要求所有节点都满足matchRelationType指定的关系类型
  • 大于0:表示只要有matchNum个节点满足matchRelationType指定的关系类型即可
  • 大于等于节点总数:等价于matchNum=0的情况

# Relation Type

  • Success: 满足匹配条件时,消息发送到Success链路
  • Failure: 以下情况消息发送到Failure链路:
    • nodeIds为空
    • 执行超时
    • 不满足匹配条件
    • 节点执行出错

# 执行结果

组件会合并所有节点的执行结果:

  • metadata: 合并所有节点的metadata,相同key时后执行的节点会覆盖先执行节点的值
  • data: 将所有节点处理后的消息封装成WrapperMsg数组

WrapperMsg结构:

字段 类型 说明 默认值
msg types.RuleMsg 节点处理后的消息 无
err string 错误信息 ""
nodeId string 最后处理该消息的节点 ""

# 配置示例

//注意:规则链从第三个节点开始触发。firstNodeIndex=2
{
  "ruleChain": {
    "id": "rule01",
    "name": "测试规则链",
    "root": true
  },
  "metadata": {
    "firstNodeIndex": 2,
    "nodes": [
      {
        "id": "s1",
        "type": "functions",
        "name": "组件1",
        "debugMode": true,
        "configuration": {
          "functionName": "groupActionTest1"
        }
      },
      {
        "id": "s2",
        "type": "functions",
        "name": "组件2",
        "debugMode": true,
        "configuration": {
          "functionName": "groupActionTest2"
        }
      },
      {
        "id": "group1",
        "type": "groupAction",
        "name": "action组",
        "debugMode": true,
        "configuration": {
          "matchRelationType": "Success",
          "nodeIds": "s1,s2"
        }
      },
      {
        "id": "s3",
        "type": "log",
        "name": "记录日志",
        "debugMode": false,
        "configuration": {
          "jsScript": "return msg;"
        }
      }
    ],
    "connections": [
      {
        "fromId": "group1",
        "toId": "s3",
        "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
55
56
57
在 GitHub 上编辑此页 (opens new window)
上次更新: 2025/04/02, 01:29:50
延迟
迭代器

← 延迟 迭代器→

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

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