using JSMR.Domain.Entities;

namespace JSMR.Application.Jobs;

public interface IJobRepository
{
    Task<Job> AddAsync(Job job, CancellationToken cancellationToken);
    Task<Job?> GetByIdAsync(int id, CancellationToken cancellationToken);
    Task<IReadOnlyList<Job>> GetRecentAsync(int take, CancellationToken cancellationToken);

    Task<bool> AnyRunningAsync(CancellationToken cancellationToken);
    Task<Job?> TryClaimNextQueuedAsync(string workerName, CancellationToken cancellationToken);

    Task SaveChangesAsync(CancellationToken cancellationToken);
}