Files
ez-api/internal/model/sync_outbox.go
zenfun 6a16712b9d feat(core): implement sync outbox mechanism and refactor provider validation
- Introduce `SyncOutboxService` and model to retry failed CP-to-Redis sync operations
- Update `SyncService` to handle sync failures by enqueuing tasks to the outbox
- Centralize provider group and API key validation logic into `ProviderGroupManager`
- Refactor API handlers to utilize the new manager and robust sync methods
- Add configuration options for sync outbox (interval, batch size, retries)
2025-12-25 01:24:19 +08:00

19 lines
812 B
Go

package model
import "time"
// SyncOutbox stores failed CP -> Redis sync operations for retry.
type SyncOutbox struct {
ID uint `gorm:"primaryKey" json:"id"`
ResourceType string `gorm:"size:50;index" json:"resource_type"`
Action string `gorm:"size:50" json:"action"`
ResourceID *uint `gorm:"index" json:"resource_id,omitempty"`
Payload string `gorm:"type:text" json:"payload,omitempty"`
RetryCount int `gorm:"default:0" json:"retry_count"`
LastError string `gorm:"type:text" json:"last_error,omitempty"`
NextRetryAt *time.Time `gorm:"index" json:"next_retry_at,omitempty"`
Status string `gorm:"size:20;default:'pending'" json:"status"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}