Table of Contents

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

scopes IServiceScopeFactory
locks IDistributedLock
logger ILogger<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

job IScheduledJob

The job, resolved in the caller's scope.

force bool

Run even if not due (manual run).

cancellationToken CancellationToken

Cancellation.

Returns

Task<JobRunOutcome>

What happened.