effect-mq 0.3.2 → 0.4.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 (42) hide show
  1. package/README.md +102 -14
  2. package/dist/Job.d.ts +131 -9
  3. package/dist/Job.d.ts.map +1 -1
  4. package/dist/Job.js +81 -5
  5. package/dist/Job.js.map +1 -1
  6. package/dist/JobStore.d.ts +63 -2
  7. package/dist/JobStore.d.ts.map +1 -1
  8. package/dist/JobStore.js.map +1 -1
  9. package/dist/MemoryJobStore.d.ts.map +1 -1
  10. package/dist/MemoryJobStore.js +159 -119
  11. package/dist/MemoryJobStore.js.map +1 -1
  12. package/dist/Worker.d.ts +18 -0
  13. package/dist/Worker.d.ts.map +1 -1
  14. package/dist/Worker.js +37 -9
  15. package/dist/Worker.js.map +1 -1
  16. package/dist/drizzle-postgres/DrizzleJobStore.d.ts.map +1 -1
  17. package/dist/drizzle-postgres/DrizzleJobStore.js +239 -49
  18. package/dist/drizzle-postgres/DrizzleJobStore.js.map +1 -1
  19. package/dist/drizzle-postgres/schema.d.ts +2 -0
  20. package/dist/drizzle-postgres/schema.d.ts.map +1 -1
  21. package/dist/drizzle-postgres/schema.js +1 -0
  22. package/dist/drizzle-postgres/schema.js.map +1 -1
  23. package/dist/redis/RedisJobStore.d.ts.map +1 -1
  24. package/dist/redis/RedisJobStore.js +173 -36
  25. package/dist/redis/RedisJobStore.js.map +1 -1
  26. package/dist/redis/scripts.d.ts +24 -1
  27. package/dist/redis/scripts.d.ts.map +1 -1
  28. package/dist/redis/scripts.js +126 -21
  29. package/dist/redis/scripts.js.map +1 -1
  30. package/dist/testing/conformance.d.ts.map +1 -1
  31. package/dist/testing/conformance.js +266 -0
  32. package/dist/testing/conformance.js.map +1 -1
  33. package/package.json +1 -1
  34. package/src/Job.ts +268 -13
  35. package/src/JobStore.ts +77 -2
  36. package/src/MemoryJobStore.ts +102 -53
  37. package/src/Worker.ts +61 -9
  38. package/src/drizzle-postgres/DrizzleJobStore.ts +273 -66
  39. package/src/drizzle-postgres/schema.ts +2 -0
  40. package/src/redis/RedisJobStore.ts +236 -47
  41. package/src/redis/scripts.ts +153 -21
  42. package/src/testing/conformance.ts +350 -0
package/README.md CHANGED
@@ -75,8 +75,13 @@ What you get out of the box:
75
75
  - **Graceful shutdown** — interrupting a worker releases in-flight jobs back
76
76
  to `waiting` without consuming an attempt.
77
77
  - **Repeatable jobs** — durable cron/interval schedules
78
- (`MyJob.schedule(key, { cron })`) that fire exactly once per occurrence
79
- across any number of workers.
78
+ (`MyJob.schedule(key, { cron })`); each occurrence is claimed and enqueued
79
+ in one atomic store op, so ticks are exactly-once across any number of
80
+ workers.
81
+ - **Batch enqueue** — `MyJob.enqueueMany(payloads, options?)` inserts a
82
+ whole batch of plain items in one store round trip per chunk (multi-row
83
+ `INSERT` / one Lua script), with per-item idempotency and dedup semantics
84
+ intact (dedup-keyed items fall back to individual enqueues).
80
85
  - **Admin verbs** — `cancel` (including *running* jobs, whose handler fiber is
81
86
  interrupted cross-process), `promote` (delayed → now), and queue-level
82
87
  `pause`/`resume`.
@@ -88,12 +93,37 @@ What you get out of the box:
88
93
  - **Deduplication** — pending-dedup, throttle, debounce, and
89
94
  replace-while-delayed via a dedup key that never touches your job ids.
90
95
 
