Skip to content

OperationsJobContext — @gj-kit/nest-operations-jobs

A public interface from @gj-kit/nest-operations-jobs. The signature below is taken directly from the 0.1.1 release declaration.

import { OperationsJobContext } from '@gj-kit/nest-operations-jobs';
interface OperationsJobContext {
readonly runId: string;
readonly jobKey: string;
readonly trigger: JobTrigger;
readonly logger: JobLogger;
/**
* Aborted when the deadline passes, when the runner loses its claim, or when
* the caller's own signal aborts. The abort reason is an
* `OperationsJobsError`. Long batch loops must check it.
*
* The library guarantees that the signal aborts at the right instant, that the
* settling record is written exactly once, and that a body outliving its
* deadline cannot corrupt that record. It cannot guarantee that side effects
* stop: a job that ignores this signal keeps writing.
*/
readonly signal: AbortSignal;
/** Epoch milliseconds at which the run times out, from the injected clock. */
readonly deadlineAt: number;
/**
* Refresh the heartbeat immediately, optionally recording intermediate progress.
*
* Resolves `false` when this run no longer holds its claim — it was reaped as
* stale or already settled — and the job should stop. After the runner has
* settled the run this is a no-op that resolves `false` without touching the
* store, so a job that outlives its deadline can never overwrite the record.
*
* A failed store write is logged and resolves `true`: one transient error must
* not be read as "claim lost". Sustained failure is not forgiven, though —
* once nothing has been written for `staleRunAfterMs`, the runner aborts the
* run with `ERR_JOB_ABORTED` exactly as if the store had answered `false`,
* because by then another instance is entitled to reap this run's row.
*/
heartbeat(progress?: JobSummary): Promise<boolean>;
}

This declaration is the source of truth for parameters, optionality, generics, return values, and public union/type contracts. Check the package golden path and this subpath’s import conditions for required environment, permission, and error boundaries before calling it.

  • Package: @gj-kit/nest-operations-jobs
  • Version: 0.1.1
  • Public entry: .
  • Source: GitHub