Component Visual Configuration
Custom components define visual forms through Config struct tags. The visual editor (RuleGo-Editor) automatically renders the component configuration UI based on these tags.
# Optional Interfaces
Besides the core Node interface, components can implement the following optional interfaces to provide additional information:
# ComponentDefGetter — Custom Form Definition
Overrides the auto-generated component form configuration. Non-empty fields in the return value override the auto-generated values:
type ComponentDefGetter interface {
Def() ComponentForm
}
2
3
Example — custom description and relation types:
func (x *MyNode) Def() types.ComponentForm {
relationTypes := &[]string{types.Success, types.Failure, types.True, types.False}
return types.ComponentForm{
Label: "My Component",
Desc: "This is a custom component",
RelationTypes: relationTypes,
}
}
2
3
4
5
6
7
8
# CategoryGetter — Custom Category
type CategoryGetter interface {
Category() string
}
2
3
# DescGetter — Custom Description
type DescGetter interface {
Desc() string
}
2
3
# Config Struct Tags
Custom component Config structs support the following tags for visual editor form rendering:
| Tag | Description | Example |
|---|---|---|
json | Field name | json:"delayMs" |
label | Display name | label:"Delay (ms)" |
desc | Field description | desc:"Delay time in milliseconds" |
required | Whether required | required:"true" |
component | UI component type | component:"{\"type\":\"select\",\"options\":[...]}" |
ref | Shared node association | ref:"primary" |
# component tag examples
Dropdown select:
RequestMethod string `json:"requestMethod" label:"Request Method"
component:"{\"type\":\"select\",\"options\":[{\"label\":\"GET\",\"value\":\"GET\"},{\"label\":\"POST\",\"value\":\"POST\"}]}"`
2
Code editor:
JsScript string `json:"jsScript" label:"Script"
component:"{\"type\":\"codeEditor\",\"language\":\"javascript\"}"`
2
# Shared Node Pool (SharedNode)
For components that need shared connections or resources (such as MQTT clients, database connection pools), you can use the shared node pool pattern. Multiple rule nodes reuse the same underlying connection instance, avoiding repeated creation.
Use the ref tag in the Config struct to identify the relationship between fields and the shared node:
type MqttClientNodeConfiguration struct {
Server string `json:"server" label:"Server Address" required:"true" ref:"primary"` // Reference field
Username string `json:"username" label:"Username" ref:"shared"` // Provided by shared node
Password string `json:"password" label:"Password" ref:"shared"` // Provided by shared node
Topic string `json:"topic" label:"Topic" required:"true"` // Component's own field
}
2
3
4
5
6
ref:"primary"— The identifier field for theref://reference addressref:"shared"— Configuration field provided by the shared node, hidden when using references- No
ref— Component's own business field, always displayed
# Related Documentation
- Component Form Conventions — Complete form generation rules and endpoint component conventions
- Get Component Configuration Form — ComponentForm and ComponentFormField complete field reference
- Custom Components Overview — Component interfaces and development guide