Skip to content
Tracon

JobContext

Namespace Tracon · Assembly Tracon.Abstractions.dll

The context available during an IJobHandler execution.

public sealed class JobContext

objectJobContext

object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

The handler does not access IJobStore directly; this keeps the handler focused only on execution logic and removes the need to set up a fake store in a unit test. It carries no service provider either: the handler is built by the container from its own per-execution scope, so its dependencies arrive through its constructor.

public JobContext()

Checks whether the job was cancelled by an external request (POST .../cancel). The handler supports cooperative cancellation by checking this between items.

public required Func<CancellationToken, ValueTask<bool>> IsCancelledAsync { get; init; }

Func<CancellationToken, ValueTask<bool>>

The job’s items, by sequence number. Carries every item, regardless of JobItemRecord.Status — not filtered down to JobItemStatus.Pending ones. On a retry (see IJobHandler.ExecuteAsync’s remarks), items already JobItemStatus.Completed or JobItemStatus.Failed from an earlier attempt are present here too; the handler is responsible for skipping them.

public required IReadOnlyList<JobItemRecord> Items { get; init; }

IReadOnlyList<JobItemRecord>

The record of the job being executed.

public required JobRecord Job { get; init; }

JobRecord

Reports an item’s processing result. The handler must call this as each item is processed; the result is reflected into the persistent store and the job’s counters.

public required Func<JobItemResult, CancellationToken, ValueTask> ReportItemAsync { get; init; }

Func<JobItemResult, CancellationToken, ValueTask>