using System;
using System.Threading;
using System.Threading.Tasks;
using StellaOps.Feedser.Core.Jobs;

namespace StellaOps.Feedser.Source.Vndr.Oracle;

internal static class OracleJobKinds
{
    public const string Fetch = "source:vndr-oracle:fetch";
    public const string Parse = "source:vndr-oracle:parse";
    public const string Map = "source:vndr-oracle:map";
}

internal sealed class OracleFetchJob : IJob
{
    private readonly OracleConnector _connector;

    public OracleFetchJob(OracleConnector connector)
        => _connector = connector ?? throw new ArgumentNullException(nameof(connector));

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

internal sealed class OracleParseJob : IJob
{
    private readonly OracleConnector _connector;

    public OracleParseJob(OracleConnector connector)
        => _connector = connector ?? throw new ArgumentNullException(nameof(connector));

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

internal sealed class OracleMapJob : IJob
{
    private readonly OracleConnector _connector;

    public OracleMapJob(OracleConnector connector)
        => _connector = connector ?? throw new ArgumentNullException(nameof(connector));

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