using Microsoft.Extensions.DependencyInjection;
using ScadaLink.Commons.Interfaces.Services;

namespace ScadaLink.ExternalSystemGateway;

public static class ServiceCollectionExtensions
{
    public static IServiceCollection AddExternalSystemGateway(this IServiceCollection services)
    {
        services.AddOptions<ExternalSystemGatewayOptions>()
            .BindConfiguration("ScadaLink:ExternalSystemGateway");

        services.AddHttpClient();
        services.AddScoped<ExternalSystemClient>();
        services.AddScoped<IExternalSystemClient>(sp => sp.GetRequiredService<ExternalSystemClient>());
        services.AddScoped<DatabaseGateway>();
        services.AddScoped<IDatabaseGateway>(sp => sp.GetRequiredService<DatabaseGateway>());

        return services;
    }

    public static IServiceCollection AddExternalSystemGatewayActors(this IServiceCollection services)
    {
        // WP-10: Actor registration happens in AkkaHostedService.
        // Script Execution Actors run on dedicated blocking I/O dispatcher.
        return services;
    }
}
