using Microsoft.Extensions.Hosting; using Npgsql; namespace NeonSprawl.Server.Game.PositionState; /// Disposes the shared when the host stops. Registered before so runs last (NEO-13). internal sealed class NpgsqlDataSourceShutdownHostedService(NpgsqlDataSource dataSource) : IHostedService { public Task StartAsync(CancellationToken cancellationToken) => Task.CompletedTask; public async Task StopAsync(CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); await dataSource.DisposeAsync(); } }