35 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| package interfaces
 | |
| 
 | |
| import (
 | |
| 	"context"
 | |
| 	"time"
 | |
| 	"tyapi-server/internal/infrastructure/task/entities"
 | |
| 	"tyapi-server/internal/infrastructure/task/types"
 | |
| )
 | |
| 
 | |
| // ApiTaskQueue API任务队列接口
 | |
| type ApiTaskQueue interface {
 | |
| 	// Enqueue 入队任务
 | |
| 	Enqueue(ctx context.Context, taskType types.TaskType, payload types.TaskPayload) error
 | |
| 
 | |
| 	// EnqueueDelayed 延时入队任务
 | |
| 	EnqueueDelayed(ctx context.Context, taskType types.TaskType, payload types.TaskPayload, delay time.Duration) error
 | |
| 
 | |
| 	// EnqueueAt 指定时间入队任务
 | |
| 	EnqueueAt(ctx context.Context, taskType types.TaskType, payload types.TaskPayload, scheduledAt time.Time) error
 | |
| 
 | |
| 	// Cancel 取消任务
 | |
| 	Cancel(ctx context.Context, taskID string) error
 | |
| 
 | |
| 	// ModifySchedule 修改任务调度时间
 | |
| 	ModifySchedule(ctx context.Context, taskID string, newScheduledAt time.Time) error
 | |
| 
 | |
| 	// GetTaskStatus 获取任务状态
 | |
| 	GetTaskStatus(ctx context.Context, taskID string) (*entities.AsyncTask, error)
 | |
| 
 | |
| 	// ListTasks 列出任务
 | |
| 	ListTasks(ctx context.Context, taskType types.TaskType, status entities.TaskStatus, limit int) ([]*entities.AsyncTask, error)
 | |
| 
 | |
| 	// EnqueueTask 入队任务(简化版本)
 | |
| 	EnqueueTask(ctx context.Context, task *entities.AsyncTask) error
 | |
| } |