external

package
v0.20.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SELECT = "SELECT"
	INSERT = "INSERT"
	DELETE = "DELETE"
	UPDATE = "UPDATE"
)
View Source
const EndSign = '\n'

EndSign 结束符

Variables

View Source
var (
	SshConfigEmptyErr   = errors.New("ssh config can not empty")
	SshClientNotInitErr = errors.New("ssh client not initialized")
	SshCmdEmptyErr      = errors.New("cmd can not empty")
)
View Source
var MqttClientNotInitErr = errors.New("mqtt client not initialized")

MqttClientNotInitErr mqttClient 未初始化错误

View Source
var NetNotInitErr = errors.New("net not init error")

NetNotInitErr net 未初始化错误

Functions

func NewHttpClient

func NewHttpClient(config RestApiCallNodeConfiguration) *http.Client

Types

type DbClientNode

type DbClientNode struct {
	//节点配置
	Config DbClientNodeConfiguration
	// contains filtered or unexported fields
}

func (*DbClientNode) Destroy

func (x *DbClientNode) Destroy()

Destroy 销毁组件

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 处理消息

func (*DbClientNode) Type

func (x *DbClientNode) Type() string

Type 返回组件类型

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 邮件消息体

func (*Email) SendEmail

func (e *Email) SendEmail(addr string, auth smtp.Auth, metadata map[string]string, connectTimeout time.Duration) error

func (*Email) SendEmailWithTls

func (e *Email) SendEmailWithTls(addr string, auth smtp.Auth, metadata map[string]string, connectTimeout time.Duration) error

type MqttClientNode

type MqttClientNode struct {
	//节点配置
	Config MqttClientNodeConfiguration
	// contains filtered or unexported fields
}

func (*MqttClientNode) Destroy

func (x *MqttClientNode) Destroy()

Destroy 销毁

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 处理消息

func (*MqttClientNode) Type

func (x *MqttClientNode) Type() string

Type 组件类型

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'

func (*NetNode) Destroy added in v0.17.0

func (x *NetNode) Destroy()

Destroy 销毁

func (*NetNode) Init added in v0.17.0

func (x *NetNode) Init(ruleConfig types.Config, configuration types.Configuration) error

Init 初始化

func (*NetNode) New added in v0.17.0

func (x *NetNode) New() types.Node

func (*NetNode) OnMsg added in v0.17.0

func (x *NetNode) OnMsg(ctx types.RuleContext, msg types.RuleMsg)

OnMsg 处理消息

func (*NetNode) Printf added in v0.17.0

func (x *NetNode) Printf(format string, v ...interface{})

func (*NetNode) Type added in v0.17.0

func (x *NetNode) Type() string

Type 组件类型

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) Destroy

func (x *RestApiCallNode) Destroy()

Destroy 销毁

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 处理消息

func (*RestApiCallNode) Type

func (x *RestApiCallNode) Type() string

Type 组件类型

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) Destroy

func (x *SendEmailNode) Destroy()

Destroy 销毁

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 处理消息

func (*SendEmailNode) Type

func (x *SendEmailNode) Type() string

Type 组件类型

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

func (*SshNode) Destroy

func (x *SshNode) Destroy()

Destroy 方法用来销毁组件,做一些资源释放操作

func (*SshNode) Init

func (x *SshNode) Init(ruleConfig types.Config, configuration types.Configuration) error

Init 方法用来初始化组件,一般做一些组件参数配置或者客户端初始化操作

func (*SshNode) New

func (x *SshNode) New() types.Node

New 方法用来创建一个 SshNode 的新实例

func (*SshNode) OnMsg

func (x *SshNode) OnMsg(ctx types.RuleContext, msg types.RuleMsg)

OnMsg 方法用来处理消息,每条流入组件的数据会经过该函数处理

func (*SshNode) Type

func (x *SshNode) Type() string

Type 方法用来返回组件的类型

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL