mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-13 17:47:51 +00:00
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)
This commit is contained in:
18
internal/model/sync_outbox.go
Normal file
18
internal/model/sync_outbox.go
Normal file
@@ -0,0 +1,18 @@
|
||||
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"`
|
||||
}
|
||||
Reference in New Issue
Block a user