using StellaOps.Feedser.Core.Jobs;

namespace StellaOps.Feedser.Source.Acsc;

internal static class AcscJobKinds
{
    public const string Fetch = "source:acsc:fetch";
    public const string Parse = "source:acsc:parse";
    public const string Map = "source:acsc:map";
    public const string Probe = "source:acsc:probe";
}

internal sealed class AcscFetchJob : IJob
{
    private readonly AcscConnector _connector;

    public AcscFetchJob(AcscConnector connector)
        => _connector = connector ?? throw new ArgumentNullException(nameof(connector));

    public Task ExecuteAsync(JobExecutionContext context, CancellationToken cancellationToken)
        => _connector.FetchAsync(context.Services, cancellationToken);
}

internal sealed class AcscParseJob : IJob
{
    private readonly AcscConnector _connector;

    public AcscParseJob(AcscConnector connector)
        => _connector = connector ?? throw new ArgumentNullException(nameof(connector));

    public Task ExecuteAsync(JobExecutionContext context, CancellationToken cancellationToken)
        => _connector.ParseAsync(context.Services, cancellationToken);
}

internal sealed class AcscMapJob : IJob
{
    private readonly AcscConnector _connector;

    public AcscMapJob(AcscConnector connector)
        => _connector = connector ?? throw new ArgumentNullException(nameof(connector));

    public Task ExecuteAsync(JobExecutionContext context, CancellationToken cancellationToken)
        => _connector.MapAsync(context.Services, cancellationToken);
}

internal sealed class AcscProbeJob : IJob
{
    private readonly AcscConnector _connector;

    public AcscProbeJob(AcscConnector connector)
        => _connector = connector ?? throw new ArgumentNullException(nameof(connector));

    public Task ExecuteAsync(JobExecutionContext context, CancellationToken cancellationToken)
        => _connector.ProbeAsync(cancellationToken);
}
