콘텐츠로 이동

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

@gj-kit/nest-operations-jobs/core에서 공개하는 interface입니다. package version 0.1.1의 release declaration을 그대로 표시합니다.

import { OperationsJobContext } from '@gj-kit/nest-operations-jobs/core';
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>;
}

이 선언은 매개변수, optionality, 제네릭, 반환값, 공개 union/type 계약의 정본입니다. 호출 전 필요한 환경·권한·오류 경계는 패키지 Golden path와 이 subpath의 import 조건을 함께 확인하세요.

  • 패키지: @gj-kit/nest-operations-jobs
  • 버전: 0.1.1
  • 공개 entry: ./core
  • 소스: GitHub