using Microsoft.Extensions.DependencyInjection;
namespace ScadaLink.SiteEventLogging;
public static class ServiceCollectionExtensions
{
///
/// Register site event logging services (recording, purge, query).
///
public static IServiceCollection AddSiteEventLogging(this IServiceCollection services)
{
// The recorder is registered as a concrete singleton and the interface is
// forwarded to the same instance. The purge and query services depend on the
// concrete SiteEventLogger directly (they need its lock-guarded WithConnection)
// rather than downcasting an ISiteEventLogger, which would throw
// InvalidCastException for any other ISiteEventLogger implementation.
services.AddSingleton();
services.AddSingleton(sp => sp.GetRequiredService());
services.AddSingleton();
services.AddHostedService();
return services;
}
// NOTE: EventLogHandlerActor is wired up directly in
// ScadaLink.Host/Actors/AkkaHostedService.cs as a cluster singleton, because the
// actor must be created inside the ActorSystem with the resolved
// IEventLogQueryService. There is intentionally no DI helper for that here — a
// former AddSiteEventLoggingActors placeholder was dead code and has been removed.
}