.NET API
JobContext
Tracon.Abstractions.dllThe context available during an IJobHandler execution.
public sealed class JobContext- Inheritance
- object ← JobContext
- Inherited Members
- object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Remarks
Section titled “Remarks”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.
Constructors
Section titled “Constructors”JobContext()
Section titled “ JobContext()”public JobContext()Properties
Section titled “Properties”IsCancelledAsync
Section titled “ IsCancelledAsync”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; }Property Value
Section titled “Property Value”Func<CancellationToken, ValueTask<bool>>
Remarks
Section titled “Remarks”The built-in worker also cancels the handler’s token within one
TraconSchedulingOptions.PollInterval of the cancel request, so a
handler that reads its token stops without asking. This check is the
immediate answer, read from the store.
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; }Property Value
Section titled “Property Value”The record of the job being executed.
public required JobRecord Job { get; init; }Property Value
Section titled “Property Value”ReportItemAsync
Section titled “ ReportItemAsync”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; }