pluginmanager

package
v0.0.0-...-8bbe05f Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NORMAL_REPORT = 0
	LAZY_REPORT   = 1 // 懒上报

	// 限制上报时插件名和插件版本字段的长度
	PLUGIN_NAME_MAXLEN    = 255
	PLUGIN_VERSION_MAXLEN = 32
)
View Source
const (
	// PluginOneTime 一次性插件
	PLUGIN_ONCE     string = "Once"
	PLUGIN_ONCE_INT int    = 0
	// PluginPersist 常驻型插件
	PLUGIN_PERSIST     string = "Persist"
	PLUGIN_PERSIST_INT int    = 1
	// Commander 云助手组件
	PLUGIN_COMMANDER     string = "Commander"
	PLUGIN_COMMANDER_INT        = 2
	// PluginUnknown 未知类型
	PLUGIN_UNKNOWN     string = "Unknown"
	PLUGIN_UNKNOWN_INT int    = -1
)

插件类型

Variables

View Source
var (
	LocalManager pluginmodel.LocalManager = &ShimManager{}
)
View Source
var (
	NEED_REFRESH_STATUS_API []string = []string{"--install", "--uninstall", "--start", "--stop", "--upgrade", "--restart"}
)

调用一下接口后需要主动向服务端上报插件状态

Functions

func GetArch

func GetArch() (formatArch string, rawArch string)

func InitPluginCheckTimer

func InitPluginCheckTimer()

func SetUpdateHandler

func SetUpdateHandler(h UpdateHandler)

Types

type CommanderInfo

type CommanderInfo struct {
	PidFile      string `json:"pidFile"`
	EndpointType string `json:"endpointType"`
	EndpointFile string `json:"endpointFile"`
	ApiVersion   string `json:"apiVersion"`
}

type InstalledPlugins

type InstalledPlugins struct {
	// contains filtered or unexported fields
}

func LoadInstalledPlugins

func LoadInstalledPlugins() (*InstalledPlugins, error)

func LoadPreInstalledPlugins

func LoadPreInstalledPlugins() (*InstalledPlugins, error)

func (*InstalledPlugins) Close

func (ip *InstalledPlugins) Close() error

Close can be called multiple times and internal implementation in bbolt would keep it safe. Thus close the database as soon as possible please.

func (*InstalledPlugins) DeleteByKey

func (ip *InstalledPlugins) DeleteByKey(key int) (err error)

func (*InstalledPlugins) FindAll

func (ip *InstalledPlugins) FindAll() (keys []int, values []PluginInfo, err error)

func (*InstalledPlugins) FindManyByName

func (ip *InstalledPlugins) FindManyByName(name string) ([]int, []PluginInfo, error)

func (*InstalledPlugins) FindOneWithPredicate

func (ip *InstalledPlugins) FindOneWithPredicate(predicate func(plugin *PluginInfo) bool) (foundKey int, foundValue *PluginInfo, err error)

func (*InstalledPlugins) Insert

func (ip *InstalledPlugins) Insert(value *PluginInfo) (insertedKey int, err error)

func (*InstalledPlugins) Update

func (ip *InstalledPlugins) Update(key int, value *PluginInfo) (err error)

Update method simply stores new value to specified position in JSON array. Would PANIC if key is out of range.

type PluginInfo

type PluginInfo struct {
	PluginID       string      `json:"pluginId"`
	Name           string      `json:"name"`
	Arch           string      `json:"arch"`
	OSType         string      `json:"osType"`
	Version        string      `json:"version"`
	Publisher      string      `json:"publisher"`
	Url            string      `json:"url"`
	Md5            string      `json:"md5"`
	RunPath        string      `json:"runPath"`
	Timeout        string      `json:"timeout"`
	IsPreInstalled string      `json:"isPreInstalled"`
	PluginType_    interface{} `json:"pluginType"`

	HeartbeatInterval int           `json:"heartbeatInterval"`
	IsRemoved         bool          `json:"isRemoved"`
	AddSysTag         bool          `json:"addSysTag"`
	CommanderInfo     CommanderInfo `json:"commanderInfo"`
	// contains filtered or unexported fields
}

