Documentation
¶
Index ¶
- Variables
- func StartEventForwarding() error
- func StartEventForwardingWatch()
- func StartLeaderWatch()
- func StopEventForwarding()
- func StopEventForwardingWatch()
- func StopLeaderWatch()
- func SyncEventForwardingFromConfig()
- type EventHandlerLifecycle
- func (l *EventHandlerLifecycle) Disable(ctx plugins.BaseContext) error
- func (l *EventHandlerLifecycle) Enable(ctx plugins.EnableContext) error
- func (l *EventHandlerLifecycle) Install(ctx plugins.InstallContext) error
- func (l *EventHandlerLifecycle) Start(ctx plugins.BaseContext) error
- func (l *EventHandlerLifecycle) StartCron(ctx plugins.BaseContext, spec string) error
- func (l *EventHandlerLifecycle) Stop(ctx plugins.BaseContext) error
- func (l *EventHandlerLifecycle) Uninstall(ctx plugins.UninstallContext) error
- func (l *EventHandlerLifecycle) Upgrade(ctx plugins.UpgradeContext) error
Constants ¶
This section is empty.
Variables ¶
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 StopEventForwarding ¶
func StopEventForwarding()
StopEventForwarding 中文函数注释:停止当前运行的 Watcher 与 Worker,并清理内部引用。
func StopEventForwardingWatch ¶
func StopEventForwardingWatch()
StopEventForwardingWatch 中文函数注释:优雅停止定时任务,避免重复任务或资源泄漏。
func SyncEventForwardingFromConfig ¶
func SyncEventForwardingFromConfig()
SyncEventForwardingFromConfig 中文函数注释:每次调用均读取数据库最新配置;若开关或参数变化,则执行启停或更新,保持与平台配置一致。
Types ¶
type EventHandlerLifecycle ¶
type EventHandlerLifecycle struct {
// contains filtered or unexported fields
}
EventHandlerLifecycle 中文函数注释:事件转发插件生命周期实现。
func (*EventHandlerLifecycle) Disable ¶
func (l *EventHandlerLifecycle) Disable(ctx plugins.BaseContext) error
Disable 中文函数注释:禁用事件转发插件,停止后台任务与事件转发。
func (*EventHandlerLifecycle) Enable ¶
func (l *EventHandlerLifecycle) Enable(ctx plugins.EnableContext) error
Enable 中文函数注释:启用事件转发插件,确保数据库表存在。
func (*EventHandlerLifecycle) Install ¶
func (l *EventHandlerLifecycle) Install(ctx plugins.InstallContext) error
Install 中文函数注释:安装事件转发插件,初始化数据库表结构。
func (*EventHandlerLifecycle) Start ¶
func (l *EventHandlerLifecycle) Start(ctx plugins.BaseContext) error
Start 中文函数注释:启动事件转发插件后台任务(不可阻塞),按主备状态控制事件转发启停。
func (*EventHandlerLifecycle) StartCron ¶
func (l *EventHandlerLifecycle) StartCron(ctx plugins.BaseContext, spec string) error
StartCron 中文函数注释:事件转发插件不使用插件级 cron,留空实现。
func (*EventHandlerLifecycle) Stop ¶
func (l *EventHandlerLifecycle) Stop(ctx plugins.BaseContext) error
Stop 停止事件转发插件的后台任务
func (*EventHandlerLifecycle) Uninstall ¶
func (l *EventHandlerLifecycle) Uninstall(ctx plugins.UninstallContext) error
Uninstall 中文函数注释:卸载事件转发插件,停止后台任务并根据keepData参数决定是否删除相关表。
func (*EventHandlerLifecycle) Upgrade ¶
func (l *EventHandlerLifecycle) Upgrade(ctx plugins.UpgradeContext) error
Upgrade 中文函数注释:升级事件转发插件,执行必要的数据库迁移。