96
+ ## Batch enqueue
97
+
98
+ Fan-out inserts a whole batch of plain items in **one store round trip per
99
+ chunk** — a multi-row `INSERT` on Postgres, one Lua script on Redis (drivers
100
+ chunk very large batches):
101
+
102
+ ```ts
103
+ const ids = yield* GenerateInvoice.enqueueMany(
104
+ companies.map((company) => ({ companyId: company.id })),
105
+ { queue: "billing", at: nextBillingRun } // shared options
106
+ )
107
+ ```
108
+
109
+ Ids come back aligned with the payloads. Every item keeps full single-enqueue
110
+ semantics — `idempotencyKey`, `dedupe`, and `metadata` callbacks run per
111
+ payload, and duplicates are silent no-ops returning the existing id (items
112
+ that derive a dedup key run through the single-enqueue path individually, in
113
+ order). Options apply batch-wide; per-job `jobId`/`dedupe` are excluded at
114
+ the type level. The batch is intentionally *not* one transaction: a
115
+ mid-batch store failure can leave a subset applied, which is safe under
116
+ at-least-once — re-running a batch with deterministic ids skips what already
117
+ landed (store-assigned ids may re-insert).
118
+
91
119
  ## Repeatable jobs
92
120
 
93
121
  Schedules are durable rows in the store — not process-local timers — so they
94
- survive restarts and coordinate across workers. Ticks enqueue with a
95
- slot-deterministic job id (`sched/<key>/<slot>`), which makes every occurrence
96
- exactly-once no matter how many workers sweep:
122
+ survive restarts and coordinate across workers. Each occurrence is claimed
123
+ and its job (id `sched/<key>/<slot>`) enqueued in **one atomic store op** —
124
+ a compare-and-swap on the schedule's next occurrence — so every occurrence
125
+ fires exactly once no matter how many workers sweep, and no matter how
126
+ aggressively history retention prunes old tick jobs:
97
127
 
98
128
  ```ts
99
129
  // Create or replace (same key = replace; upsert is idempotent to deploy).
@@ -171,6 +201,32 @@ DrizzleJobStore.layer({ ...tables, historyTtl: { completed: "1 day", failed: "90
171
201
  The sweep honours `min(per-row keep.age, ceiling)`, so a job name that goes
172
202
  quiet is still pruned on the timer, not only when its group is next acked.
173
203
 
204
+ ## Tracing
205
+
206
+ Producer → handler traces connect **across processes and storage**: the
207
+ enqueue span's context (`traceId`/`spanId`/`sampled`) is persisted on the
208
+ job record, and the worker wraps every handler run in a span whose parent
209
+ is that external context (`Tracer.externalSpan`) — your invite handler's
210
+ span appears as a child of the HTTP request that scheduled it, even when
211
+ they ran hours apart on different machines. Run spans are named
212
+ `` `${name}.run` `` by default (configurable via
213
+ `Worker.layer({ handlerSpanName: (ctx) => ... })`) and carry
214
+ `effectMqJobId`, `effectMqQueue`, and `effectMqAttempt` attributes.
215
+
216
+ How the handler span attaches follows the delay: **immediate enqueues
217
+ continue the producer trace** (parent-child — the email handler sits inside
218
+ the signup request's waterfall), while **explicitly delayed/`at`-scheduled
219
+ jobs start their own trace with a causal link** back to the producer (a
220
+ five-day-wide parent-child trace renders badly and defeats tail sampling).
221
+ The policy keys off scheduling *intent* captured at enqueue — queue backlog
222
+ never changes your trace shapes — and every retry attempt of a job keeps
223
+ its mode. Override per worker with
224
+ `Worker.layer({ traceLinking: "auto" | "parent" | "link" | "none" })`. All
225
+ producer verbs (`enqueue`, `cancel`, `schedule`, ...) already run in their
226
+ own spans. Wire up any Effect tracer/exporter; without one, the overhead is
227
+ negligible. Poll-loop iterations are deliberately unspanned — the handler
228
+ run is the meaningful trace unit; per-claim spans would flood your backend.
229
+
174
230
  ## Metrics
175
231
 
176
232
  Workers and producers emit Effect `Metric` instruments (exported as the
@@ -248,6 +304,33 @@ store level). `idempotencyKey` still exists and is different on purpose: it
248
304
  makes the job id *itself* deterministic (permanent identity, joinable from
249
305
  your domain tables), while `dedupe` is temporal policy with its own lifecycle.
250
306
 
307
+ Keys also power the schedule/reschedule/cancel lifecycle for one-shot future
308
+ work — no job-id bookkeeping in your business logic:
309
+
310
+ ```ts
311
+ class SendInvite extends Job.make("send-invite", {
312
+ payload: { employeeId: Schema.String },
313
+ dedupe: ({ employeeId }) => ({ key: employeeId, replace: true })
314
+ }) {}
315
+
316
+ // Schedule for a wall-clock instant (any DateTime.Input — zero duration math):
317
+ yield* SendInvite.enqueue({ employeeId }, {
318
+ at: DateTime.makeZonedUnsafe(
319
+ { year: 2026, month: 8, day: 24, hours: 9 },
320
+ { timeZone: "America/New_York", adjustForTimeZone: true }
321
+ )
322
+ })
323
+
324
+ // Reschedule: the same idempotent call with a new time (replace moves it).
325
+ yield* SendInvite.enqueue({ employeeId }, { at: nextDay })
326
+
327
+ // They are not onboarding after all — cancel whatever is pending, if anything:
328
+ const wasPending = yield* SendInvite.cancelByKey(employeeId)
329
+ ```
330
+
331
+ `delay` and `at` are mutually exclusive (a compile error via the option
332
+ union); an `at` in the past runs immediately.
333
+
251
334
  Postgres users: dedup adds one table and one jobs column — add
252
335
  `export const jobDedupe = mqDedupe()` to your schema and `drizzle-kit
