eventhandler

package
v0.26.6 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Metadata = plugins.Module{
	Meta: plugins.Meta{
		Name:        modules.PluginNameEventHandler,
		Title:       "事件转发插件",
		Version:     "1.0.0",
		Description: "K8s 事件采集、规则过滤与Webhook转发。启用选举插件后,只有主实例执行,否则每个实例都执行。",
	},
	Tables: []string{
		"k8s_event_configs",
		"k8s_events",
		"eventhandler_event_forward_settings",
	},
	Menus: []plugins.Menu{
		{
			Key:   "plugin_eventhandler_index",
			Title: "事件转发插件",
			Icon:  "fa-solid fa-bell",
			Order: 60,
			Children: []plugins.Menu{
				{
					Key:         "plugin_eventhandler_setting",
					Title:       "事件转发参数",
					Icon:        "fa-solid fa-sliders",
					Show:        "isPlatformAdmin()==true",
					EventType:   "custom",
					CustomEvent: `() => loadJsonPage("/plugins/eventhandler/setting")`,
					Order:       90,
				},
				{
					Key:         "plugin_eventhandler_admin",
					Title:       "事件转发规则",
					Icon:        "fa-solid fa-plug-circle-bolt",
					Show:        "isPlatformAdmin()==true",
					EventType:   "custom",
					CustomEvent: `() => loadJsonPage("/plugins/eventhandler/admin")`,
					Order:       100,
				},
			},
		},
	},
	Dependencies: []string{
		modules.PluginNameWebhook,
	},
	RunAfter:          []string{modules.PluginNameLeader},
	Lifecycle:         &EventHandlerLifecycle{},
	PluginAdminRouter: route.RegisterPluginAdminRoutes,
}

Functions

func StartEventForwarding

func StartEventForwarding() error

StartEventForwarding 中文函数注释:读取平台配置,仅在开启总开关时启动 Watcher 与 Worker;若已运行则跳过。

func StartEventForwardingWatch

func StartEventForwardingWatch()

StartEventForwardingWatch 中文函数注释:设置一个定时器,后台不断更新事件转发配置,保持与平台配置一致。

func StartLeaderWatch

func StartLeaderWatch()

StartLeaderWatch 中文函数注释:启动主备状态监听,根据主节点状态启停事件转发。

func StopEventForwarding

func StopEventForwarding()

StopEventForwarding 中文函数注释:停止当前运行的 Watcher 与 Worker,并清理内部引用。

func StopEventForwardingWatch

func StopEventForwardingWatch()

StopEventForwardingWatch 中文函数注释:优雅停止定时任务,避免重复任务或资源泄漏。

func StopLeaderWatch

func StopLeaderWatch()

StopLeaderWatch 中文函数注释:停止主备状态监听,并停止事件转发。

func SyncEventForwardingFromConfig

func SyncEventForwardingFromConfig()

SyncEventForwardingFromConfig 中文函数注释:每次调用均读取数据库最新配置;若开关或参数变化,则执行启停或更新,保持与平台配置一致。

Types

type EventHandlerLifecycle

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

EventHandlerLifecycle 中文函数注释:事件转发插件生命周期实现。

func (*EventHandlerLifecycle) Disable

Disable 中文函数注释:禁用事件转发插件,停止后台任务与事件转发。

func (*EventHandlerLifecycle) Enable

Enable 中文函数注释:启用事件转发插件,确保数据库表存在。

func (*EventHandlerLifecycle) Install

Install 中文函数注释:安装事件转发插件,初始化数据库表结构。

func (*EventHandlerLifecycle) Start

Start 中文函数注释:启动事件转发插件后台任务(不可阻塞),按主备状态控制事件转发启停。

func (*EventHandlerLifecycle) StartCron

func (l *EventHandlerLifecycle) StartCron(ctx plugins.BaseContext, spec string) error

StartCron 中文函数注释:事件转发插件不使用插件级 cron,留空实现。

func (*EventHandlerLifecycle) Stop

Stop 停止事件转发插件的后台任务

func (*EventHandlerLifecycle) Uninstall

Uninstall 中文函数注释:卸载事件转发插件,停止后台任务并根据keepData参数决定是否删除相关表。

func (*EventHandlerLifecycle) Upgrade

Upgrade 中文函数注释:升级事件转发插件,执行必要的数据库迁移。

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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