扩展组件概述
RuleGo除了提供标准组件外,还提供了丰富的扩展组件库rulego-components
,项目地址:Github (opens new window) | Gitee (opens new window)。
扩展组件需要额外手动导入使用。RuleGo生态或第三方提供的组件也采用相同的导入方式。
# 使用方法
- 使用
go get
命令安装所需的扩展组件: - 注册组件:
//如果组件在init有注册逻辑,则只需引入该组件,触发其init函数即可
import (
// 注册扩展组件库
// 使用`go build -tags with_extend .`把扩展组件编译到运行文件
_ "github.com/rulego/rulego-components/endpoint/beanstalkd"
_ "github.com/rulego/rulego-components/endpoint/grpc_stream"
_ "github.com/rulego/rulego-components/endpoint/kafka"
_ "github.com/rulego/rulego-components/external/mongodb"
_ "github.com/rulego/rulego-components/external/nats"
)
//否则手动注册
rulego.Registry.Register(&xx{})
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
- 然后在规则链,通过配置
type
和configuration
使用组件:
{
"id": "s5",
"type": "x/redisClient",
"name": "保存到redis",
"debugMode": true,
"configuration": {
"cmd": "SET",
"params": ["${key}", "${msg.data}"],
"poolSize": 10,
"Server": "192.168.1.1:6379"
}
}
1
2
3
4
5
6
7
8
9
10
11
12
2
3
4
5
6
7
8
9
10
11
12
# 其他扩展组件
- rulego-components (opens new window)
- rulego-components-ai (opens new window)
- rulego-components-ci (opens new window)
- rulego-components-iot (opens new window)
- rulego-components-etl (opens new window)
# 贡献组件
RuleGo采用组件化架构设计,所有业务逻辑都以组件形式实现,并支持灵活配置和重用。虽然RuleGo已内置了大量常用组件,但为了满足更多样化的业务需求,我们欢迎开发者为RuleGo贡献更多扩展组件,共同打造丰富和强大的RuleGo生态。
贡献组件时请遵循以下原则:
- 如果组件代码没有第三方依赖或属于通用性组件,请提交到主库的标准组件目录:components (opens new window)
- 如果组件依赖第三方库或为特定场景定制,请提交到扩展组件仓库:rulego-components (opens new window)
- 如果组件为物联网场景定制,请提交到扩展组件仓库:rulego-components-iot (opens new window)
- 如果组件为ETL场景定制,请提交到扩展组件仓库:rulego-components-etl (opens new window)
- 如果组件为CI/CD场景定制,请提交到扩展组件仓库:rulego-components-ci (opens new window)
- 如果组件为AI场景定制,请提交到扩展组件仓库:rulego-components-ai (opens new window)
在 GitHub 上编辑此页 (opens new window)
上次更新: 2025/03/05, 08:52:48