namespace MxGateway.Server.Workers;
/// Service collection extensions for worker process management.
public static class WorkerServiceCollectionExtensions
{
/// Registers worker process launcher and factory services.
/// Service collection to register services.
public static IServiceCollection AddWorkerProcessLauncher(this IServiceCollection services)
{
services.AddSingleton();
services.AddSingleton();
services.AddSingleton();
// Terminate workers leaked by a previous unclean gateway run before the
// server accepts sessions. Registered ahead of AddGatewaySessions so the
// cleanup hosted service starts before the session subsystem.
services.AddSingleton();
services.AddSingleton();
services.AddHostedService();
return services;
}
}