12 lines
989 B
C#
12 lines
989 B
C#
using PlotLine.Data;
|
|
namespace PlotLine.Services;
|
|
// Central reservation recovery only; AI execution continues through existing feature workers/services.
|
|
public sealed class AiAllowanceMaintenance(IServiceScopeFactory scopes,ILogger<AiAllowanceMaintenance> logger):BackgroundService
|
|
{
|
|
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
|
{
|
|
using var timer=new PeriodicTimer(TimeSpan.FromMinutes(5));
|
|
do{try{using var scope=scopes.CreateScope();var events=await scope.ServiceProvider.GetRequiredService<IDiscretionaryAiRepository>().Expire();var notifier=scope.ServiceProvider.GetRequiredService<IStoryIntelligenceProgressNotifier>();foreach(var progress in events)await notifier.PublishCharacterEnrichmentAsync(progress);}catch(Exception error)when(error is not OperationCanceledException){logger.LogWarning(error,"AI reservation expiry maintenance failed; reservations remain durably recorded.");}}while(await timer.WaitForNextTickAsync(stoppingToken));
|
|
}
|
|
}
|