Trigger queue cleaner sequentially (#14)

* added option to run queue cleaner after content blocker

* updated readme to clearly state what the jobs do
This commit is contained in:
Marius Nechifor
2024-11-25 21:33:06 +02:00
committed by GitHub
parent 599242aa2a
commit a0c8ff72fb
8 changed files with 118 additions and 44 deletions

View File

@@ -16,6 +16,7 @@
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.1" />
<PackageReference Include="QBittorrent.Client" Version="1.9.24285.1" />
<PackageReference Include="Quartz" Version="3.13.1" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,35 @@
using Quartz;
namespace Infrastructure.Verticals.Jobs;
public class JobChainingListener : IJobListener
{
private readonly string _nextJobName;
public JobChainingListener(string nextJobName)
{
_nextJobName = nextJobName;
}
public string Name => nameof(JobChainingListener);
public Task JobExecutionVetoed(IJobExecutionContext context, CancellationToken cancellationToken) => Task.CompletedTask;
public Task JobToBeExecuted(IJobExecutionContext context, CancellationToken cancellationToken) => Task.CompletedTask;
public async Task JobWasExecuted(IJobExecutionContext context, JobExecutionException? jobException, CancellationToken cancellationToken)
{
if (string.IsNullOrEmpty(_nextJobName))
{
return;
}
IScheduler scheduler = context.Scheduler;
JobKey nextJobKey = new(_nextJobName);
if (await scheduler.CheckExists(nextJobKey, cancellationToken))
{
await scheduler.TriggerJob(nextJobKey, cancellationToken);
}
}
}