haixunMaster/haixun-backend/internal/model/job/domain/repository/queue.go

20 lines
1.0 KiB
Go
Raw Permalink Normal View History

2026-06-23 09:54:27 +00:00
package repository
import "context"
type QueueRepository interface {
Enqueue(ctx context.Context, workerType, jobID string) error
Dequeue(ctx context.Context, workerType string, timeoutSeconds int) (string, error)
RemoveJob(ctx context.Context, workerType, jobID string) error
SetCancelSignal(ctx context.Context, jobID, reason string) error
GetCancelSignal(ctx context.Context, jobID string) (bool, string, error)
ClearCancelSignal(ctx context.Context, jobID string) error
TryLock(ctx context.Context, jobID, workerID string, ttlSeconds int) (bool, error)
RefreshLock(ctx context.Context, jobID, workerID string, ttlSeconds int) error
ReleaseLock(ctx context.Context, jobID, workerID string) error
TryAcquireDedupe(ctx context.Context, templateType, dedupeHash, jobID string, ttlSeconds int) (bool, error)
ReleaseDedupe(ctx context.Context, templateType, dedupeHash string) error
TrySchedulerLock(ctx context.Context, holder string, ttlSeconds int) (bool, error)
ReleaseSchedulerLock(ctx context.Context, holder string) error
}