namespace Health.Application.Diets;

public sealed record DietImageUploadFile(string FileName, long Length, Stream Content);

public sealed record DietImageAnalysisJob(Guid Id, IReadOnlyList<string> FilePaths);

public sealed record DietImageAnalysisResult(bool Success, int Code, string? Data, string? Message);

public interface IDietImageAnalysisCoordinator
{
    Task<DietImageAnalysisResult> AnalyzeAsync(IReadOnlyList<DietImageUploadFile> files, CancellationToken ct);
}

public interface IDietImageAnalysisQueue
{
    Task<Guid> EnqueueAsync(IReadOnlyList<string> filePaths, CancellationToken ct);
    Task RecoverStaleAsync(CancellationToken ct);
    Task<DietImageAnalysisJob?> TryTakeAsync(CancellationToken ct);
    Task<DietImageAnalysisResult> WaitForResultAsync(Guid jobId, CancellationToken ct);
    Task CompleteAsync(Guid jobId, DietImageAnalysisResult result, CancellationToken ct);
    Task<bool> RetryAsync(Guid jobId, string error, CancellationToken ct);
}

public interface IDietImageAnalyzer
{
    Task<DietImageAnalysisResult> AnalyzeAsync(DietImageAnalysisJob job, CancellationToken ct);
}