func FetchPackageInfo

func FetchPackageInfo(logger logrus.FieldLogger, pluginName string, version string, withArch bool) ([]PluginInfo, error)

get pluginInfo by name from online

func (*PluginInfo) PluginType

func (pi *PluginInfo) PluginType() string

func (*PluginInfo) SetPluginType

func (pi *PluginInfo) SetPluginType(pluginType string)

type PluginListRequest

type PluginListRequest struct {
	OsType     string `json:"osType"`
	PluginName string `json:"pluginName"`
	Version    string `json:"version"`
	PluginType string `json:"pluginType"`
	Arch       string `json:"arch"`
}

向服务端请求插件列表的接口数据

type PluginListResponse

type PluginListResponse struct {
	Code       int          `json:"code"`
	RequestId  string       `json:"requestId"`
	InstanceId string       `json:"instanceId"`
	PluginList []PluginInfo `json:"pluginList"`
}

type PluginStatusResponse

type PluginStatusResponse struct {
	InstanceId      string `json:"instanceId"`
	Code            int    `json:"code"`
	ScanInterval    int    `json:"scanInterval"`    // 下次Agent周期扫描插件状态的频率(兜底),单位秒
	PullInterval    int    `json:"pullInterval"`    // 下次Agent主动拉取插件状态的频率,单位秒
	RefreshInterval int    `json:"refreshInterval"` // 周期扫描到Failed状态的常驻插件后会拉起,在RefreshInterval间隔后上报插件状态
	ReportType      int    `json:"reportType"`      // 上报方式 0-正常上报;1-懒上报
}

状态上报的响应数据

type PluginStatusResquest

type PluginStatusResquest struct {
	Plugin []pluginmodel.PluginStatus `json:"plugin"`
}

状态上报的请求数据

type PluginUpdateCheck

type PluginUpdateCheck struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

PluginUpdateCheck 检查升级请求数据

type PluginUpdateCheckRequest

type PluginUpdateCheckRequest struct {
	Os     string              `json:"os"`
	Arch   string              `json:"arch"`
	Plugin []PluginUpdateCheck `json:"plugin"`
}

type PluginUpdateCheckResponse

type PluginUpdateCheckResponse struct {
	InstanceId   string             `json:"instanceId"`
	NextInterval int                `json:"nextInterval"`
	Plugin       []PluginUpdateInfo `json:"plugin"`
}

PluginUpdateCheckResp 检查升级的响应数据

type PluginUpdateInfo

type PluginUpdateInfo struct {
	Name    string `json:"name"`
	Version string `json:"version"`
	Timeout int    `json:"timeout"`
}

PluginUpdateInfo 升级插件的信息

type RemotePlugin

type RemotePlugin struct {
	// contains filtered or unexported fields
}

func (*RemotePlugin) Name

func (rp *RemotePlugin) Name() string

func (*RemotePlugin) TimeoutSecs

func (rp *RemotePlugin) TimeoutSecs() int

func (*RemotePlugin) Url

func (rp *RemotePlugin) Url() string

func (*RemotePlugin) Version

func (rp *RemotePlugin) Version() string

type ShimManager

type ShimManager struct{}

func (*ShimManager) FindInstalled

func (*ShimManager) FindInstalled(logger logrus.FieldLogger) ([]pluginmodel.LocalPlugin, error)

func (*ShimManager) FindUpgradable

func (*ShimManager) FindUpgradable(logger logrus.FieldLogger) ([]pluginmodel.LocalPlugin, error)

func (*ShimManager) HealthCheck

func (*ShimManager) Update

func (*ShimManager) Update(logger logrus.FieldLogger, target pluginmodel.RemotePlugin) error

type UpdateHandler

type UpdateHandler func(name, version string) bool

Directories

Path Synopsis
main command

Jump to

Keyboard shortcuts

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