16 lines
645 B
C#
16 lines
645 B
C#
using Microsoft.Extensions.Hosting;
|
|
using Npgsql;
|
|
|
|
namespace NeonSprawl.Server.Game.PositionState;
|
|
|
|
/// <summary>Disposes the shared <see cref="NpgsqlDataSource"/> when the host stops. Registered before <see cref="PostgresDevPlayerSeedHostedService"/> so <see cref="IHostedService.StopAsync"/> runs last (NEON-15).</summary>
|
|
internal sealed class NpgsqlDataSourceShutdownHostedService(NpgsqlDataSource dataSource) : IHostedService
|
|
{
|
|
public Task StartAsync(CancellationToken cancellationToken) => Task.CompletedTask;
|
|
|
|
public async Task StopAsync(CancellationToken cancellationToken)
|
|
{
|
|
await dataSource.DisposeAsync();
|
|
}
|
|
}
|