using StellaOps.Feedser.Core.Jobs;

namespace StellaOps.Feedser.Source.Ru.Bdu;

internal static class RuBduJobKinds
{
    public const string Fetch = "source:ru-bdu:fetch";
    public const string Parse = "source:ru-bdu:parse";
    public const string Map = "source:ru-bdu:map";
}

internal sealed class RuBduFetchJob : IJob
{
    private readonly RuBduConnector _connector;

    public RuBduFetchJob(RuBduConnector connector)
        => _connector = connector ?? throw new ArgumentNullException(nameof(connector));

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

internal sealed class RuBduParseJob : IJob
{
    private readonly RuBduConnector _connector;

    public RuBduParseJob(RuBduConnector connector)
        => _connector = connector ?? throw new ArgumentNullException(nameof(connector));

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

internal sealed class RuBduMapJob : IJob
{
    private readonly RuBduConnector _connector;

    public RuBduMapJob(RuBduConnector connector)
        => _connector = connector ?? throw new ArgumentNullException(nameof(connector));

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