@blokjs/trigger-worker 0.6.17 → 0.6.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/WorkerTrigger.d.ts +27 -3
  2. package/dist/WorkerTrigger.js +168 -26
  3. package/dist/adapters/KafkaAdapter.d.ts +5 -0
  4. package/dist/adapters/KafkaAdapter.js +12 -1
  5. package/dist/index.d.ts +1 -1
  6. package/dist/index.js +2 -2
  7. package/package.json +5 -4
  8. package/CHANGELOG.md +0 -22
  9. package/__tests__/integration/nats-adapter.real-nats.test.ts +0 -116
  10. package/__tests__/integration/pgboss-adapter.real-pg.test.ts +0 -164
  11. package/__tests__/integration/rabbitmq-adapter.real-rabbitmq.test.ts +0 -179
  12. package/__tests__/integration/sqs-adapter.real-sqs.test.ts +0 -228
  13. package/src/WorkerTrigger.test.ts +0 -540
  14. package/src/WorkerTrigger.ts +0 -784
  15. package/src/adapters/BullMQAdapter.ts +0 -296
  16. package/src/adapters/InMemoryAdapter.ts +0 -280
  17. package/src/adapters/KafkaAdapter.ts +0 -277
  18. package/src/adapters/NATSAdapter.ts +0 -454
  19. package/src/adapters/PgBossAdapter.ts +0 -293
  20. package/src/adapters/RabbitMQAdapter.ts +0 -285
  21. package/src/adapters/RedisStreamsAdapter.ts +0 -286
  22. package/src/adapters/SQSAdapter.ts +0 -306
  23. package/src/adapters/factory.test.ts +0 -89
  24. package/src/adapters/factory.ts +0 -111
  25. package/src/adapters/new-adapters.test.ts +0 -130
  26. package/src/index.ts +0 -94
  27. package/template/.env.example +0 -13
  28. package/template/package.json +0 -45
  29. package/template/src/Nodes.ts +0 -10
  30. package/template/src/Workflows.ts +0 -8
  31. package/template/src/index.ts +0 -41
  32. package/template/src/runner/WorkerServer.ts +0 -34
  33. package/template/src/runner/types/Workflows.ts +0 -7
  34. package/template/src/workflows/jobs/process-job.ts +0 -47
  35. package/template/tsconfig.json +0 -31
  36. package/template/vitest.config.ts +0 -39
  37. package/tsconfig.json +0 -32
@@ -19,8 +19,22 @@
19
19
  * - Ack on success, retry or DLQ on failure
20
20
  */
21
21
  import { type HelperResponse, type WorkerTriggerOpts } from "@blokjs/helper";
22
- import { type BlokService, DefaultLogger, type GlobalOptions, TriggerBase, type TriggerResponse } from "@blokjs/runner";
22
+ import { type BlokService, Configuration, DefaultLogger, type GlobalOptions, TriggerBase, type TriggerResponse } from "@blokjs/runner";
23
23
  import type { Context } from "@blokjs/shared";
24
+ /**
25
+ * F4 / F24 — thrown by `executeWithTimeout` when a worker job exceeds its
26
+ * trigger-level `config.timeout`. A dedicated type (instead of a plain
27
+ * `Error`) lets `handleJob`'s catch discriminate the timeout: it aborts the
28
+ * detached run via `ctx.signal` and flips the run record to `timedOut`
29
+ * (matching the per-step `maxDuration` taxonomy) rather than routing the
30
+ * timeout through the generic retry/DLQ path.
31
+ */
32
+ export declare class WorkerTimeoutError extends Error {
33
+ readonly timeoutMs: number;
34
+ /** Run id of the aborted run, when known — used to flip status to `timedOut`. */
35
+ readonly runId?: string;
36
+ constructor(timeoutMs: number, runId?: string);
37
+ }
24
38
  /**
25
39
  * Job received from worker queue
26
40
  */
@@ -220,9 +234,19 @@ export declare abstract class WorkerTrigger extends TriggerBase {
220
234
  */
221
235
  protected handleJob(job: WorkerJob, workflow: WorkerWorkflowModel, config: WorkerTriggerOpts): Promise<void>;
222
236
  /**
223
- * Execute workflow with a timeout
237
+ * Execute workflow with a timeout.
238
+ *
239
+ * F4 — on timeout, fire the ctx AbortController so the detached `run`
240
+ * unwinds cooperatively (it throws `RunCancelledError` at the next
241
+ * between-step check; long uninterruptible nodes should still poll
242
+ * `ctx.signal.aborted`). The promise rejects with a dedicated
243
+ * {@link WorkerTimeoutError} carrying the run id so `handleJob`'s catch can
244
+ * flip the run record to `timedOut` (F24). The second `run` (broker
245
+ * redelivery) is prevented because we ACK without requeue on timeout.
246
+ *
247
+ * F2 — `configuration` is the per-job Configuration; threaded into `run`.
224
248
  */
225
- protected executeWithTimeout(ctx: Context, timeoutMs: number): Promise<TriggerResponse>;
249
+ protected executeWithTimeout(ctx: Context, timeoutMs: number, configuration?: Configuration): Promise<TriggerResponse>;
226
250
  /**
227
251
  * Calculate exponential backoff delay
228
252
  * Formula: min(baseDelay * 2^attempt, 30000) + jitter