Please wait for the administrator to review and you will receive a system notification when the review is complete
rulego-components是RuleGo 规则引擎扩展组件库。
RuleGo IoT 场景扩展组件库
RuleGo ETL相关组件
RuleGo CI/CD 场景扩展组件库
RuleGo AI 场景扩展组件库
English| 简体中文
Official Website | Docs | Contribution Guide
RuleGo
is a lightweight, high-performance, embedded, orchestrable component-based rule engine built on the Go language.
It can help you quickly build loosely coupled and flexible systems that can respond and adjust to changes in business requirements in real time.
RuleGo
also provides a large number of reusable components that support the aggregation, filtering, distribution, transformation, enrichment, and execution of various actions on data, and can also interact and integrate with various protocols and systems.
It has a wide range of application potential in low-code, business code orchestration, data integration, workflows, large model intelligent agents, edge computing, automation, IoT, and other scenarios.
RuleGo
into existing applications. It can also be deployed independently as middleware, providing rule engine and orchestration services.Message Type Switch
, JavaScript Switch
, JavaScript Filter
, JavaScript Transformer
, HTTP Push
, MQTT Push
, Send Email
, Log Recording
, etc. Other components can be extended as needed.HTTP Endpoint
, MQTT Endpoint
, TCP/UDP Endpoint
, UDP Endpoint
, Kafka Endpoint
, Schedule Endpoint
, etc.RuleGo
is an orchestrable rule engine that excels at decoupling your systems.
RuleGo Architecture Diagram
Install RuleGo
using the go get
command:
go get github.com/rulego/rulego
# or
go get gitee.com/rulego/rulego
RuleGo
is extremely simple to use. Just follow these 3 steps:
Define rule chains using JSON:
Import the RuleGo package and use the rule chain definition to create a rule engine instance:
import "github.com/rulego/rulego"
//Load the rule chain definition file.
ruleFile := fs.LoadFile("chain_call_rest_api.json")
// Create a rule engine instance using the rule chain definition
ruleEngine, err := rulego.New("rule01", ruleFile)
// Define message metadata
metaData := types.NewMetadata()
metaData.PutValue("productType", "test01")
// Define message payload and message type
msg := types.NewMsg(0, "TELEMETRY_MSG", types.JSON, metaData, "{\"temperature\":35}")
// Hand over the message to the rule engine for processing
ruleEngine.OnMsg(msg)
Real time update of rule chain logic without restarting the application
// Dynamically update rule chain logic
err := ruleEngine.ReloadSelf(ruleFile)
// Update a node under the rule chain
ruleEngine.ReloadChild("node01", nodeFile)
// Get the rule chain definition
ruleEngine.DSL()
// Load all rule chain definitions in a folder into the rule engine pool
rulego.Load("/rules", rulego.WithConfig(config))
// Get an already created rule engine instance by ID
ruleEngine, ok := rulego.Get("rule01")
// Delete an already created rule engine instance
rulego.Del("rule01")
// Create a default configuration
config := rulego.NewConfig()
// Debug node callback, the node configuration must be set to debugMode:true to trigger the call
// Both node entry and exit information will call this callback function
config.OnDebug = func (chainId,flowType string, nodeId string, msg types.RuleMsg, relationType string, err error) {
}
// Use the configuration
ruleEngine, err := rulego.New("rule01", []byte(ruleFile), rulego.WithConfig(config))
The core feature of RuleGo
is its component-based architecture, where all business logic is encapsulated in components that can be flexibly configured and reused. Currently,
RuleGo
has built-in a vast array of commonly used components.
RuleGo
provides the Endpoint module for unified data integration and processing of heterogeneous systems. For details, refer to: Endpoint
We provide a ready-to-use rule engine service based on RuleGo
: RuleGo-Server ,
and a front-end visual editor: RuleGo-Editor .
RuleGo-Server can be deployed as a standalone middleware, offering operations such as rule chain management, debugging, deployment, and node component management.
RuleGo
completes most of its work during initialization, so running the rule chain almost doesn't add extra overhead to the system, and the resource consumption is extremely low, making it particularly suitable for running on edge servers.
Additionally, RuleGo uses Directed Acyclic Graph (DAG) to represent the rule chain, where each input message only needs to be processed along the path in the graph without matching all the rules, which greatly improves the efficiency of message processing and routing, and also saves system resources.
Performance test cases:
Machine: Raspberry Pi 2 (900MHz Cortex-A7*4,1GB LPDDR2)
Data size: 260B
Rule chain: JS script filtering->JS complex transformation->HTTP push
Test results: 100 concurrent and 500 concurrent, memory consumption does not change much around 19M
Any form of contribution is welcome, including submitting issues, suggestions, documentation, tests or code. Contribution Guide
RuleGo
uses Apache 2.0 license, please refer to LICENSE file for details.