Files
pig-farm-controller/internal/infra/notify/notify.go

32 lines
684 B
Go
Raw Normal View History

2025-10-24 20:33:15 +08:00
package notify
import (
2025-11-05 21:40:19 +08:00
"context"
2025-10-24 20:33:15 +08:00
"time"
"git.huangwc.com/pig/pig-farm-controller/internal/infra/models"
2025-10-24 20:33:15 +08:00
)
// DefaultTimeFormat 定义了所有通知中统一使用的时间格式。
const DefaultTimeFormat = "2006-01-02 15:04:05"
// AlarmContent 定义了通知的内容
type AlarmContent struct {
// 通知标题
Title string
// 通知信息
Message string
// 通知级别
Level models.SeverityLevel
2025-10-24 20:33:15 +08:00
// 通知时间
Timestamp time.Time
}
// Notifier 定义了通知发送器的接口
type Notifier interface {
// Send 发送通知
2025-11-05 21:40:19 +08:00
Send(ctx context.Context, content AlarmContent, toAddr string) error
2025-10-24 20:33:15 +08:00
// Type 返回通知器的类型
Type() models.NotifierType
2025-10-24 20:33:15 +08:00
}