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:
zenfun
2025-12-25 01:24:19 +08:00
parent 44a82fa252
commit 6a16712b9d
12 changed files with 750 additions and 113 deletions

View File

@@ -22,6 +22,7 @@ type Handler struct {
rdb *redis.Client
logWebhook *service.LogWebhookService
logPartitioner *service.LogPartitioner
groupManager *service.ProviderGroupManager
}
func NewHandler(db *gorm.DB, logDB *gorm.DB, sync *service.SyncService, logger *service.LogWriter, rdb *redis.Client, partitioner *service.LogPartitioner) *Handler {
@@ -36,6 +37,7 @@ func NewHandler(db *gorm.DB, logDB *gorm.DB, sync *service.SyncService, logger *
rdb: rdb,
logWebhook: service.NewLogWebhookService(rdb),
logPartitioner: partitioner,
groupManager: service.NewProviderGroupManager(),
}
}