96bea1d478
Restyles the Blazor dashboard onto a portable token-based theme so it reads like an instrument panel: warm-paper background, hairline-ruled panels, IBM Plex type, monospace tabular numerics, and status carried by colour chips. Vendors theme.css + IBM Plex fonts, rewrites dashboard.css as a thin token-driven view layer, and swaps the Bootstrap navbar and status badges for the design-system app bar and chips. Also includes pending API-key management, Galaxy hierarchy projection, and constraint-enforcement work with their tests. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
46 lines
1.6 KiB
C#
46 lines
1.6 KiB
C#
using Microsoft.Extensions.Hosting;
|
|
using Microsoft.Extensions.Logging;
|
|
using Microsoft.Extensions.Options;
|
|
using MxGateway.Server.Configuration;
|
|
|
|
namespace MxGateway.Server.Sessions;
|
|
|
|
public sealed class SessionLeaseMonitorHostedService(
|
|
ISessionManager sessionManager,
|
|
IOptions<GatewayOptions> options,
|
|
ILogger<SessionLeaseMonitorHostedService> logger,
|
|
TimeProvider? timeProvider = null) : BackgroundService
|
|
{
|
|
private readonly TimeProvider _timeProvider = timeProvider ?? TimeProvider.System;
|
|
|
|
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
|
{
|
|
TimeSpan interval = TimeSpan.FromSeconds(Math.Max(1, options.Value.Sessions.LeaseSweepIntervalSeconds));
|
|
using PeriodicTimer timer = new(interval, _timeProvider);
|
|
|
|
try
|
|
{
|
|
while (await timer.WaitForNextTickAsync(stoppingToken).ConfigureAwait(false))
|
|
{
|
|
try
|
|
{
|
|
await sessionManager
|
|
.CloseExpiredLeasesAsync(_timeProvider.GetUtcNow(), stoppingToken)
|
|
.ConfigureAwait(false);
|
|
}
|
|
catch (OperationCanceledException) when (stoppingToken.IsCancellationRequested)
|
|
{
|
|
return;
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
logger.LogWarning(exception, "Session lease sweep failed.");
|
|
}
|
|
}
|
|
}
|
|
catch (OperationCanceledException) when (stoppingToken.IsCancellationRequested)
|
|
{
|
|
}
|
|
}
|
|
}
|