using StellaOps.Feedser.Core.Jobs;

namespace StellaOps.Feedser.Source.Ru.Nkcki;

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

internal sealed class RuNkckiFetchJob : IJob
{
    private readonly RuNkckiConnector _connector;

    public RuNkckiFetchJob(RuNkckiConnector connector)
        => _connector = connector ?? throw new ArgumentNullException(nameof(connector));

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

internal sealed class RuNkckiParseJob : IJob
{
    private readonly RuNkckiConnector _connector;

    public RuNkckiParseJob(RuNkckiConnector connector)
        => _connector = connector ?? throw new ArgumentNullException(nameof(connector));

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

internal sealed class RuNkckiMapJob : IJob
{
    private readonly RuNkckiConnector _connector;

    public RuNkckiMapJob(RuNkckiConnector connector)
        => _connector = connector ?? throw new ArgumentNullException(nameof(connector));

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