253
336
  generate` diffs both (the table and the new `dedupe_key` column) into one
@@ -482,13 +565,15 @@ Everything a job definition, an enqueue, and a worker can be tuned with:
482
565
  (any per-enqueue option below).
483
566
 
484
567
  **Per enqueue** (`enqueue`/`execute` options) — `jobId`, `queue`,
485
- `metadata`, `dedupe`, `delay`, `priority` (higher first), `attempts`,
486
- `backoff` (`fixed`/`exponential`), `keep` (`count`/`age`), `timeout`.
568
+ `metadata`, `dedupe`, `delay` OR `at` (absolute `DateTime.Input`; exclusive
569
+ by type), `priority` (higher first), `attempts`, `backoff`
570
+ (`fixed`/`exponential`), `keep` (`count`/`age`), `timeout`.
487
571
 
488
- **Job verbs** — `enqueue`, `execute` (enqueue + await the typed result),
489
- `poll`, `awaitResult`, `attempts` (the decoded run ledger), `retry`,
490
- `cancel`, `promote`, `schedule`/`unschedule`, `toLayer` (register the
491
- handler).
572
+ **Job verbs** — `enqueue`, `enqueueMany` (a whole batch, one store round
573
+ trip per chunk; same options minus per-job `jobId`/`dedupe`), `execute` (enqueue +
574
+ await the typed result), `poll`, `awaitResult`, `attempts` (the decoded run
575
+ ledger), `retry`, `cancel`, `cancelByKey` (by dedup key, idempotent),
576
+ `promote`, `schedule`/`unschedule`, `toLayer` (register the handler).
492
577
 
493
578
  **`Worker.layer(options)`** — all durations take `Duration.Input`:
494
579
 
@@ -504,6 +589,8 @@ handler).
504
589
  | `pollInterval` | 5s | idle fallback when no wake-up arrives (wake-ups are queue-filtered and push-based, so the default is fine even on Postgres) |
505
590
  | `scheduleSweepInterval` | 15s | how often to tick due repeatable-job schedules |
506
591
  | `queueMetricsInterval` | off | sample `store.counts()` per queue into the depth gauge |
592
+ | `handlerSpanName` | `` `${name}.run` `` | name of the span wrapping each handler run |
593
+ | `traceLinking` | `auto` | parent for immediate jobs, causal link for delayed ones (`parent`/`link`/`none` force a mode) |
507
594
  | `id` | random | identifier used in lock tokens |
508
595
 
509
596
  **Store construction** — every driver accepts `idGenerator`, `historyTtl`,
@@ -543,7 +630,7 @@ plain Effect, so it works with any test runner.
543
630
  Implement the `JobStore` service (one atomic seam: `enqueue`, `claim`, `ack`,
544
631
  `release`, `extendLocks`, `recoverStalled`, `awaitWake`, `getJob`,
545
632
  `getAttempts`, `list`, `retry`, `counts`, `remove`, `cancel`, `promote`,
546
- `pause`/`resume`/`pausedQueues`, and the schedule ops
633
+ `pause`/`resume`/`pausedQueues`, `cancelByDedupe`, and the schedule ops
547
634
  `upsertSchedule`/`removeSchedule`/`listSchedules`/`dueSchedules`/`advanceSchedule`)
548
635
  and run the conformance suite against it:
549
636
 
@@ -561,8 +648,9 @@ suite in this repo runs the same conformance tests against a real database.
561
648
 
562
649
  ## Roadmap
563
650
 
564
- Next up: trace propagation, a cross-process event stream, batch enqueue,
565
- custom drizzle columns, and parent-child fan-out. Full prioritized list:
651
+ Next up: drizzle schema customization (column renames, native id and
652
+ timestamp column types, a typed queue registry), a cross-process event
653
+ stream, and parent-child fan-out. Full prioritized list:
566
654
  [ROADMAP.md](https://github.com/TeamWarp/effect-mq/blob/main/ROADMAP.md);
567
655
  release history:
568
656
  [CHANGELOG.md](https://github.com/TeamWarp/effect-mq/blob/main/CHANGELOG.md).
package/dist/Job.d.ts CHANGED
@@ -30,7 +30,7 @@
30
30
  *
31
31
  * @since 0.1.0
32
32
  */
33
- import { type Context, Duration, Effect, type Exit, Layer, Option, Schedule, Schema } from "effect";
33
+ import { type Context, DateTime, Duration, Effect, type Exit, Layer, Option, Schedule, Schema } from "effect";
34
34
  import { type BackoffPolicy, JobId, type JobNotCancellableError, JobNotFoundError, type JobNotPromotableError, type JobNotRetryableError, type JobState, JobStore, type KeepPolicy, QueueName, ScheduleKey, type Service as StoreService, unrecoverable } from "./JobStore.ts";
35
35
  export {
36
36
  /**
@@ -102,6 +102,11 @@ export interface JobOptions {
102
102
  readonly priority?: number | undefined;
103
103
  /** Total attempts including the first run. Default 1 (no retries). */
104
104
  readonly attempts?: number | undefined;
105
+ /**
106
+ * Delay between retry attempts:
107
+ * `{ type: "fixed" | "exponential", delay, factor? }`. Default: retries
108
+ * are immediate.
109
+ */
105
110
  readonly backoff?: BackoffInput | undefined;
106
111
  /** Retention for terminal records. Default: keep forever. */
107
112
  readonly keep?: KeepInput | undefined;
@@ -129,15 +134,72 @@ export interface JobOptions {
129
134
  * @since 0.3.0
130
135
  */
131
136
  export type DedupeInput = string | {
137
+ /**
138
+ * The dedup key, scoped to this job's name (e.g. an employee id). Never
139
+ * changes the job id. Must be non-empty.
140
+ */
132
141
  readonly key: string;
142
+ /**
143
+ * Throttle window: at most one job per key per window, even after the
144
+ * keyed job completes. Without `ttl`, dedup lasts while the keyed job is
145
+ * pending (waiting/delayed/active).
146
+ */
133
147
  readonly ttl?: Duration.Input | undefined;
148
+ /**
149
+ * Debounce (requires `ttl`): every deduplicated enqueue pushes the window
150
+ * out again.
151
+ */
134
152
  readonly extend?: boolean | undefined;
153
+ /**
154
+ * Latest-wins while the keyed job is still delayed: the new enqueue's
155
+ * payload/metadata/priority/attempts/backoff/keep/timeout/delay replace
156
+ * the existing job's (same id, ledger preserved). A landed replace
157
+ * re-arms the `ttl` window. In any other state, normal dedup applies.
158
+ */
135
159
  readonly replace?: boolean | undefined;
136
160
  };
161
+ /**
162
+ * When the job becomes runnable: a relative `delay` OR an absolute `at`
163
+ * (any `DateTime.Input` — a `DateTime` from `DateTime.makeZonedUnsafe` for
164
+ * wall-clock-in-timezone instants, a `Date`, ISO string, epoch millis, or
165
+ * date parts). Setting both is a compile error; an `at` in the past runs
166
+ * immediately.
167
+ *
168
+ * @since 0.4.0
169
+ */
170
+ export type RunTimeInput = {
171
+ /**
172
+ * Run this long after enqueue (relative). Any `Duration.Input`:
173
+ * `"5 seconds"`, `Duration.minutes(10)`, millis, ...
174
+ *
175
+ * Mutually exclusive with `at` (setting both is a compile error).
176
+ */
177
+ readonly delay?: Duration.Input | undefined;
178
+ /** Set `delay` for relative times, or `at` (alone) for absolute ones. */
179
+ readonly at?: undefined;
180
+ } | {
181
+ /**
182
+ * Run at an absolute instant (any `DateTime.Input`) — no duration math:
183
+ *
184
+ * ```ts
185
+ * at: DateTime.makeZonedUnsafe(
186
+ * { year: 2026, month: 8, day: 24, hours: 9 },
187
+ * { timeZone: "America/New_York", adjustForTimeZone: true }
188
+ * )
189
+ * // also: a Date, ISO string, epoch millis, or { year, month, ... } parts
190
+ * ```
191
+ *
192
+ * An `at` in the past runs immediately. Mutually exclusive with `delay`
193
+ * (setting both is a compile error).
194
+ */
195
+ readonly at?: DateTime.DateTime.Input | undefined;
196
+ /** Set `at` for absolute times, or `delay` (alone) for relative ones. */
197
+ readonly delay?: undefined;
198
+ };
137
199
  /**
138
200
  * @since 0.1.0
139
201
  */
140
- export interface EnqueueOptions extends JobOptions {
202
+ export type EnqueueOptions = Omit<JobOptions, "delay"> & RunTimeInput & {
141
203
  /**
142
204
  * Explicit job id. Enqueueing an id that already exists is a no-op that
143
205
  * returns the existing id (idempotency). Overrides the definition's
@@ -150,7 +212,27 @@ export interface EnqueueOptions extends JobOptions {
150
212
  readonly metadata?: Readonly<Record<string, string>> | undefined;
151
213
  /** Deduplicate by key (see `DedupeInput`); overrides the definition's `dedupe`. */
152
214
  readonly dedupe?: DedupeInput | undefined;
153
- }
215
+ };
216
+ /**
217
+ * Options for `enqueueMany` — `EnqueueOptions` minus the per-job fields:
218
+ * `jobId` (a shared id would make every item after the first a duplicate)
219
+ * and `dedupe` (a shared key would collapse the batch into one job; per-item
220
+ * dedup still runs via the definition's `dedupe` callback).
221
+ *
222
+ * Built from parts rather than `Omit<EnqueueOptions, ...>`: a mapped type
223
+ * over the `delay`/`at` union would flatten it and lose their exclusivity.
224
+ *
225
+ * @since 0.4.0
226
+ */
227
+ export type EnqueueManyOptions = Omit<JobOptions, "delay"> & RunTimeInput & {
228
+ /** Send every item to a different queue than the definition's. */
229
+ readonly queue?: string | undefined;
230
+ /**
231
+ * Queryable business context, merged over each item's definition-derived
232
+ * `metadata` (the same overrides apply to every item).
233
+ */
234
+ readonly metadata?: Readonly<Record<string, string>> | undefined;
235
+ };
154
236
  interface ResolvedDefaults {
155
237
  readonly delayMs: number;
156
238
  readonly priority: number;
@@ -167,16 +249,32 @@ interface ResolvedDefaults {
167
249
  * @since 0.2.0
168
250
  */
169
251
  export interface ScheduleOptions<PayloadInput> {
252
+ /**
253
+ * Cron expression (5-field, e.g. `"0 9 * * 1"` = 9:00 every Monday).
254
+ * First fires at the next matching occurrence. Exactly one of `cron` or
255
+ * `every` must be set.
256
+ */
170
257
  readonly cron?: string | undefined;
258
+ /** IANA time zone for `cron` (e.g. `"America/New_York"`). Default UTC. */
171
259
  readonly tz?: string | undefined;
260
+ /**
261
+ * Fixed interval; first fires one interval from now and stays on that
262
+ * grid. Exactly one of `cron` or `every` must be set.
263
+ */
172
264
  readonly every?: Duration.Input | undefined;
265
+ /** The payload every occurrence is enqueued with. */
173
266
  readonly payload: PayloadInput;
174
267
  /** Queryable business context, merged over the definition's `metadata`. */
175
268
  readonly metadata?: Readonly<Record<string, string>> | undefined;
269
+ /** Priority for each occurrence. Higher runs first; default 0. */
176
270
  readonly priority?: number | undefined;
271
+ /** Attempt budget for each occurrence. Default 1. */
177
272
  readonly attempts?: number | undefined;
273
+ /** Retry backoff for each occurrence. */
178
274
  readonly backoff?: BackoffInput | undefined;
275
+ /** Retention for each occurrence's terminal record. */
179
276
  readonly keep?: KeepInput | undefined;
277
+ /** Per-run execution time limit for each occurrence. */
180
278
  readonly timeout?: Duration.Input | undefined;
181
279
  }
182
280
  /**
@@ -237,6 +335,22 @@ export interface Job<Name extends string, Payload extends AnyStructSchema, Succe
237
335
  * `idempotencyKey`) are a silent no-op returning the existing id.
238
336
  */
239
337
  readonly enqueue: (payload: Payload["~type.make.in"], options?: EnqueueOptions | undefined) => Effect.Effect<JobId, never, StoreId | Payload["EncodingServices"]>;
338
+ /**
339
+ * Queue many jobs in bulk — one store round trip per chunk of plain
340
+ * items; items whose definition derives a `dedupe` key fall back to
341
+ * individual enqueues, in order. Returns ids aligned with the payloads.
342
+ * Per-item semantics match `enqueue`: `idempotencyKey`, `dedupe`, and
343
+ * `metadata` callbacks run for each payload, and duplicates are silent
344
+ * no-ops returning the existing id. Options apply to every item
345
+ * (`jobId`/`dedupe` are excluded — a shared id or dedup key would
346
+ * collapse the batch into one job).
347
+ *
348
+ * The batch is not transactional: a store failure mid-batch may leave a
349
+ * subset (not necessarily a prefix) enqueued. Safe under at-least-once —
350
+ * re-running the batch skips already-inserted items when ids are
351
+ * deterministic (`idempotencyKey`); store-assigned ids may re-insert.
352
+ */
353
+ readonly enqueueMany: (payloads: ReadonlyArray<Payload["~type.make.in"]>, options?: EnqueueManyOptions | undefined) => Effect.Effect<ReadonlyArray<JobId>, never, StoreId | Payload["EncodingServices"]>;
240
354
  /** Read the current status of a previously enqueued job. */
241
355
  readonly poll: (jobId: JobId) => Effect.Effect<Option.Option<JobStatus<Success["Type"], Error["Type"]>>, never, StoreId | Success["DecodingServices"] | Error["DecodingServices"]>;
242
356
  /** The job's decoded run ledger, oldest first. */
@@ -261,15 +375,19 @@ export interface Job<Name extends string, Payload extends AnyStructSchema, Succe
261
375
  * heartbeat (latency ≤ `lockRenewInterval`).
262
376
  */
263
377
  readonly cancel: (jobId: JobId) => Effect.Effect<void, JobNotFoundError | JobNotCancellableError, StoreId>;
378
+ /**
379
+ * Cancel whatever pending job holds this dedup key (see `DedupeInput`).
380
+ * Idempotent: returns false when nothing pending holds the key.
381
+ */
382
+ readonly cancelByKey: (key: string) => Effect.Effect<boolean, never, StoreId>;
264
383
  /** Run a delayed job now. */
265
384
  readonly promote: (jobId: JobId) => Effect.Effect<void, JobNotFoundError | JobNotPromotableError, StoreId>;
266
385
  /**
267
- * Create or replace a durable repeatable schedule for this job. Ticks
268
- * enqueue with a slot-deterministic id, so schedules are exactly-once per
269
- * occurrence across all workers (assuming history retention windows
270
- * comfortably exceed the sweep interval a pruned tick job cannot dedup a
271
- * pathologically stale sweeper). Missed occurrences (downtime) collapse
272
- * into a single catch-up run.
386
+ * Create or replace a durable repeatable schedule for this job. Each
387
+ * occurrence is claimed and enqueued in one atomic store op, so ticks are
388
+ * exactly-once per occurrence across all workers regardless of history
389
+ * retention. Missed occurrences (downtime) collapse into a single
390
+ * catch-up run.
273
391
  *
274
392
  * Re-registering with an *unchanged* cadence (same `cron`/`tz`/`every`) is
275
393
  * a no-op for the next occurrence — deploy-time re-registration neither
@@ -299,8 +417,11 @@ export interface Any {
299
417
  * @since 0.1.0
300
418
  */
301
419
  export declare const make: <const Name extends string, Payload extends Schema.Struct.Fields | AnyStructSchema, Success extends Schema.Top = Schema.Void, Error extends Schema.Top = Schema.Never, StoreId = JobStore>(name: Name, options: {
420
+ /** The payload schema: a `Schema.Struct` or its bare fields object. */
302
421
  readonly payload: Payload;
422
+ /** Schema for the handler's success value (decodable via `awaitResult`/`attempts`). Default `Schema.Void`. */
303
423
  readonly success?: Success | undefined;
424
+ /** Schema for the handler's typed failure (round-trips through storage). Default `Schema.Never`. */
304
425
  readonly error?: Error | undefined;
305
426
  /**
306
427
  * Derive a stable job id from the payload. Enqueueing the same key twice
@@ -330,6 +451,7 @@ export declare const make: <const Name extends string, Payload extends Schema.St
330
451
  * Default: the default `JobStore`.
331
452
  */
332
453
  readonly store?: Context.Key<StoreId, StoreService> | undefined;
454
+ /** Default enqueue options (`delay`, `priority`, `attempts`, `backoff`, `keep`, `timeout`); per-enqueue options override. */
333
455
  readonly defaults?: JobOptions | undefined;
334
456
  }) => Job<Name, Payload extends Schema.Struct.Fields ? Schema.Struct<Payload> : Payload, Success, Error, StoreId>;
335
457
  //# sourceMappingURL=Job.d.ts.map
package/dist/Job.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Job.d.ts","sourceRoot":"","sources":["../src/Job.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,EAAS,KAAK,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,IAAI,EAAE,KAAK,EAAU,MAAM,EAAa,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC7H,OAAO,E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@ -30,7 +30,7 @@
30
30
  *
31
31
  * @since 0.1.0
32
32
  */
33
- import { Clock, Duration, Effect, Layer, Metric, Option, Predicate, Schedule, Schema } from "effect";
33
+ import { Clock, DateTime, Duration, Effect, Layer, Metric, Option, Predicate, Schedule, Schema } from "effect";
34
34
  import { JobCancelledError, JobId, JobNotFoundError, JobStore, nextOccurrence, QueueName, ScheduleKey, unrecoverable } from "./JobStore.js";
35
35
  import * as Metrics from "./Metrics.js";
36
36
  export {
@@ -111,7 +111,23 @@ const Proto = {
111
111
  };
112
112
  const dedupe = normalizeDedupe(options?.dedupe ?? this.dedupe?.(payload));
113
113
  const queue = options?.queue !== undefined ? QueueName(options.queue) : this.queue;
114
- return Schema.encodeEffect(this.payloadJsonSchema)(payload).pipe(Effect.orDie, Effect.flatMap((encoded) => Effect.flatMap(this.store, (store) => store.enqueue({
114
+ if (options?.at !== undefined && options.delay !== undefined) {
115
+ // Unrepresentable in TypeScript; guard untyped callers anyway.
116
+ throw new Error("effect-mq: set either `delay` or `at`, not both");
117
+ }
118
+ const delayMs = options?.at !== undefined
119
+ ? Effect.map(Clock.currentTimeMillis, (now) => Math.max(0, DateTime.toEpochMillis(DateTime.makeUnsafe(options.at ?? now)) - now))
120
+ : Effect.succeed(options?.delay !== undefined
121
+ ? Duration.toMillis(options.delay)
122
+ : this.defaults.delayMs);
123
+ // The enqueue span's context rides along on the record, so the
124
+ // handler's span joins the producing trace across processes.
125
+ const spanContext = Effect.currentSpan.pipe(Effect.map((span) => ({
126
+ traceId: span.traceId,
127
+ spanId: span.spanId,
128
+ sampled: span.sampled
129
+ })), Effect.catchTag("NoSuchElementError", () => Effect.succeed(undefined)));
130
+ return Effect.all([Schema.encodeEffect(this.payloadJsonSchema)(payload), delayMs, spanContext]).pipe(Effect.orDie, Effect.flatMap(([encoded, resolvedDelayMs, capturedSpan]) => Effect.flatMap(this.store, (store) => store.enqueue({
115
131
  id,
116
132
  name: this._tag,
117
133
  queue,
@@ -129,9 +145,12 @@ const Proto = {
129
145
  ? Duration.toMillis(options.timeout)
130
146
  : this.defaults.timeoutMs,
131
147
  dedupe,
132
- delayMs: options?.delay !== undefined
133
- ? Duration.toMillis(options.delay)
134
- : this.defaults.delayMs
148
+ // `delayed` records scheduling INTENT (not queue backlog), so
149
+ // the worker's auto trace-linking stays deterministic.
150
+ trace: capturedSpan === undefined
151
+ ? undefined
152
+ : { ...capturedSpan, delayed: resolvedDelayMs > 0 },
153
+ delayMs: resolvedDelayMs
135
154
  }))), Effect.orDie, Effect.tap((result) => Metric.update(Metrics.jobsEnqueued.pipe(Metric.withAttributes({
136
155
  name: this._tag,
137
156
  queue,
@@ -139,6 +158,58 @@ const Proto = {
139
158
  })), 1)), Effect.map((result) => result.id));
140
159
  }).pipe(Effect.withSpan(`${this._tag}.enqueue`, {}, { captureStackTrace: false }));
141
160
  },
161
+ enqueueMany(payloads, options) {
162
+ return Effect.suspend(() => {
163
+ const queue = options?.queue !== undefined ? QueueName(options.queue) : this.queue;
164
+ if (options?.at !== undefined && options.delay !== undefined) {
165
+ // Unrepresentable in TypeScript; guard untyped callers anyway.
166
+ throw new Error("effect-mq: set either `delay` or `at`, not both");
167
+ }
168
+ const delayMs = options?.at !== undefined
169
+ ? Effect.map(Clock.currentTimeMillis, (now) => Math.max(0, DateTime.toEpochMillis(DateTime.makeUnsafe(options.at ?? now)) - now))
170
+ : Effect.succeed(options?.delay !== undefined
171
+ ? Duration.toMillis(options.delay)
172
+ : this.defaults.delayMs);
173
+ const spanContext = Effect.currentSpan.pipe(Effect.map((span) => ({
174
+ traceId: span.traceId,
175
+ spanId: span.spanId,
176
+ sampled: span.sampled
177
+ })), Effect.catchTag("NoSuchElementError", () => Effect.succeed(undefined)));
178
+ const encodedAll = Effect.forEach(payloads, (fields) => {
179
+ const payload = this.payloadSchema.make(fields);
180
+ return Effect.map(Schema.encodeEffect(this.payloadJsonSchema)(payload), (encoded) => ({ payload, encoded }));
181
+ });
182
+ return Effect.all([encodedAll, delayMs, spanContext]).pipe(Effect.orDie, Effect.flatMap(([items, resolvedDelayMs, capturedSpan]) => Effect.flatMap(this.store, (store) => store.enqueueMany(items.map(({ encoded, payload }) => ({
183
+ id: this.idempotencyKey !== undefined
184
+ ? JobId(`${this._tag}/${this.idempotencyKey(payload)}`)
185
+ : undefined,
186
+ name: this._tag,
187
+ queue,
188
+ payload: encoded,
189
+ metadata: { ...this.metadata?.(payload), ...options?.metadata },
190
+ priority: options?.priority ?? this.defaults.priority,
191
+ attemptsMax: Math.max(1, options?.attempts ?? this.defaults.attempts),
192
+ backoff: options?.backoff !== undefined
193
+ ? normalizeBackoff(options.backoff)
194
+ : this.defaults.backoff,
195
+ keep: options?.keep !== undefined
196
+ ? normalizeKeep(options.keep)
197
+ : this.defaults.keep,
198
+ timeoutMs: options?.timeout !== undefined
199
+ ? Duration.toMillis(options.timeout)
200
+ : this.defaults.timeoutMs,
201
+ dedupe: normalizeDedupe(this.dedupe?.(payload)),
202
+ trace: capturedSpan === undefined
203
+ ? undefined
204
+ : { ...capturedSpan, delayed: resolvedDelayMs > 0 },
205
+ delayMs: resolvedDelayMs
206
+ }))))), Effect.orDie, Effect.tap((results) => {
207
+ const duplicates = results.filter((result) => result.duplicate).length;
208
+ const update = (duplicate, count) => count === 0 ? Effect.void : Metric.update(Metrics.jobsEnqueued.pipe(Metric.withAttributes({ name: this._tag, queue, duplicate })), count);
209
+ return Effect.andThen(update("false", results.length - duplicates), update("true", duplicates));
210
+ }), Effect.map((results) => results.map((result) => result.id)));
211
+ }).pipe(Effect.withSpan(`${this._tag}.enqueueMany`, {}, { captureStackTrace: false }));
212
+ },
142
213
  poll(jobId) {
143
214
  const self = this;
144
215
  return Effect.flatMap(this.store, (store) => store.getJob(jobId).pipe(Effect.orDie, Effect.flatMap(Option.match({
@@ -203,6 +274,9 @@ const Proto = {
203
274
  cancel(jobId) {
204
275
  return Effect.flatMap(this.store, (store) => store.cancel(jobId).pipe(Effect.catchTag("JobStoreError", (error) => Effect.die(error)))).pipe(Effect.withSpan(`${this._tag}.cancel`, { attributes: { jobId } }, { captureStackTrace: false }));
205
276
  },
277
+ cancelByKey(key) {
278
+ return Effect.flatMap(this.store, (store) => store.cancelByDedupe(this._tag, key).pipe(Effect.catchTag("JobStoreError", (error) => Effect.die(error)))).pipe(Effect.withSpan(`${this._tag}.cancelByKey`, { attributes: { key } }, { captureStackTrace: false }));
279
+ },
206
280
  promote(jobId) {
207
281
  return Effect.flatMap(this.store, (store) => store.promote(jobId).pipe(Effect.catchTag("JobStoreError", (error) => Effect.die(error)))).pipe(Effect.withSpan(`${this._tag}.promote`, { attributes: { jobId } }, { captureStackTrace: false }));
208
282
  },
@@ -257,12 +331,14 @@ const Proto = {
257
331
  };
258
332
  const boundMethods = [
259
333
  "enqueue",
334
+ "enqueueMany",
260
335
  "poll",
261
336
  "attempts",
262
337
  "awaitResult",
263
338
  "execute",
264
339
  "retry",
265
340
  "cancel",
341
+ "cancelByKey",
266
342
  "promote",
267
343
  "schedule",
268
344
  "unschedule",