Skip to content
Tracon

IJobDispatcher

Namespace Tracon · Assembly Tracon.Abstractions.dll

Queues a job for a registered IJobHandler.

public interface IJobDispatcher

The supported way for consumer code to create work. IJobStore stays the persistence surface: it takes a fully formed JobRecord, so the caller has to invent the identifier, the status and the timestamps, and it accepts any handler key, including one nobody registered — such a job only fails later, in the worker. This interface closes both gaps.

It performs no authorization of its own: the caller is already inside the process. The HTTP surface has its own, narrower gate (TraconSchedulingOptions.HttpSchedulableHandlerKeys).

Lifetime: registered as a singleton and safe to call from any thread; it holds no per-call state.

Tenant: takes an expected tenantJobRequest.TenantId is required and is the tenant the job is queued for. The ambient tenant is not consulted; a caller that wants it passes it explicitly.

Delivery: queueing itself is exactly one row — the method either returns a queued JobRecord or throws, and it never retries on its own. What happens afterwards is the queue’s contract, and that is at-least-once: the handler may run more than once for the job this call created (see IJobHandler.ExecuteAsync).

EnqueueAsync(JobRequest, CancellationToken)

Section titled “ EnqueueAsync(JobRequest, CancellationToken)”

Validates the request and queues the job.

ValueTask<JobRecord> EnqueueAsync(JobRequest request, CancellationToken cancellationToken = default)

request JobRequest

What to run, for whom, and with what input.

cancellationToken CancellationToken

The cancellation token.

ValueTask<JobRecord>

The queued job record, with its identifier and counters filled in.

ArgumentNullException

request is null.

ArgumentException

JobRequest.HandlerKey is not registered, or the request’s tenant, target or lane is not valid.