package models import "time" // AlertOutbox 表示待发送或重试中的告警任务。 type AlertOutbox struct { ID uint `gorm:"primaryKey;index:idx_logs_alert_outbox_event_latest,priority:2" json:"id"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` // LogEventID 关联日志事件 ID。 LogEventID uint `gorm:"index;index:idx_logs_alert_outbox_event_latest,priority:1" json:"log_event_id"` // PayloadJSON 保存 AlertReceiveBody 的 JSON 文本。 PayloadJSON string `gorm:"type:text" json:"payload_json"` // Status 任务状态:pending/processing/retrying/sent/dead。 Status string `gorm:"size:32;index" json:"status"` // RetryCount 已重试次数。 RetryCount int `json:"retry_count"` // NextRetryAt 下一次可重试时间。 NextRetryAt time.Time `gorm:"index" json:"next_retry_at"` // LeaseUntil/LeaseOwner 用于多实例原子领取,避免同一任务并发发送。 LeaseUntil *time.Time `gorm:"index" json:"lease_until,omitempty"` LeaseOwner string `gorm:"size:128;index" json:"lease_owner"` // LastError 最近一次错误信息。 LastError string `gorm:"type:text" json:"last_error"` } func (AlertOutbox) TableName() string { return "logs_alert_outbox" }