24 lines
967 B
C#
24 lines
967 B
C#
using ScrapperAPI.Dtos;
|
|
|
|
namespace ScrapperAPI.Interfaces;
|
|
|
|
public interface IQueueRepository
|
|
{
|
|
Task<int> EnqueueAsync(int sessionId, string url, CancellationToken ct);
|
|
Task<QueueCounts> GetCountsAsync(int sessionId, CancellationToken ct);
|
|
|
|
/// <summary>
|
|
/// Pega 1 item pendente e muda para Processing atomica/seguramente.
|
|
/// Retorna null se não houver itens pendentes.
|
|
/// </summary>
|
|
Task<QueueItem?> TryDequeueAsync(int sessionId, CancellationToken ct);
|
|
|
|
Task MarkDoneAsync(int queueId, CancellationToken ct);
|
|
Task MarkFailedAsync(int queueId, string error, CancellationToken ct);
|
|
|
|
// Opcional: resetar stuck processing (se quiser depois)
|
|
Task<int> RequeueStuckProcessingAsync(int sessionId, TimeSpan olderThan, CancellationToken ct);
|
|
|
|
Task<bool> RemovePendingByIdAsync(int sessionId, int queueId, CancellationToken ct);
|
|
Task<int> RemovePendingByUrlAsync(int sessionId, string url, CancellationToken ct);
|
|
} |