using Microsoft.Extensions.DependencyInjection;
using ScadaLink.Communication.Grpc;

namespace ScadaLink.Communication;

public static class ServiceCollectionExtensions
{
    public static IServiceCollection AddCommunication(this IServiceCollection services)
    {
        services.AddOptions<CommunicationOptions>()
            .BindConfiguration("Communication");

        services.AddSingleton<CommunicationService>();
        services.AddSingleton<SiteStreamGrpcClientFactory>();
        services.AddSingleton<DebugStreamService>();

        return services;
    }

    public static IServiceCollection AddCommunicationActors(this IServiceCollection services)
    {
        // Actor registration happens in AkkaHostedService.RegisterCentralActors/RegisterSiteActors.
        // This method is a hook for any additional DI registrations needed by the communication actors.
        return services;
    }
}
