Files
mxaccessgw/src/ZB.MOM.WW.MxGateway.Server/Sessions/SessionServiceCollectionExtensions.cs
T

23 lines
1.1 KiB
C#

namespace ZB.MOM.WW.MxGateway.Server.Sessions;
/// <summary>Service collection extensions for session management.</summary>
public static class SessionServiceCollectionExtensions
{
/// <summary>Registers gateway session registry, manager, and factory services.</summary>
/// <param name="services">Service collection to register services in.</param>
/// <returns>The service collection for chaining.</returns>
public static IServiceCollection AddGatewaySessions(this IServiceCollection services)
{
// Lifetime consistent with IGalaxyHierarchyCache (singleton); the normalizer reads the
// cache's current snapshot per call, so it holds no per-session or per-request state.
services.AddSingleton<ArrayAddressNormalizer>();
services.AddSingleton<ISessionRegistry, SessionRegistry>();
services.AddSingleton<ISessionWorkerClientFactory, SessionWorkerClientFactory>();
services.AddSingleton<ISessionManager, SessionManager>();
services.AddHostedService<SessionLeaseMonitorHostedService>();
services.AddHostedService<SessionShutdownHostedService>();
return services;
}
}