@ultimat3/jobs 24.0.0 → 25.0.0

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 (54) hide show
  1. package/CLAUDE.md +25 -27
  2. package/README.md +50 -34
  3. package/package.json +7 -7
  4. package/src/backfill-errors.ts +3 -2
  5. package/src/backfill-ledger.ts +1 -1
  6. package/src/backfill-rate.ts +2 -2
  7. package/src/backfill.ts +2 -2
  8. package/src/counters.ts +1 -1
  9. package/src/driver-memory-operator.ts +3 -3
  10. package/src/driver-memory.ts +14 -17
  11. package/src/driver-pg-settle-sql.ts +2 -3
  12. package/src/driver-pg-sql.ts +1 -1
  13. package/src/driver-pg.ts +18 -18
  14. package/src/driver.ts +9 -15
  15. package/src/errors-concurrency.ts +1 -1
  16. package/src/errors.ts +5 -5
  17. package/src/events-pg.ts +4 -4
  18. package/src/events.ts +6 -6
  19. package/src/execute.ts +46 -5
  20. package/src/export.ts +2 -2
  21. package/src/heartbeat.ts +7 -2
  22. package/src/index.ts +37 -97
  23. package/src/inspect-operator.ts +1 -1
  24. package/src/inspect.ts +1 -1
  25. package/src/job.ts +1 -1
  26. package/src/leases.ts +1 -1
  27. package/src/limits.ts +13 -8
  28. package/src/outbox-lease.ts +1 -1
  29. package/src/outbox-pg.ts +5 -5
  30. package/src/outbox-relay.ts +6 -6
  31. package/src/outbox.ts +13 -13
  32. package/src/renewal-timer.ts +1 -1
  33. package/src/retry-classification.ts +52 -15
  34. package/src/scheduler-leader.ts +2 -2
  35. package/src/scheduler-pg.ts +16 -14
  36. package/src/scheduler-state.ts +2 -2
  37. package/src/scheduler.ts +5 -5
  38. package/src/steps-memory.ts +2 -2
  39. package/src/steps.ts +35 -7
  40. package/src/task.ts +1 -1
  41. package/src/webhook-attempt.ts +206 -0
  42. package/src/webhook-ledger.ts +15 -4
  43. package/src/webhook.ts +64 -118
  44. package/src/worker-admit.ts +7 -3
  45. package/src/worker-drain-cutoff.ts +110 -0
  46. package/src/worker-fleet-slots.ts +5 -2
  47. package/src/worker-held.ts +100 -0
  48. package/src/worker-options.ts +19 -15
  49. package/src/worker-run.ts +38 -8
  50. package/src/worker-tally.ts +53 -0
  51. package/src/worker-types.ts +7 -4
  52. package/src/worker.ts +85 -77
  53. package/src/driver-nats.ts +0 -89
  54. package/src/driver-redis.ts +0 -92
@@ -1,92 +0,0 @@
1
- // Redis driver — interface-complete, not implemented. Honest stub: correct types so an app
2
- // can be written against it and `x verify` typechecks, with one labelled throw per method so
3
- // nobody discovers the gap from a silently-dropped job.
4
- //
5
- // Design it will implement when written: a per-queue Redis Stream with a consumer group
6
- // (XADD / XREADGROUP / XACK), `XAUTOCLAIM` for the visibility timeout, a ZSET for delayed
7
- // and suspended runs, and step records in a hash keyed by run id.
8
-
9
- import { NotImplementedError } from '@ultimat3/core';
10
- import type {
11
- ClaimedJob,
12
- ClaimOptions,
13
- EnqueueRequest,
14
- EnqueueResult,
15
- HeartbeatOptions,
16
- JobDriver,
17
- NackOptions,
18
- QueueStats,
19
- } from './driver';
20
- import type { StepRecord, StepStore } from './steps';
21
-
22
- // Names the seam that actually replaces the stub, and NOTHING ELSE — the two other repairs this
23
- // line has carried were both unrunnable.
24
- //
25
- // NOT `jobs: { driver }` in app.config.ts, which it said until 2026-08-20: the field had no
26
- // reader anywhere, so that edit repaired nothing and sent the reader back to the same throw. It
27
- // is deleted now.
28
- //
29
- // NOT `x jobs drain --to memory` either, which it said until 2026-09, and that one was a route
30
- // into data loss: the target is a Map inside the command's own process, so the drain acked every
31
- // durable row and lost the copy at exit. `x jobs` refuses that value by name now. There is no
32
- // drain to run in its place, and the reason is in this file — `enqueue` below refuses too, so
33
- // nothing was ever queued onto this driver and the queue is untouched.
34
- //
35
- // The redis driver lands in v2; there is no flag that turns this one on.
36
- const FIX =
37
- 'call setJobDriver(createPgDriver()) at boot instead of this driver; nothing needs moving first, because enqueue here refuses too, so no job was ever written to it';
38
-
39
- const unavailable = (method: string): never => {
40
- throw new NotImplementedError({
41
- cause: `redis jobs driver (${method}) is not implemented`,
42
- fix: FIX,
43
- });
44
- };
45
-
46
- const redisStepStore = (): StepStore => ({
47
- get(_runId: string, _name: string): Promise<StepRecord | undefined> {
48
- return unavailable('steps.get');
49
- },
50
- put(_record: StepRecord): Promise<void> {
51
- return unavailable('steps.put');
52
- },
53
- list(_runId: string): Promise<readonly StepRecord[]> {
54
- return unavailable('steps.list');
55
- },
56
- del(_runId: string, _name: string): Promise<void> {
57
- return unavailable('steps.del');
58
- },
59
- clear(_runId: string): Promise<void> {
60
- return unavailable('steps.clear');
61
- },
62
- });
63
-
64
- export interface RedisDriverOptions {
65
- readonly url?: string;
66
- readonly consumerGroup?: string;
67
- }
68
-
69
- export function createRedisDriver(_options: RedisDriverOptions = {}): JobDriver {
70
- return {
71
- name: 'redis',
72
- steps: redisStepStore(),
73
- enqueue(_request: EnqueueRequest): Promise<EnqueueResult> {
74
- return unavailable('enqueue');
75
- },
76
- claim(_options: ClaimOptions): Promise<readonly ClaimedJob[]> {
77
- return unavailable('claim');
78
- },
79
- ack(_jobId: string): Promise<boolean> {
80
- return unavailable('ack');
81
- },
82
- nack(_jobId: string, _options: NackOptions): Promise<boolean> {
83
- return unavailable('nack');
84
- },
85
- heartbeat(_jobId: string, _options: HeartbeatOptions): Promise<boolean> {
86
- return unavailable('heartbeat');
87
- },
88
- stats(): Promise<readonly QueueStats[]> {
89
- return unavailable('stats');
90
- },
91
- };
92
- }