Documentation
¶
Index ¶
- func DropDB() error
- func HasEnabledEventConfigs() (bool, error)
- func InitDB() error
- func UpgradeDB(fromVersion string, toVersion string) error
- type EventForwardSetting
- type K8sEvent
- func (e *K8sEvent) Delete(params *dao.Params, ids string, queryFuncs ...func(*gorm.DB) *gorm.DB) error
- func (e *K8sEvent) GetByEvtKey(evtKey string) (*K8sEvent, error)
- func (e *K8sEvent) GetOne(params *dao.Params, queryFuncs ...func(*gorm.DB) *gorm.DB) (*K8sEvent, error)
- func (e *K8sEvent) IncrementAttemptsByID(id int64) error
- func (e *K8sEvent) IsNormal() bool
- func (e *K8sEvent) IsWarning() bool
- func (e *K8sEvent) List(params *dao.Params, queryFuncs ...func(*gorm.DB) *gorm.DB) ([]*K8sEvent, int64, error)
- func (e *K8sEvent) ListUnprocessed(limit int) ([]*K8sEvent, error)
- func (e *K8sEvent) MarkProcessedByID(id int64, processed bool) error
- func (e *K8sEvent) Save(params *dao.Params, queryFuncs ...func(*gorm.DB) *gorm.DB) error
- func (e *K8sEvent) SaveEvent() error
- func (e *K8sEvent) ShouldProcess() bool
- func (e *K8sEvent) TableName() string
- type K8sEventConfig
- func (c *K8sEventConfig) Delete(params *dao.Params, ids string, queryFuncs ...func(*gorm.DB) *gorm.DB) error
- func (c *K8sEventConfig) GetOne(params *dao.Params, queryFuncs ...func(*gorm.DB) *gorm.DB) (*K8sEventConfig, error)
- func (c *K8sEventConfig) List(params *dao.Params, queryFuncs ...func(*gorm.DB) *gorm.DB) ([]*K8sEventConfig, int64, error)
- func (c *K8sEventConfig) Save(params *dao.Params, queryFuncs ...func(*gorm.DB) *gorm.DB) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasEnabledEventConfigs ¶
HasEnabledEventConfigs 中文函数注释:判断是否存在已启用的事件规则。
Types ¶
type EventForwardSetting ¶
type EventForwardSetting struct {
ID uint `gorm:"primaryKey;autoIncrement" json:"id,omitempty"`
EventWorkerProcessInterval int `json:"event_worker_process_interval"`
EventWorkerBatchSize int `json:"event_worker_batch_size"`
EventWorkerMaxRetries int `json:"event_worker_max_retries"`
EventWatcherBufferSize int `json:"event_watcher_buffer_size"`
CreatedAt time.Time `json:"created_at,omitempty" gorm:"<-:create"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
}
EventForwardSetting 中文函数注释:事件转发总开关与运行参数配置表。
func DefaultEventForwardSetting ¶
func DefaultEventForwardSetting() *EventForwardSetting
DefaultEventForwardSetting 中文函数注释:返回默认配置(默认关闭)。
func GetOrCreateEventForwardSetting ¶
func GetOrCreateEventForwardSetting() (*EventForwardSetting, error)
GetOrCreateEventForwardSetting 中文函数注释:获取事件转发配置;若不存在则写入一条默认记录。
func UpdateEventForwardSetting ¶
func UpdateEventForwardSetting(in *EventForwardSetting) (*EventForwardSetting, error)
UpdateEventForwardSetting 中文函数注释:更新事件转发配置(确保只维护一条记录)。
func (EventForwardSetting) TableName ¶
func (EventForwardSetting) TableName() string
TableName 中文函数注释:设置表名。
type K8sEvent ¶
type K8sEvent struct {
ID int64 `gorm:"primaryKey;autoIncrement" json:"id"`
EvtKey string `gorm:"uniqueIndex;" json:"evt_key"`
Cluster string `gorm:"type:varchar(128);" json:"cluster"`
Namespace string `gorm:"type:varchar(64);index" json:"namespace"`
Name string `gorm:"type:varchar(128);" json:"name"`
Type string `gorm:"type:varchar(16);" json:"type"`
Reason string `gorm:"type:varchar(128);" json:"reason"`
Level string `gorm:"type:varchar(16);" json:"level"`
Message string `gorm:"type:text;" json:"message"`
Timestamp time.Time `gorm:"index" json:"timestamp"`
Processed bool `gorm:"default:false;index" json:"processed"`
Attempts int `gorm:"default:0" json:"-"`
CreatedAt time.Time `json:"created_at,omitempty" gorm:"<-:create"`
UpdatedAt time.Time `json:"-"`
}
K8sEvent 中文函数注释:事件转发插件使用的K8s事件模型。
func (*K8sEvent) Delete ¶
func (e *K8sEvent) Delete(params *dao.Params, ids string, queryFuncs ...func(*gorm.DB) *gorm.DB) error
Delete 中文函数注释:根据ID删除事件记录。
func (*K8sEvent) GetByEvtKey ¶
GetByEvtKey 中文函数注释:根据事件键获取事件。
func (*K8sEvent) GetOne ¶
func (e *K8sEvent) GetOne(params *dao.Params, queryFuncs ...func(*gorm.DB) *gorm.DB) (*K8sEvent, error)
GetOne 中文函数注释:获取单条事件记录。
func (*K8sEvent) IncrementAttemptsByID ¶
IncrementAttemptsByID 中文函数注释:根据ID增加重试次数。
func (*K8sEvent) List ¶
func (e *K8sEvent) List(params *dao.Params, queryFuncs ...func(*gorm.DB) *gorm.DB) ([]*K8sEvent, int64, error)
List 中文函数注释:列出事件记录。
func (*K8sEvent) ListUnprocessed ¶
ListUnprocessed 中文函数注释:列出未处理的事件,按时间升序,限制条数。
func (*K8sEvent) MarkProcessedByID ¶
MarkProcessedByID 中文函数注释:根据ID更新处理状态。
func (*K8sEvent) ShouldProcess ¶
ShouldProcess 中文函数注释:判断事件是否应该被处理。
type K8sEventConfig ¶
type K8sEventConfig struct {
ID uint `gorm:"primaryKey;autoIncrement" json:"id,omitempty"`
Name string `json:"name"` // 事件转发配置名称
Description string `json:"description"` // 事件转发配置描述
Clusters string `json:"clusters"` // 目标集群列表
Webhooks string `json:"webhooks"` // webhook列表
WebhookNames string `json:"webhook_names"` // webhook 名称列表
Enabled bool `json:"enabled"` // 是否启用该任务
AIEnabled bool `json:"ai_enabled"` // 是否启用AI总结功能
AIPromptTemplate string `gorm:"type:text" json:"ai_prompt_template"` // AI总结提示词模板
RuleNamespaces string `json:"rule_namespaces" gorm:"type:text"` // []string 精确匹配命名空间
RuleNames string `json:"rule_names" gorm:"type:text"` // []string 包含匹配名称
RuleReasons string `json:"rule_reasons" gorm:"type:text"` // []string 包含匹配Reason、Message两个字段
RuleReverse bool `json:"rule_reverse" gorm:"default:false"`
CreatedAt time.Time `json:"created_at,omitempty" gorm:"<-:create"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
}
K8sEventConfig 中文函数注释:Event 监听 转发 发送webhook配置表。
func (*K8sEventConfig) Delete ¶
func (c *K8sEventConfig) Delete(params *dao.Params, ids string, queryFuncs ...func(*gorm.DB) *gorm.DB) error
Delete 中文函数注释:根据指定 ID 删除 K8sEventConfig 实例。
func (*K8sEventConfig) GetOne ¶
func (c *K8sEventConfig) GetOne(params *dao.Params, queryFuncs ...func(*gorm.DB) *gorm.DB) (*K8sEventConfig, error)
GetOne 中文函数注释:获取单个 K8sEventConfig 实例。