29 lines
1.0 KiB
Go
29 lines
1.0 KiB
Go
package repository
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/company/ai-ops/internal/domain/model"
|
|
)
|
|
|
|
// AlertRepository 是告警数据存储接口
|
|
type AlertRepository interface {
|
|
// 告警统计
|
|
GetOpenCount(ctx context.Context) (*model.AlertCount, error)
|
|
|
|
// 规则 CRUD
|
|
ListRules(ctx context.Context) ([]model.AlertRule, error)
|
|
GetRuleByID(ctx context.Context, id string) (*model.AlertRule, error)
|
|
CreateRule(ctx context.Context, rule *model.AlertRule) error
|
|
UpdateRule(ctx context.Context, rule *model.AlertRule) error
|
|
DeleteRule(ctx context.Context, id string) error
|
|
|
|
// 告警事件
|
|
ListEvents(ctx context.Context, status string, page, pageSize int) ([]model.AlertEvent, int, error)
|
|
CreateEvent(ctx context.Context, event *model.AlertEvent) error
|
|
CreateEventWithAggregation(ctx context.Context, event *model.AlertEvent, window time.Duration, threshold int) (*model.AlertEvent, error)
|
|
UpdateEventStatus(ctx context.Context, id, status string) error
|
|
EscalateEvent(ctx context.Context, id, newLevel string) error
|
|
}
|