Class JobRunner
- Namespace
- Integrations.Infrastructure.Jobs
- Assembly
- Integrations.Infrastructure.dll
Runs a job on one replica at a time (Postgres advisory lock) and only when due according to job_runs, which
it updates. Used by the scheduler and by the admin "run now" endpoint (which forces the run).
public sealed class JobRunner
- Inheritance
-
JobRunner
- Inherited Members
Constructors
JobRunner(IServiceScopeFactory, IDistributedLock, ILogger<JobRunner>)
Runs a job on one replica at a time (Postgres advisory lock) and only when due according to job_runs, which
it updates. Used by the scheduler and by the admin "run now" endpoint (which forces the run).
public JobRunner(IServiceScopeFactory scopes, IDistributedLock locks, ILogger<JobRunner> logger)
Parameters
scopesIServiceScopeFactorylocksIDistributedLockloggerILogger<JobRunner>
Methods
TryRunAsync(IScheduledJob, bool, CancellationToken)
Runs job if no other replica is running it and (unless force) it is due.
public Task<JobRunOutcome> TryRunAsync(IScheduledJob job, bool force, CancellationToken cancellationToken)
Parameters
jobIScheduledJobThe job, resolved in the caller's scope.
forceboolRun even if not due (manual run).
cancellationTokenCancellationTokenCancellation.
Returns
- Task<JobRunOutcome>
What happened.