agent

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2022 License: MIT Imports: 20 Imported by: 0

README

libagent

libagent license Go Report Card go-mod

agent封装类库,用于快速开发agent

开发方式

待补充

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterService

func RegisterService(app App) error

RegisterService 注册系统服务

func Run

func Run(app App) error

Run 运行agent

func UnregisterService

func UnregisterService(app App) error

UnregisterService 卸载系统服务

Types

type App

type App interface {
	// 获取当前agent名称
	AgentName() string
	// 获取当前agent版本号
	Version() string
	// 获取配置文件路径
	ConfDir() string
	// 获取libagent所需配置
	// 该对象必须是一个相对全局作用域的变量,在后续执行过程中该变量将会被更新
	Configure() *conf.Configure

	// 重置配置文件时的回调函数,在以下情况下会回调
	//   - 连接成功后服务端分配了新的agent id
	OnRewriteConfigure() error
	// 连接成功后的回调函数
	OnConnect()
	// 断开连接时的回调函数
	OnDisconnect()
	// 触发上报监控信息时的回调函数,该回调一般被用来上报一些自定义监控数据
	OnReportMonitor()
	// 收到数据包时的回调函数
	OnMessage(*anet.Msg) error

	// 返回数据包时的回调函数,该函数必须是一个循环,
	// 且在有数据需要返回时将其放入第二个参数中的队列内
	LoopWrite(context.Context, chan *anet.Msg) error
}

App app 接口,每一个agent必须实现以下接口

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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