using IWS5.Core;
using IWS5.Core.Models.Processing;
using ILogger = Serilog.ILogger;

namespace IWS5.Server.EventProcessors;

public abstract class EventProcessor : IEventProcessor
{
    private readonly IConfiguration Configuration;
    protected readonly ILogger Logger;
    protected readonly string ConnectionString;

    protected EventProcessor(ILogger logger, IConfiguration configuration)
    {
        Logger = logger ?? throw new ArgumentNullException(nameof(logger));
        Configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
        ConnectionString = Configuration.GetConnectionString("GreenfieldPD") 
                           ?? throw new InvalidOperationException("Connection string 'GreenfieldPD' not found.");
    }

    public abstract Task<bool> ProcessEventAsync(EventModel eventData, int processId);
}