namespace StellaOps.Feedser.Core.Jobs;

public enum JobTriggerOutcome
{
    Accepted,
    NotFound,
    Disabled,
    AlreadyRunning,
    LeaseRejected,
    InvalidParameters,
    Failed,
    Cancelled,
}

public sealed record JobTriggerResult(JobTriggerOutcome Outcome, JobRunSnapshot? Run, string? ErrorMessage)
{
    public static JobTriggerResult Accepted(JobRunSnapshot run)
        => new(JobTriggerOutcome.Accepted, run, null);

    public static JobTriggerResult NotFound(string message)
        => new(JobTriggerOutcome.NotFound, null, message);

    public static JobTriggerResult Disabled(string message)
        => new(JobTriggerOutcome.Disabled, null, message);

    public static JobTriggerResult AlreadyRunning(string message)
        => new(JobTriggerOutcome.AlreadyRunning, null, message);

    public static JobTriggerResult LeaseRejected(string message)
        => new(JobTriggerOutcome.LeaseRejected, null, message);

    public static JobTriggerResult InvalidParameters(string message)
        => new(JobTriggerOutcome.InvalidParameters, null, message);

    public static JobTriggerResult Failed(JobRunSnapshot run, string error)
        => new(JobTriggerOutcome.Failed, run, error);

    public static JobTriggerResult Cancelled(JobRunSnapshot run, string error)
        => new(JobTriggerOutcome.Cancelled, run, error);
}
