Documentation ¶
Index ¶
- Constants
- Variables
- func NewHttpClient(config RestApiCallNodeConfiguration) *http.Client
- type DbClientNode
- type DbClientNodeConfiguration
- type Email
- type MqttClientNode
- type MqttClientNodeConfiguration
- type NetNode
- func (x *NetNode) Destroy()
- func (x *NetNode) Init(ruleConfig types.Config, configuration types.Configuration) error
- func (x *NetNode) New() types.Node
- func (x *NetNode) OnMsg(ctx types.RuleContext, msg types.RuleMsg)
- func (x *NetNode) Printf(format string, v ...interface{})
- func (x *NetNode) Type() string
- type NetNodeConfiguration
- type RestApiCallNode
- type RestApiCallNodeConfiguration
- type SendEmailConfiguration
- type SendEmailNode
- type SshConfiguration
- type SshNode
Constants ¶
const ( SELECT = "SELECT" INSERT = "INSERT" DELETE = "DELETE" UPDATE = "UPDATE" )
const EndSign = '\n'
EndSign 结束符
Variables ¶
var ( SshConfigEmptyErr = errors.New("ssh config can not empty") SshClientNotInitErr = errors.New("ssh client not initialized") SshCmdEmptyErr = errors.New("cmd can not empty") )
var MqttClientNotInitErr = errors.New("mqtt client not initialized")
MqttClientNotInitErr mqttClient 未初始化错误
var NetNotInitErr = errors.New("net not init error")
NetNotInitErr net 未初始化错误
var Registry = &types.SafeComponentSlice{}
Functions ¶
func NewHttpClient ¶
func NewHttpClient(config RestApiCallNodeConfiguration) *http.Client
Types ¶
type DbClientNode ¶
type DbClientNode struct { //节点配置 Config DbClientNodeConfiguration // 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)
OnMsg 处理消息
type DbClientNodeConfiguration ¶
type DbClientNodeConfiguration struct { // Sql SQL语句,可以使用${metaKeyName} 替换元数据中的变量 Sql string // Params SQL语句参数列表,可以使用${metaKeyName} 替换元数据中的变量 Params []interface{} // GetOne 是否只返回一条记录,true:返回结构不是数组结构,false:返回数据是数组结构 GetOne bool // PoolSize 连接池大小 PoolSize int // DriverName 数据库驱动名称,mysql或postgres DriverName 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 MqttClientNode ¶
type MqttClientNode struct { //节点配置 Config MqttClientNodeConfiguration // 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)
OnMsg 处理消息
type MqttClientNodeConfiguration ¶
type MqttClientNodeConfiguration struct { //publish topic Topic string Server string Username string Password string //MaxReconnectInterval 重连间隔 单位秒 MaxReconnectInterval int QOS uint8 CleanSession bool ClientID string CAFile string CertFile string CertKeyFile string }
func (*MqttClientNodeConfiguration) ToMqttConfig ¶
func (x *MqttClientNodeConfiguration) ToMqttConfig() mqtt.Config
type NetNode ¶ added in v0.17.0
type NetNode struct { // 节点配置 Config NetNodeConfiguration // contains filtered or unexported fields }
NetNode 用于网络协议的数据读取和发送,支持协议:tcp、udp、ip4:1、ip6:ipv6-icmp、ip6:58、unix、unixgram,以及net包支持的协议类型。 每条消息在内容最后增加结束符:'\n'
type NetNodeConfiguration ¶ added in v0.17.0
type NetNodeConfiguration struct { // 通信协议,可以是tcp、udp、ip4:1、ip6:ipv6-icmp、ip6:58、unix、unixgram,以及net包支持的协议类型。默认tcp协议 Protocol string // 服务器的地址,格式为host:port Server string // 连接超时,单位为秒,如果<=0 则默认60 ConnectTimeout int // 心跳间隔,用于定期发送心跳消息,单位为秒,如果<=0 则默认60 HeartbeatInterval int }
NetNodeConfiguration 组件的配置
type RestApiCallNode ¶
type RestApiCallNode struct { //节点配置 Config RestApiCallNodeConfiguration // contains filtered or unexported fields }
RestApiCallNode 将通过REST API调用GET | POST | PUT | DELETE到外部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)
OnMsg 处理消息
type RestApiCallNodeConfiguration ¶
type RestApiCallNodeConfiguration struct { //RestEndpointUrlPattern HTTP URL地址,可以使用 ${metaKeyName} 替换元数据中的变量 RestEndpointUrlPattern string //RequestMethod 请求方法,默认POST RequestMethod string // Without request body WithoutRequestBody bool //Headers 请求头,可以使用 ${metaKeyName} 替换元数据中的变量 Headers map[string]string //ReadTimeoutMs 超时,单位毫秒,默认0:不限制 ReadTimeoutMs int //MaxParallelRequestsCount 连接池大小,默认200。0代表不限制 MaxParallelRequestsCount int //EnableProxy 是否开启代理 EnableProxy bool //UseSystemProxyProperties 使用系统配置代理 UseSystemProxyProperties bool //ProxyScheme 代理协议 ProxyScheme string //ProxyHost 代理主机 ProxyHost string //ProxyPort 代理端口 ProxyPort int //ProxyUser 代理用户名 ProxyUser string //ProxyPassword 代理密码 ProxyPassword 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 //ConnectTimeout 连接超时,单位秒 ConnectTimeout int }
SendEmailConfiguration 配置
type SendEmailNode ¶
type SendEmailNode struct { //节点配置 Config SendEmailConfiguration ConnectTimeoutDuration time.Duration // 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)
OnMsg 处理消息
type SshConfiguration ¶
type SshConfiguration struct { //Host ssh 主机地址 Host string //Port ssh 主机端口 Port int //Username ssh登录用户名 Username string //Password ssh登录密码 Password string //Cmd shell命令,可以使用 ${metaKeyName} 替换元数据中的变量 Cmd string }
SshConfiguration 配置
type SshNode ¶
type SshNode struct { //节点配置 Config SshConfiguration // contains filtered or unexported fields }
SshNode shell 组件 通过ssh协议执行远程shell脚本 脚本执行结果返回到msg,交给下一个节点 DataType 会强制转成TEXT