Documentation
¶
Index ¶
- Constants
- Variables
- func NewHttpClient(config RestApiCallNodeConfiguration) *http.Client
- type DbClientNode
- type DbClientNodeConfiguration
- type Email
- type LogNode
- type LogNodeConfiguration
- type MqttClientNode
- type MqttClientNodeConfiguration
- type RestApiCallNode
- type RestApiCallNodeConfiguration
- type SendEmailConfiguration
- type SendEmailNode
Constants ¶
const ( SELECT = "SELECT" INSERT = "INSERT" DELETE = "DELETE" UPDATE = "UPDATE" )
Variables ¶
var Registry = &types.SafeComponentSlice{}
Functions ¶
func NewHttpClient ¶
func NewHttpClient(config RestApiCallNodeConfiguration) *http.Client
Types ¶
type DbClientNode ¶
type DbClientNode struct {
// contains filtered or unexported fields
}
func (*DbClientNode) Init ¶
func (x *DbClientNode) Init(ruleConfig types.Config, configuration types.Configuration) error
Init 初始化组件
func (*DbClientNode) New ¶
func (x *DbClientNode) New() types.Node
func (*DbClientNode) OnMsg ¶
func (x *DbClientNode) OnMsg(ctx types.RuleContext, msg types.RuleMsg) error
OnMsg 处理消息
type DbClientNodeConfiguration ¶
type DbClientNodeConfiguration struct {
// Sql 操作语句,可以使用${}占位符
Sql string
// Params 操作参数,可以是数组或对象
Params []interface{}
// GetOne 是否只返回一条记录,返回结构非slice结构
GetOne bool
// PoolSize 连接池大小
PoolSize int
// DbType 数据库类型,mysql或postgres
DbType string
// Dsn 数据库连接配置,参考sql.Open参数
Dsn string
}
DbClientNodeConfiguration 节点配置
type Email ¶
type Email struct {
//From 发件人
From string
//To 收件人,多个与`,`隔开
To string
//Cc 抄送人,多个与`,`隔开
Cc string
//Bcc 密送人,多个与`,`隔开
Bcc string
//Subject 邮件主题,可以使用 ${metaKeyName} 替换元数据中的变量
Subject string
//Body 邮件模板,可以使用 ${metaKeyName} 替换元数据中的变量
Body string
}
Email 邮件消息体
type LogNode ¶
type LogNode struct {
// contains filtered or unexported fields
}
LogNode 使用JS脚本将传入消息转换为字符串,并将最终值记录到日志文件中 使用`types.Config.Logger`记录日志 消息体可以通过`msg`变量访问,msg 是string类型。例如:`return msg.temperature > 50;` 消息元数据可以通过`metadata`变量访问。例如 `metadata.customerName === 'Lala';` 消息类型可以通过`msgType`变量访问. 脚本执行成功,发送信息到`Success`链, 否则发到`Failure`链。
type LogNodeConfiguration ¶
type LogNodeConfiguration struct {
//JsScript 只配置函数体脚本内容,对消息进行格式化,脚本返回值string
//例如
//return 'Incoming message:\n' + JSON.stringify(msg) + '\nIncoming metadata:\n' + JSON.stringify(metadata);
//完整脚本函数:
//"function ToString(msg, metadata, msgType) { ${JsScript} }"
//脚本返回值string
JsScript string
}
LogNodeConfiguration 节点配置
type MqttClientNode ¶
type MqttClientNode struct {
// contains filtered or unexported fields
}
func (*MqttClientNode) Init ¶
func (x *MqttClientNode) Init(ruleConfig types.Config, configuration types.Configuration) error
Init 初始化
func (*MqttClientNode) New ¶
func (x *MqttClientNode) New() types.Node
func (*MqttClientNode) OnMsg ¶
func (x *MqttClientNode) OnMsg(ctx types.RuleContext, msg types.RuleMsg) error
OnMsg 处理消息
type MqttClientNodeConfiguration ¶
type MqttClientNodeConfiguration struct {
//publish topic
Topic string
Server string
Username string
Password string
MaxReconnectInterval time.Duration
QOS uint8
CleanSession bool
ClientID string
CAFile string
CertFile string
CertKeyFile string
}
func (*MqttClientNodeConfiguration) ToMqttConfig ¶
func (x *MqttClientNodeConfiguration) ToMqttConfig() mqtt.Config
type RestApiCallNode ¶
type RestApiCallNode struct {
// contains filtered or unexported fields
}
RestApiCallNode 将通过REST API调用<code> GET | POST | PUT | DELETE </ code>到外部REST服务。 如果请求成功,把HTTP响应消息发送到`Success`链, 否则发到`Failure`链, metaData.status记录响应错误码和metaData.errorBody记录错误信息。
func (*RestApiCallNode) Init ¶
func (x *RestApiCallNode) Init(ruleConfig types.Config, configuration types.Configuration) error
Init 初始化
func (*RestApiCallNode) New ¶
func (x *RestApiCallNode) New() types.Node
func (*RestApiCallNode) OnMsg ¶
func (x *RestApiCallNode) OnMsg(ctx types.RuleContext, msg types.RuleMsg) error
OnMsg 处理消息
type RestApiCallNodeConfiguration ¶
type RestApiCallNodeConfiguration struct {
//RestEndpointUrlPattern HTTP URL地址目标,可以使用 ${metaKeyName} 替换元数据中的变量
RestEndpointUrlPattern string
//RequestMethod 请求方法
RequestMethod string
//Headers 请求头,可以使用 ${metaKeyName} 替换元数据中的变量
Headers map[string]string
//ReadTimeoutMs 超时,单位毫秒
ReadTimeoutMs int
//MaxParallelRequestsCount 连接池大小,默认200
MaxParallelRequestsCount int
//EnableProxy 是否开启代理
EnableProxy bool
//UseSystemProxyProperties 使用系统配置代理
UseSystemProxyProperties bool
//ProxyHost 代理主机
ProxyHost string
//ProxyPort 代理端口
ProxyPort int
//ProxyUser 代理用户名
ProxyUser string
//ProxyPassword 代理密码
ProxyPassword string
//ProxyScheme
ProxyScheme string
}
RestApiCallNodeConfiguration rest配置
type SendEmailConfiguration ¶
type SendEmailConfiguration struct {
//SmtpHost Smtp主机地址
SmtpHost string
//SmtpPort Smtp端口
SmtpPort int
//Username 用户名
Username string
//Password 密码
Password string
//EnableTls 是否是使用tls方式
EnableTls bool
//Email 邮件内容配置
Email Email
}
SendEmailConfiguration 配置
type SendEmailNode ¶
type SendEmailNode struct {
// contains filtered or unexported fields
}
SendEmailNode 通过SMTP服务器发送邮消息 如果请求成功,发送消息到`Success`链, 否则发到`Failure`链,
func (*SendEmailNode) Init ¶
func (x *SendEmailNode) Init(ruleConfig types.Config, configuration types.Configuration) error
Init 初始化
func (*SendEmailNode) New ¶
func (x *SendEmailNode) New() types.Node
func (*SendEmailNode) OnMsg ¶
func (x *SendEmailNode) OnMsg(ctx types.RuleContext, msg types.RuleMsg) error
OnMsg 处理消息