fix: 修复 golangci-lint depguard 和 gofmt 错误
将 redis leader lock 逻辑从 service 层抽取为 LeaderLocker 接口, 实现移至 repository 层,消除 service 层对 redis 的直接依赖。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -59,3 +59,10 @@ type ScheduledTestResultRepository interface {
|
||||
ListByPlanID(ctx context.Context, planID int64, limit int) ([]*ScheduledTestResult, error)
|
||||
PruneOldResults(ctx context.Context, planID int64, keepCount int) error
|
||||
}
|
||||
|
||||
// LeaderLocker provides distributed leader election for background runners.
|
||||
// TryAcquire attempts to acquire a named lock and returns a release function
|
||||
// and true if successful, or nil and false if the lock is held by another instance.
|
||||
type LeaderLocker interface {
|
||||
TryAcquire(ctx context.Context, key string, ttl time.Duration) (release func(), ok bool)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user