@shivaedev/effect-pg-boss 0.5.0 → 0.6.1

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 (56) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +61 -12
  3. package/dist/server/client.d.ts +7 -1
  4. package/dist/server/client.d.ts.map +1 -1
  5. package/dist/server/client.js.map +1 -1
  6. package/dist/server/definition.d.ts +5 -5
  7. package/dist/server/definition.d.ts.map +1 -1
  8. package/dist/server/error.d.ts +10 -1
  9. package/dist/server/error.d.ts.map +1 -1
  10. package/dist/server/error.js +5 -0
  11. package/dist/server/error.js.map +1 -1
  12. package/dist/server/health.d.ts +6 -0
  13. package/dist/server/health.d.ts.map +1 -1
  14. package/dist/server/health.js.map +1 -1
  15. package/dist/server/internal/countsFor.d.ts +5 -0
  16. package/dist/server/internal/countsFor.d.ts.map +1 -0
  17. package/dist/server/internal/countsFor.js +27 -0
  18. package/dist/server/internal/countsFor.js.map +1 -0
  19. package/dist/server/internal/ensureQueue.d.ts +4 -0
  20. package/dist/server/internal/ensureQueue.d.ts.map +1 -0
  21. package/dist/server/internal/ensureQueue.js +27 -0
  22. package/dist/server/internal/ensureQueue.js.map +1 -0
  23. package/dist/server/internal/jobControl.d.ts +5 -0
  24. package/dist/server/internal/jobControl.d.ts.map +1 -0
  25. package/dist/server/internal/jobControl.js +35 -0
  26. package/dist/server/internal/jobControl.js.map +1 -0
  27. package/dist/server/internal/register.d.ts +2 -1
  28. package/dist/server/internal/register.d.ts.map +1 -1
  29. package/dist/server/internal/register.js +9 -25
  30. package/dist/server/internal/register.js.map +1 -1
  31. package/dist/server/internal/service.d.ts +1 -1
  32. package/dist/server/internal/service.d.ts.map +1 -1
  33. package/dist/server/internal/service.js +11 -5
  34. package/dist/server/internal/service.js.map +1 -1
  35. package/dist/server/internal/tracing.d.ts +6 -0
  36. package/dist/server/internal/tracing.d.ts.map +1 -0
  37. package/dist/server/internal/tracing.js +37 -0
  38. package/dist/server/internal/tracing.js.map +1 -0
  39. package/dist/server/service.d.ts +8 -5
  40. package/dist/server/service.d.ts.map +1 -1
  41. package/dist/server/service.js +1 -1
  42. package/dist/server/service.js.map +1 -1
  43. package/docs/north-star.md +1 -1
  44. package/docs/roadmap.md +9 -3
  45. package/package.json +2 -2
  46. package/src/server/client.ts +17 -1
  47. package/src/server/definition.ts +5 -5
  48. package/src/server/error.ts +10 -1
  49. package/src/server/health.ts +7 -0
  50. package/src/server/internal/countsFor.ts +33 -0
  51. package/src/server/internal/ensureQueue.ts +29 -0
  52. package/src/server/internal/jobControl.ts +47 -0
  53. package/src/server/internal/register.ts +10 -26
  54. package/src/server/internal/service.ts +17 -6
  55. package/src/server/internal/tracing.ts +44 -0
  56. package/src/server/service.ts +13 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.1 - 2026-10-17
4
+
5
+ ### Fixed
6
+
7
+ - Run each queue and scheduled job attempt inside a root consumer span named for its queue, with job identity, attempt and retry-count attributes and handler failures. Handler steps share that job trace.
8
+ - Persist the enqueueing Effect span context in pg-boss job data and link the job span to it. Handlers and `getJob` still decode the original payload Schema; direct pg-boss data readers see an envelope for traced sends.
9
+
10
+ ## 0.6.0 - 2026-10-17
11
+
12
+ ### Added
13
+
14
+ - `PgBossService.counts(queue)` returns live `QueueCounts` without waiting for the pg-boss monitor; `health` keeps using cached counts.
15
+ - `PgBossService.getJob(queue, id)` returns optional job metadata with Schema-decoded payloads and decoding service requirements. `PgBossService.retry(queue, id)` reprocesses failed or retry-waiting jobs under their original ID.
16
+ - `PgBossQueueOptionsError` identifies immutable queue option conflicts during Layer acquisition. Custom `PgBossClient` factories can provide optional native `findJobs`, `retry`, `update`, `getDb` and `updateQueue` capabilities for the new operations.
17
+
18
+ ### Fixed
19
+
20
+ - Queue and schedule definitions accept pg-boss's full `Queue` options except the owned name and dead-letter setup, including notification delivery, policy, partitioning, heartbeat and backlog warnings.
21
+ - Startup reconciles declared mutable queue settings through `updateQueue`, including expiry and retry limits, so they reach existing queues after restart.
22
+
3
23
  ## 0.5.0 - 2026-10-13
4
24
 
5
25
  ### Added
package/README.md CHANGED
@@ -31,7 +31,7 @@ A **queue definition** names a pg-boss queue and the Schema of its payload. Appl
31
31
 
32
32
  A **schedule definition** describes a queue with a cron trigger. `schedule.run(effect)` pairs it with an Effect that needs no payload. Queue workers and scheduled workers are **registrations**: the values you put in the jobs Layer's `jobs` list.
33
33
 
34
- The application creates one jobs service with `makePgBoss(identifier)`. Its Layer starts a client, registers the job list and captures the services those workers need. The Layer's scope owns its client reference and releases it when the scope ends; the final reference closes the client. Callers use the jobs service to enqueue a decoded payload or read queue health.
34
+ The application creates one jobs service with `makePgBoss(identifier)`. Its Layer starts a client, registers the job list and captures the services those workers need. The Layer's scope owns its client reference and releases it when the scope ends; the final reference closes the client. Callers use the jobs service to enqueue a decoded payload, look up or retry a job, or read queue health and live counts.
35
35
 
36
36
  Use a distinct literal identifier for each jobs service. The service and its Layer keep that identifier in their types, so providing a Layer for a different identifier leaves the required jobs service unprovided at compile time.
37
37
 
@@ -116,7 +116,7 @@ export const jobsLayer = (databaseUrl: string) =>
116
116
  }).pipe(Layer.provide(MailLive));
117
117
  ```
118
118
 
119
- The constructor options belong to pg-boss. `jobs` is the complete list of registrations for this Layer. The Layer captures `MailLive` for both the queue handler and the scheduled Effect. A startup or registration failure fails Layer acquisition with `PgBossError` and releases its acquired client reference. A shared client stays running while another scope still owns a reference.
119
+ The constructor options belong to pg-boss. `jobs` is the complete list of registrations for this Layer. The Layer captures `MailLive` for both the queue handler and the scheduled Effect. A startup or registration failure fails Layer acquisition with `PgBossError` or `PgBossQueueOptionsError` and releases its acquired client reference. A shared client stays running while another scope still owns a reference.
120
120
 
121
121
  Keep the Layer in the application's worker runtime scope. A short scope is useful for an acquisition or health check; a worker process needs its scope to remain open while it handles jobs.
122
122
 
@@ -154,6 +154,14 @@ Provide `Jobs` through the application's existing runtime. `enqueue` takes the d
154
154
 
155
155
  `PgBossPayloadError` names a payload boundary failure; malformed durable input is rejected before the worker's domain code runs. The PostgreSQL test also checks that invalid data sent directly to pg-boss reaches the dead-letter queue without reaching the handler.
156
156
 
157
+ ### Trace jobs
158
+
159
+ Each queue or scheduled job attempt runs in one root consumer span named for its queue. The span encloses payload decoding and the whole handler, so top-level `Effect.fn` steps are children of the job span. Its attributes include `job.id`, `job.queue`, `job.name`, the one-based `job.attempt` and pg-boss's zero-based `job.retry_count`. A failed handler ends the span with its failure.
160
+
161
+ `enqueue` captures the current Effect span, including an external parent span, when present. It stores that context in a typed envelope in pg-boss's existing job `data`; the adapter unwraps the envelope before Schema decoding in the handler and `getJob`, so the application's payload Schema stays unchanged. Jobs sent without a span keep their ordinary encoded payload, and workers also accept those unwrapped jobs. Direct pg-boss data readers see the envelope for traced sends.
162
+
163
+ The consumer span links to the sender rather than sharing its parent trace, following OpenTelemetry messaging conventions for asynchronous processing. Each retry gets its own job trace. Provide the application's Effect tracer when building the worker Layer; the worker uses that captured tracer. The PostgreSQL tracing tests use Effect's in-memory tracer and a producer that shuts down before its worker starts; the scheduled-worker test checks the same span boundary with a fake client.
164
+
157
165
  ### Read health
158
166
 
159
167
  ```ts
@@ -173,7 +181,35 @@ export const readJobCounts = Effect.gen(function* () {
173
181
  });
174
182
  ```
175
183
 
176
- `health` exposes pg-boss queue counts as data. Its total fields include the registered queue's active, failed, queued and ready counts, plus the dead-letter queue's queued count. Decide in the application which values affect an HTTP health response or an alert.
184
+ `health` exposes pg-boss cached queue counts as data. It stays cheap and follows the pg-boss monitor interval; it does not establish that a queue has just drained. Its total fields include the registered queue's active, failed, queued and ready counts, plus the dead-letter queue's queued count. Decide in the application which values affect an HTTP health response or an alert.
185
+
186
+ ### Read live counts and retry a job
187
+
188
+ ```ts
189
+ import { Effect, Option } from "effect";
190
+ import { SendEmail } from "./jobs.ts";
191
+ import { Jobs } from "./services.ts";
192
+
193
+ export const inspectEmail = (id: string) => Effect.gen(function* () {
194
+ const jobs = yield* Jobs;
195
+ const job = yield* jobs.getJob(SendEmail, id);
196
+ if (Option.isSome(job) && job.value.state === "failed") {
197
+ yield* jobs.retry(SendEmail, id);
198
+ }
199
+ const counts = yield* jobs.counts(SendEmail);
200
+ return counts.queuedCount === 0 && counts.activeCount === 0;
201
+ });
202
+ ```
203
+
204
+ `counts(queue)` reads the job table directly on each call. `queuedCount` includes created and retry-waiting jobs, including future jobs; `activeCount` counts running jobs, `failedCount` counts retained failures, and `totalCount` includes retained terminal jobs. A queue has drained when queued and active counts are both zero. These counts are a snapshot, so a producer can enqueue more work after the query returns.
205
+
206
+ `getJob(queue, id)` returns `None` when the ID is absent, or `Some` pg-boss job metadata with `data` decoded by the queue's Schema. Invalid stored data fails with `PgBossPayloadError`, and the Effect requires the Schema's decoding services. `retry(queue, id)` reuses the original ID: it makes a failed job eligible for another attempt and pulls a retry-waiting job forward to run now. Missing IDs and jobs in other states are left unchanged. It does not remove an earlier copy from the dead-letter queue.
207
+
208
+ ### Queue settings on startup
209
+
210
+ `queue` accepts pg-boss `Queue` options except `name` and `deadLetter`, which the definition and adapter own. For prompt delivery, set `queue: { notify: true }` and enable `useListenNotify: true` in the worker Layer's constructor options. The PostgreSQL notification test waits for an idle worker with a ten-second polling interval and verifies delivery within 1.5 seconds.
211
+
212
+ Startup creates missing queues and reconciles declared settings on existing queues through `updateQueue`. Unspecified settings keep their stored values; the adapter always supplies its default retry settings and dead-letter destination. Changing an explicitly declared `policy` or `partition` on an existing queue fails startup with `PgBossQueueOptionsError`; its `queue`, `options` and message identify the conflict. Queue setting changes apply to subsequently enqueued jobs. Schedule queues follow the same registration path.
177
213
 
178
214
  ### Share a client between Layer builds
179
215
 
@@ -195,7 +231,17 @@ Overlapping Layer builds with the same `clientCacheKey` share one started client
195
231
 
196
232
  ### Separate producers and workers
197
233
 
198
- Pass a queue definition directly in `Jobs.layer({ jobs: [SendEmail] })` to create its queue and dead-letter queue without starting a consumer. A separate worker process registers `SendEmail.handle(...)` against the same database. Producer queues use the same retry options and appear in `health`; only worker registrations capture handler services.
234
+ Pass a queue definition directly in the jobs Layer to create its queue and dead-letter queue without starting a consumer:
235
+
236
+ ```ts
237
+ import { SendEmail } from "./jobs.ts";
238
+ import { Jobs } from "./services.ts";
239
+
240
+ export const producerLayer = (databaseUrl: string) =>
241
+ Jobs.layer({ connectionString: databaseUrl, jobs: [SendEmail] });
242
+ ```
243
+
244
+ Provide this Layer to the request runtime and call `jobs.enqueue(SendEmail, { userId })` as above. A separate worker process registers `SendEmail.handle(...)` against the same database. Producer queues use the same retry options and appear in `health`; only worker registrations capture handler services. The PostgreSQL producer test creates both queues through this Layer, enqueues a transformed payload, and observes a failing worker exhaust two retries before the job reaches its dead-letter queue.
199
245
 
200
246
  ### API
201
247
 
@@ -205,18 +251,21 @@ Import the module that defines the name; the package has no root entry.
205
251
  | --- | --- |
206
252
  | `@shivaedev/effect-pg-boss/definition.ts` | `defineQueue`, `defineSchedule`, `jobContext`; `DefineQueueOptions`, `DefineScheduleOptions`, `JobContext`, `JobPayloadSchema`, `JobRegistration`, `QueueDefinition`, `QueueWorker`, `RegistrationRequirements`, `ScheduleDefinition`, `ScheduledWorker` |
207
253
  | `@shivaedev/effect-pg-boss/service.ts` | `makePgBoss`; `PgBossDefinition`, `PgBossLayerOptions`, `PgBossService` |
208
- | `@shivaedev/effect-pg-boss/health.ts` | `deadLetterQueueName`; `JobsHealth`, `QueueHealth` |
209
- | `@shivaedev/effect-pg-boss/error.ts` | `PgBossError`, `PgBossPayloadError`, `toPgBossError`; `PgBossOperation` |
254
+ | `@shivaedev/effect-pg-boss/health.ts` | `deadLetterQueueName`; `JobsHealth`, `QueueCounts`, `QueueHealth` |
255
+ | `@shivaedev/effect-pg-boss/error.ts` | `PgBossError`, `PgBossPayloadError`, `PgBossQueueOptionsError`, `toPgBossError`; `PgBossOperation` |
210
256
  | `@shivaedev/effect-pg-boss/client.ts` | `defaultClientFactory`; `PgBossClient`, `PgBossClientFactory` |
211
257
 
212
- The definition options keep the pg-boss names: `queue` uses `QueueOptions` except `deadLetter`, `worker` uses `WorkOptions`, and a schedule's `schedule` uses `ScheduleOptions`. A queue also requires `name` and `schema`; a schedule requires `name` and `cron`.
258
+ The definition options keep the pg-boss names: `queue` uses `Queue` except `name` and `deadLetter`, `worker` uses `WorkOptions`, and a schedule's `schedule` uses `ScheduleOptions`. A queue also requires `name` and `schema`; a schedule requires `name` and `cron`.
213
259
 
214
- The application's service has two operations:
260
+ The application's service has these operations:
215
261
 
216
262
  - `enqueue(queue, payload, options?)`: an Effect returning `Option.Option<string>`, with `PgBossError | PgBossPayloadError` in its error type. Its options use pg-boss `SendOptions`.
217
- - `health`: an Effect returning `JobsHealth`, with `PgBossError` in its error type.
263
+ - `health`: an Effect returning cached `JobsHealth`, with `PgBossError` in its error type.
264
+ - `counts(queue)`: an Effect returning live `QueueCounts`, with `PgBossError` in its error type.
265
+ - `getJob(queue, id)`: an Effect returning `Option.Option<JobWithMetadata<Payload>>` with decoded payload data, `PgBossError | PgBossPayloadError` in its error type and the Schema's decoding services in its requirements.
266
+ - `retry(queue, id)`: an Effect returning `void`, with `PgBossError` in its error type.
218
267
 
219
- `Jobs.layer(options)` accepts pg-boss `ConstructorOptions` plus `jobs`, optional `clientCacheKey`, optional `clientFactory`, optional `onError` and optional `stop`. The factory type accepts constructor options and returns `PgBossClient`; `onError` has the type `(error: Error) => Effect.Effect<unknown, never, R>`; `stop` uses pg-boss `StopOptions`.
268
+ `Jobs.layer(options)` accepts pg-boss `ConstructorOptions` plus `jobs`, optional `clientCacheKey`, optional `clientFactory`, optional `onError` and optional `stop`. The factory type accepts constructor options and returns `PgBossClient`. Custom clients can supply the optional native capabilities `findJobs`, `retry`, `update`, `getDb` and `updateQueue` for lookup, retry, live counts and reconciliation; a requested operation fails with `PgBossError` if its required capability is absent. `onError` has the type `(error: Error) => Effect.Effect<unknown, never, R>`; `stop` uses pg-boss `StopOptions`.
220
269
 
221
270
  `onError` handles pg-boss client `error` events using the services captured by the Layer. The Layer's requirement type includes the workers' services, the workers' payload Schemas' `DecodingServices` and the callback's services. `enqueue` includes the payload Schema's `EncodingServices` in its requirement type.
222
271
 
@@ -227,12 +276,12 @@ The application's service has two operations:
227
276
  ### Install, setup and limits
228
277
 
229
278
  ```sh
230
- pnpm add @shivaedev/effect-pg-boss effect@4.0.4 pg-boss@12.23.1
279
+ pnpm add @shivaedev/effect-pg-boss effect@4.0.4 pg-boss@12.37.0
231
280
  ```
232
281
 
233
282
  The package requires Node.js 24 or later and PostgreSQL. `effect` and `pg-boss` are peers; use versions that satisfy the package's published peer ranges.
234
283
 
235
- Provide the database connection and job registrations at the application runtime boundary. Application services own the domain work and provider calls; pg-boss owns queue execution. Treat enqueueing and an application database transaction as separate operations, and choose any required transaction or outbox policy in the application.
284
+ Provide the database connection and job registrations at the application runtime boundary. Application services own the domain work and provider calls; pg-boss owns queue execution. Treat enqueueing and an application database transaction as separate operations. Enqueue after the application write commits, and handle queue failures in the application so they cannot roll back the write. The starter logs enqueue failures and returns the saved note; a failed enqueue leaves its word count pending. The package supplies no application transaction adapter.
236
285
 
237
286
  For package development, the real PostgreSQL test uses `PLATFORM_EFFECT_PG_BOSS_TEST_DATABASE_URL` and skips when the variable is absent. A skipped test does not establish durable queue behavior. Fake-client tests cover registration and lifecycle calls; they do not establish real cron execution, retry timing or deployment behavior. The package is built for ShivaeDev applications and may change without a deprecation period.
238
287
 
@@ -1,14 +1,20 @@
1
- import type { ConstructorOptions, Job, Queue, QueueResult, ScheduleOptions, SendOptions, StopOptions, WorkOptions } from "pg-boss";
1
+ import type { ConstructorOptions, FindJobsOptions, Job, JobWithMetadata, Queue, QueueResult, ScheduleOptions, SendOptions, StopOptions, WorkOptions } from "pg-boss";
2
+ import { PgBoss } from "pg-boss";
2
3
  export interface PgBossClient {
3
4
  readonly createQueue: (name: string, options?: Omit<Queue, "name">) => Promise<void>;
5
+ readonly findJobs?: (name: string, options?: FindJobsOptions) => Promise<readonly JobWithMetadata<unknown>[]>;
6
+ readonly getDb?: PgBoss["getDb"];
4
7
  readonly getQueue: (name: string) => Promise<QueueResult | null>;
5
8
  readonly off: (event: "error", listener: (error: Error) => void) => unknown;
6
9
  readonly offWork: (name: string) => Promise<void>;
7
10
  readonly on: (event: "error", listener: (error: Error) => void) => unknown;
11
+ readonly retry?: PgBoss["retry"];
8
12
  readonly schedule: (name: string, cron: string, data?: object | null, options?: ScheduleOptions) => Promise<void>;
9
13
  readonly send: (name: string, data?: object | null, options?: SendOptions) => Promise<string | null>;
10
14
  readonly start: () => Promise<unknown>;
11
15
  readonly stop: (options?: StopOptions) => Promise<void>;
16
+ readonly update?: PgBoss["update"];
17
+ readonly updateQueue?: PgBoss["updateQueue"];
12
18
  readonly work: (name: string, options: WorkOptions, handler: (jobs: readonly Job<unknown>[]) => Promise<unknown>) => Promise<string>;
13
19
  }
14
20
  export type PgBossClientFactory = (options: ConstructorOptions) => PgBossClient;
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/server/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGnI,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACrF,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACjE,QAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,KAAK,OAAO,CAAC;IAC5E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,IAAI,CAAC,CAAC;IAClH,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,OAAO,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACrG,QAAQ,CAAC,KAAK,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IACvC,QAAQ,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IACnC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,aAAa,CAAC,CAAC;IAC7C,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,GAAG,CAAC,OAAO,CAAC,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CACrI;AAED,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,EAAE,kBAAkB,KAAK,YAAY,CAAC;AAEhF,eAAO,MAAM,oBAAoB,EAAE,mBAAsD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/server/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAiBjC,MAAM,CAAC,MAAM,oBAAoB,GAAwB,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC"}
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/server/client.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAsBjC,MAAM,CAAC,MAAM,oBAAoB,GAAwB,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import type { Effect, Schema } from "effect";
2
- import type { Job, QueueOptions, ScheduleOptions, WorkOptions } from "pg-boss";
2
+ import type { Job, Queue, ScheduleOptions, WorkOptions } from "pg-boss";
3
3
  export interface JobPayloadSchema extends Schema.Top {
4
4
  readonly Encoded: object;
5
5
  readonly Type: object;
@@ -15,7 +15,7 @@ export interface QueueDefinition<Name extends string = string, Payload extends J
15
15
  readonly _tag: "QueueDefinition";
16
16
  readonly handle: <E, R>(handler: (payload: Schema.Schema.Type<Payload>, job: JobContext) => Effect.Effect<unknown, E, R>) => QueueWorker<Payload, R>;
17
17
  readonly name: Name;
18
- readonly queueOptions: Omit<QueueOptions, "deadLetter">;
18
+ readonly queueOptions: Omit<Queue, "name" | "deadLetter">;
19
19
  readonly schema: Payload;
20
20
  readonly workerOptions: WorkOptions;
21
21
  }
@@ -31,7 +31,7 @@ export interface ScheduleDefinition<Name extends string = string> {
31
31
  readonly _tag: "ScheduleDefinition";
32
32
  readonly cron: string;
33
33
  readonly name: Name;
34
- readonly queueOptions: Omit<QueueOptions, "deadLetter">;
34
+ readonly queueOptions: Omit<Queue, "name" | "deadLetter">;
35
35
  readonly run: <E, R>(effect: Effect.Effect<unknown, E, R>) => ScheduledWorker<R>;
36
36
  readonly scheduleOptions: ScheduleOptions;
37
37
  readonly workerOptions: WorkOptions;
@@ -44,7 +44,7 @@ export interface ScheduledWorker<Requirements = unknown> {
44
44
  export type RegistrationRequirements<Registrations extends readonly JobRegistration[]> = Registrations[number] extends infer Registration ? Registration extends QueueWorker<infer Payload, infer Requirements> ? Requirements | Payload["DecodingServices"] : Registration extends ScheduledWorker<infer Requirements> ? Requirements : never : never;
45
45
  export interface DefineQueueOptions<Name extends string, Payload extends JobPayloadSchema> {
46
46
  readonly name: Name;
47
- readonly queue?: Omit<QueueOptions, "deadLetter">;
47
+ readonly queue?: Omit<Queue, "name" | "deadLetter">;
48
48
  readonly schema: Payload;
49
49
  readonly worker?: WorkOptions;
50
50
  }
@@ -52,7 +52,7 @@ export declare const defineQueue: <const Name extends string, const Payload exte
52
52
  export interface DefineScheduleOptions<Name extends string> {
53
53
  readonly cron: string;
54
54
  readonly name: Name;
55
- readonly queue?: Omit<QueueOptions, "deadLetter">;
55
+ readonly queue?: Omit<Queue, "name" | "deadLetter">;
56
56
  readonly schedule?: ScheduleOptions;
57
57
  readonly worker?: WorkOptions;
58
58
  }
@@ -1 +1 @@
1
- {"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../src/server/definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE/E,MAAM,WAAW,gBAAiB,SAAQ,MAAM,CAAC,GAAG;IACnD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IACzC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;CAC7B;AAED,MAAM,WAAW,eAAe,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,EAAE,OAAO,SAAS,gBAAgB,GAAG,gBAAgB;IACjH,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EACrB,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,M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,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC9B;AAED,eAAO,MAAM,WAAW,GAAI,KAAK,CAAC,IAAI,SAAS,MAAM,EAAE,KAAK,CAAC,OAAO,SAAS,gBAAgB,WACnF,kBAAkB,CAAC,IAAI,EAAE,OAAO,CAAC,KACxC,eAAe,CAAC,IAAI,EAAE,OAAO,CAe/B,CAAC;AAEF,MAAM,WAAW,qBAAqB,CAAC,IAAI,SAAS,MAAM;IACzD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAAC,CAAC;IACpD,QAAQ,CAAC,QAAQ,CAAC,EAAE,eAAe,CAAC;IACpC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC9B;AAED,eAAO,MAAM,cAAc,GAAI,KAAK,CAAC,IAAI,SAAS,MAAM,WAAW,qBAAqB,CAAC,IAAI,CAAC,KAAG,kBAAkB,CAAC,IAAI,CAgBvH,CAAC;AAEF,eAAO,MAAM,UAAU,QAAS,GAAG,CAAC,OAAO,CAAC,KAAG,UAM7C,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { Redacted } from "effect";
2
- export type PgBossOperation = "enqueue" | "health" | "register" | "start" | "stop";
2
+ export type PgBossOperation = "counts" | "enqueue" | "getJob" | "health" | "register" | "retry" | "start" | "stop";
3
3
  declare const PgBossError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
4
4
  readonly _tag: "PgBossError";
5
5
  } & Readonly<A>;
@@ -9,6 +9,15 @@ export declare class PgBossError extends PgBossError_base<{
9
9
  readonly original: Redacted.Redacted<unknown>;
10
10
  }> {
11
11
  }
12
+ declare const PgBossQueueOptionsError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
13
+ readonly _tag: "PgBossQueueOptionsError";
14
+ } & Readonly<A>;
15
+ export declare class PgBossQueueOptionsError extends PgBossQueueOptionsError_base<{
16
+ readonly queue: string;
17
+ readonly options: readonly ("partition" | "policy")[];
18
+ }> {
19
+ get message(): string;
20
+ }
12
21
  declare const PgBossPayloadError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
13
22
  readonly _tag: "PgBossPayloadError";
14
23
  } & Readonly<A>;
@@ -1 +1 @@
1
- {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/server/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAExC,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,QAAQ,GAAG,UAAU,GAAG,OAAO,GAAG,MAAM,CAAC;;;;AAEnF,qBAAa,WAAY,SAAQ,iBAAgC;IAChE,QAAQ,CAAC,SAAS,EAAE,eAAe,CAAC;IACpC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;CAC9C,CAAC;CAAG;;;;AAEL,qBAAa,kBAAmB,SAAQ,wBAAuC;IAC9E,QAAQ,CAAC,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAAC;IACxC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;CAC9C,CAAC;CAAG;AAEL,eAAO,MAAM,aAAa,cAAe,eAAe,SAAS,OAAO,UAAU,MAAM,KAAG,WAKxF,CAAC"}
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/server/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAExC,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;;;;AAEnH,qBAAa,WAAY,SAAQ,iBAAgC;IAChE,QAAQ,CAAC,SAAS,EAAE,eAAe,CAAC;IACpC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;CAC9C,CAAC;CAAG;;;;AAEL,qBAAa,uBAAwB,SAAQ,6BAA4C;IACxF,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC,WAAW,GAAG,QAAQ,CAAC,EAAE,CAAC;CACtD,CAAC;IACD,IAAa,OAAO,IAAI,MAAM,CAE7B;CACD;;;;AAED,qBAAa,kBAAmB,SAAQ,wBAAuC;IAC9E,QAAQ,CAAC,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAAC;IACxC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;CAC9C,CAAC;CAAG;AAEL,eAAO,MAAM,aAAa,cAAe,eAAe,SAAS,OAAO,UAAU,MAAM,KAAG,WAKxF,CAAC"}
@@ -1,6 +1,11 @@
1
1
  import { Data, Redacted } from "effect";
2
2
  export class PgBossError extends Data.TaggedError("PgBossError") {
3
3
  }
4
+ export class PgBossQueueOptionsError extends Data.TaggedError("PgBossQueueOptionsError") {
5
+ get message() {
6
+ return `Queue ${this.queue} cannot change options after creation: ${this.options.join(", ")}`;
7
+ }
8
+ }
4
9
  export class PgBossPayloadError extends Data.TaggedError("PgBossPayloadError") {
5
10
  }
6
11
  export const toPgBossError = (operation, error, queue) => new PgBossError({
@@ -1 +1 @@
1
- {"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/server/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAIxC,MAAM,OAAO,WAAY,SAAQ,IAAI,CAAC,WAAW,CAAC,aAAa,CAI7D;CAAG;AAEL,MAAM,OAAO,kBAAmB,SAAQ,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAI3E;CAAG;AAEL,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,SAA0B,EAAE,KAAc,EAAE,KAAc,EAAe,EAAE,CACxG,IAAI,WAAW,CAAC;IACf,SAAS;IACT,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC;IAC9B,KAAK;CACL,CAAC,CAAC"}
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/server/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAIxC,MAAM,OAAO,WAAY,SAAQ,IAAI,CAAC,WAAW,CAAC,aAAa,CAI7D;CAAG;AAEL,MAAM,OAAO,uBAAwB,SAAQ,IAAI,CAAC,WAAW,CAAC,yBAAyB,CAGrF;IACD,IAAa,OAAO;QACnB,OAAO,SAAS,IAAI,CAAC,KAAK,0CAA0C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;IAC/F,CAAC;CACD;AAED,MAAM,OAAO,kBAAmB,SAAQ,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAI3E;CAAG;AAEL,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,SAA0B,EAAE,KAAc,EAAE,KAAc,EAAe,EAAE,CACxG,IAAI,WAAW,CAAC;IACf,SAAS;IACT,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC;IAC9B,KAAK;CACL,CAAC,CAAC"}
@@ -1,3 +1,9 @@
1
+ export interface QueueCounts {
2
+ readonly activeCount: number;
3
+ readonly failedCount: number;
4
+ readonly queuedCount: number;
5
+ readonly totalCount: number;
6
+ }
1
7
  export interface QueueHealth {
2
8
  readonly activeCount: number;
3
9
  readonly deadLetteredCount: number;
@@ -1 +1 @@
1
- {"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../src/server/health.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,SAAS,WAAW,EAAE,CAAC;IACtC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC5B;AAED,eAAO,MAAM,mBAAmB,cAAe,MAAM,KAAG,MAA4B,CAAC"}
1
+ {"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../src/server/health.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,SAAS,WAAW,EAAE,CAAC;IACtC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC5B;AAED,eAAO,MAAM,mBAAmB,cAAe,MAAM,KAAG,MAA4B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"health.js","sourceRoot":"","sources":["../../src/server/health.ts"],"names":[],"mappings":"AAkBA,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,SAAiB,EAAU,EAAE,CAAC,GAAG,SAAS,MAAM,CAAC"}
1
+ {"version":3,"file":"health.js","sourceRoot":"","sources":["../../src/server/health.ts"],"names":[],"mappings":"AAyBA,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,SAAiB,EAAU,EAAE,CAAC,GAAG,SAAS,MAAM,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { Effect } from "effect";
2
+ import type { PgBossClient } from "#client.ts";
3
+ import type { QueueCounts } from "#health.ts";
4
+ export declare function countsFor(client: PgBossClient, schema: string, name: string): Effect.Effect<QueueCounts, import("#error.ts").PgBossError>;
5
+ //# sourceMappingURL=countsFor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"countsFor.d.ts","sourceRoot":"","sources":["../../../src/server/internal/countsFor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AACxC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAS9C,wBAAgB,SAAS,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,WAAW,EAAE,WAAW,CAAC,CAoBzI"}
@@ -0,0 +1,27 @@
1
+ import { Effect, Schema } from "effect";
2
+ import { toPgBossError } from "#error.ts";
3
+ const Counts = Schema.Struct({
4
+ activeCount: Schema.Number,
5
+ failedCount: Schema.Number,
6
+ queuedCount: Schema.Number,
7
+ totalCount: Schema.Number,
8
+ });
9
+ export function countsFor(client, schema, name) {
10
+ return Effect.tryPromise({
11
+ catch: (error) => toPgBossError("counts", error, name),
12
+ try: async () => {
13
+ if (client.getDb === undefined) {
14
+ throw new TypeError("This pg-boss client does not support getDb");
15
+ }
16
+ const quotedSchema = `"${schema.replaceAll('"', '""')}"`;
17
+ const { rows } = await client.getDb().executeSql(`SELECT
18
+ count(*) FILTER (WHERE state = 'active')::int AS "activeCount",
19
+ count(*) FILTER (WHERE state = 'failed')::int AS "failedCount",
20
+ count(*) FILTER (WHERE state IN ('created', 'retry'))::int AS "queuedCount",
21
+ count(*)::int AS "totalCount"
22
+ FROM ${quotedSchema}.job WHERE name = $1`, [name]);
23
+ return Schema.decodeUnknownPromise(Counts)(rows[0]);
24
+ },
25
+ });
26
+ }
27
+ //# sourceMappingURL=countsFor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"countsFor.js","sourceRoot":"","sources":["../../../src/server/internal/countsFor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAExC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAG1C,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC,MAAM;IAC1B,WAAW,EAAE,MAAM,CAAC,MAAM;IAC1B,WAAW,EAAE,MAAM,CAAC,MAAM;IAC1B,UAAU,EAAE,MAAM,CAAC,MAAM;CACzB,CAAC,CAAC;AAEH,MAAM,UAAU,SAAS,CAAC,MAAoB,EAAE,MAAc,EAAE,IAAY;IAC3E,OAAO,MAAM,CAAC,UAAU,CAAC;QACxB,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC;QACtD,GAAG,EAAE,KAAK,IAAI,EAAE;YACf,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;gBAChC,MAAM,IAAI,SAAS,CAAC,4CAA4C,CAAC,CAAC;YACnE,CAAC;YACD,MAAM,YAAY,GAAG,IAAI,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC;YACzD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC,UAAU,CAC/C;;;;;WAKO,YAAY,sBAAsB,EACzC,CAAC,IAAI,CAAC,CACN,CAAC;YACF,OAAO,MAAM,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACrD,CAAC;KACD,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Queue } from "pg-boss";
2
+ import type { PgBossClient } from "#client.ts";
3
+ export declare function ensureQueue(client: PgBossClient, name: string, options: Omit<Queue, "name" | "deadLetter">): Promise<void>;
4
+ //# sourceMappingURL=ensureQueue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ensureQueue.d.ts","sourceRoot":"","sources":["../../../src/server/internal/ensureQueue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAI/C,wBAAsB,WAAW,CAAC,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAuBhI"}
@@ -0,0 +1,27 @@
1
+ import { PgBossQueueOptionsError } from "#error.ts";
2
+ import { deadLetterQueueName } from "#health.ts";
3
+ export async function ensureQueue(client, name, options) {
4
+ const deadLetter = deadLetterQueueName(name);
5
+ const desired = { retryBackoff: true, retryLimit: 3, ...options, deadLetter };
6
+ await client.createQueue(deadLetter);
7
+ await client.createQueue(name, desired);
8
+ const existing = await client.getQueue(name);
9
+ if (existing === null) {
10
+ return;
11
+ }
12
+ const immutable = ["partition", "policy"].filter((key) => desired[key] !== undefined && desired[key] !== existing[key]);
13
+ if (immutable.length > 0) {
14
+ throw new PgBossQueueOptionsError({ options: immutable, queue: name });
15
+ }
16
+ const { partition: _partition, policy: _policy, ...mutable } = desired;
17
+ const changed = Object.entries(mutable).some(([key, value]) => value !== undefined && value !== Reflect.get(existing, key));
18
+ if (!changed) {
19
+ return;
20
+ }
21
+ if (client.updateQueue === undefined) {
22
+ throw new TypeError("This pg-boss client does not support updateQueue");
23
+ }
24
+ // pg-boss validates retryDelayMax against retryBackoff in the same update.
25
+ await client.updateQueue(name, mutable);
26
+ }
27
+ //# sourceMappingURL=ensureQueue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ensureQueue.js","sourceRoot":"","sources":["../../../src/server/internal/ensureQueue.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,E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OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC;IAC5H,IAAI,CAAC,OAAO,EAAE,CAAC;QACd,OAAO;IACR,CAAC;IACD,IAAI,MAAM,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;QACtC,MAAM,IAAI,SAAS,CAAC,kDAAkD,CAAC,CAAC;IACzE,CAAC;IACD,2EAA2E;IAC3E,MAAM,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACzC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { PgBossClient } from "#client.ts";
2
+ import type { PgBossService } from "#service.ts";
3
+ export declare function getJobFor(client: PgBossClient): PgBossService["getJob"];
4
+ export declare function retryFor(client: PgBossClient): PgBossService["retry"];
5
+ //# sourceMappingURL=jobControl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jobControl.d.ts","sourceRoot":"","sources":["../../../src/server/internal/jobControl.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,wBAAgB,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,aAAa,CAAC,QAAQ,CAAC,CAoBvE;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,aAAa,CAAC,OAAO,CAAC,CAkBrE"}
@@ -0,0 +1,35 @@
1
+ import { Effect, Option, Redacted, Schema } from "effect";
2
+ import { PgBossPayloadError, toPgBossError } from "#error.ts";
3
+ import { payloadOf } from "#internal/tracing.ts";
4
+ export function getJobFor(client) {
5
+ return (queue, id) => Effect.tryPromise({
6
+ catch: (error) => toPgBossError("getJob", error, queue.name),
7
+ try: async () => {
8
+ if (client.findJobs === undefined) {
9
+ throw new TypeError("This pg-boss client does not support findJobs");
10
+ }
11
+ return (await client.findJobs(queue.name, { id }))[0];
12
+ },
13
+ }).pipe(Effect.flatMap((job) => job === undefined
14
+ ? Effect.succeed(Option.none())
15
+ : Schema.decodeUnknownEffect(queue.schema)(payloadOf(job.data)).pipe(Effect.mapError((error) => new PgBossPayloadError({ direction: "decode", original: Redacted.make(error), queue: queue.name })), Effect.map((data) => Option.some({ ...job, data })))));
16
+ }
17
+ export function retryFor(client) {
18
+ return (queue, id) => Effect.tryPromise({
19
+ catch: (error) => toPgBossError("retry", error, queue.name),
20
+ try: async () => {
21
+ if (client.findJobs === undefined || client.retry === undefined || client.update === undefined) {
22
+ throw new TypeError("This pg-boss client does not support findJobs, retry and update");
23
+ }
24
+ const job = (await client.findJobs(queue.name, { id }))[0];
25
+ if (job?.state !== "failed" && job?.state !== "retry") {
26
+ return;
27
+ }
28
+ if (job.state === "failed") {
29
+ await client.retry(queue.name, id);
30
+ }
31
+ await client.update(queue.name, undefined, { id, startAfter: 0 });
32
+ },
33
+ });
34
+ }
35
+ //# sourceMappingURL=jobControl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jobControl.js","sourceRoot":"","sources":["../../../src/server/internal/jobControl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE1D,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGjD,MAAM,UAAU,SAAS,CAAC,MAAoB;IAC7C,OAAO,CAAC,KAAK,EAAE,EAAE,EAAE,EAAE,CACpB,MAAM,CAAC,UAAU,CAAC;QACjB,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC;QAC5D,GAAG,EAAE,KAAK,IAAI,EAAE;YACf,IAAI,MAAM,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;gBACnC,MAAM,IAAI,SA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KAAK,SAAS,EAAE,CAAC;gBAChG,MAAM,IAAI,SAAS,CAAC,iEAAiE,CAAC,CAAC;YACxF,CAAC;YACD,MAAM,GAAG,GAAG,CAAC,MAAM,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC3D,IAAI,GAAG,EAAE,KAAK,KAAK,QAAQ,IAAI,GAAG,EAAE,KAAK,KAAK,OAAO,EAAE,CAAC;gBACvD,OAAO;YACR,CAAC;YACD,IAAI,GAAG,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC5B,MAAM,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACpC,CAAC;YACD,MAAM,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,CAAC;QACnE,CAAC;KACD,CAAC,CAAC;AACL,CAAC"}
@@ -1,7 +1,8 @@
1
1
  import { type Context, Effect } from "effect";
2
2
  import type { PgBossClient } from "#client.ts";
3
3
  import { type JobRegistration } from "#definition.ts";
4
+ import { PgBossQueueOptionsError } from "#error.ts";
4
5
  export declare const registrationName: (registration: JobRegistration) => string;
5
6
  export declare const registrationNames: (registrations: readonly JobRegistration[]) => readonly string[];
6
- export declare const registerJobs: <R>(client: PgBossClient, registrations: readonly JobRegistration[], context: Context.Context<R>, replaceWorkers: boolean) => Effect.Effect<void, import("#error.ts").PgBossError>;
7
+ export declare const registerJobs: <R>(client: PgBossClient, registrations: readonly JobRegistration[], context: Context.Context<R>, replaceWorkers: boolean) => Effect.Effect<void, import("#error.ts").PgBossError | PgBossQueueOptionsError>;
7
8
  //# sourceMappingURL=register.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../src/server/internal/register.ts"],"names":[],"mappings":"AA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@@
1
1
  import { Effect, Redacted, Schema } from "effect";
2
2
  import { jobContext } from "#definition.ts";
3
- import { PgBossPayloadError, toPgBossError } from "#error.ts";
4
- import { deadLetterQueueName } from "#health.ts";
5
- function queueOptions(options) {
6
- return {
7
- retryBackoff: true,
8
- retryLimit: 3,
9
- ...options,
10
- };
11
- }
3
+ import { PgBossPayloadError, PgBossQueueOptionsError, toPgBossError } from "#error.ts";
4
+ import { ensureQueue } from "#internal/ensureQueue.ts";
5
+ import { payloadOf, traceJob } from "#internal/tracing.ts";
12
6
  function isQueueWorker(registration) {
13
7
  return registration._tag === "QueueWorker";
14
8
  }
@@ -34,24 +28,19 @@ function workerContext(context) {
34
28
  return context;
35
29
  }
36
30
  function runQueueWorker(worker, job, context) {
37
- return Effect.runPromise(Schema.decodeUnknownEffect(worker.queue.schema)(job.data).pipe(Effect.mapError((error) => new PgBossPayloadError({
31
+ return Effect.runPromise(Schema.decodeUnknownEffect(worker.queue.schema)(payloadOf(job.data)).pipe(Effect.mapError((error) => new PgBossPayloadError({
38
32
  direction: "decode",
39
33
  original: Redacted.make(error),
40
34
  queue: worker.queue.name,
41
- })), Effect.flatMap((payload) => worker.handler(payload, jobContext(job))), Effect.provide(context)), { signal: job.signal });
35
+ })), Effect.flatMap((payload) => worker.handler(payload, jobContext(job))), (effect) => traceJob(effect, job, worker.queue.name), Effect.provide(context)), { signal: job.signal });
42
36
  }
43
37
  async function registerQueue(client, registration, context, replaceWorker) {
44
38
  const queue = registration._tag === "QueueWorker" ? registration.queue : registration;
45
39
  const name = queue.name;
46
- const deadLetter = deadLetterQueueName(name);
47
40
  if (replaceWorker && registration._tag === "QueueWorker") {
48
41
  await client.offWork(name);
49
42
  }
50
- await client.createQueue(deadLetter);
51
- await client.createQueue(name, {
52
- ...queueOptions(queue.queueOptions),
53
- deadLetter,
54
- });
43
+ await ensureQueue(client, name, queue.queueOptions);
55
44
  if (registration._tag === "QueueDefinition") {
56
45
  return;
57
46
  }
@@ -63,18 +52,13 @@ async function registerQueue(client, registration, context, replaceWorker) {
63
52
  }
64
53
  async function registerSchedule(client, worker, context, replaceWorker) {
65
54
  const { schedule } = worker;
66
- const deadLetter = deadLetterQueueName(schedule.name);
67
55
  if (replaceWorker) {
68
56
  await client.offWork(schedule.name);
69
57
  }
70
- await client.createQueue(deadLetter);
71
- await client.createQueue(schedule.name, {
72
- ...queueOptions(schedule.queueOptions),
73
- deadLetter,
74
- });
58
+ await ensureQueue(client, schedule.name, schedule.queueOptions);
75
59
  await client.work(schedule.name, schedule.workerOptions, async (jobs) => {
76
60
  for (const job of jobs) {
77
- await Effect.runPromise(Effect.provide(worker.effect, context), {
61
+ await Effect.runPromise(Effect.provide(traceJob(worker.effect, job, schedule.name), context), {
78
62
  signal: job.signal,
79
63
  });
80
64
  }
@@ -89,7 +73,7 @@ export const registrationNames = (registrations) => {
89
73
  return names;
90
74
  };
91
75
  export const registerJobs = (client, registrations, context, replaceWorkers) => Effect.tryPromise({
92
- catch: (error) => toPgBossError("register", error),
76
+ catch: (error) => (error instanceof PgBossQueueOptionsError ? error : toPgBossError("register", error)),
93
77
  try: async () => {
94
78
  registrationNames(registrations);
95
79
  const provided = workerContext(context);
@@ -1 +1 @@
1
- {"version":3,"file":"register.js","sourceRoot":"","sources":["../../../src/server/internal/register.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhE,OAAO,EAAwB,UAAU,EAAgE,MAAM,gBAAgB,CAAC;AAChI,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,SAAS,YAAY,CAAC,OAA0C;IAC/D,OAAO;QACN,YAAY,EAAE,IAAI;QAClB,UAAU,EAAE,CAAC;QACb,GAAG,OAAO;KACV,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,YAA6B;IACnD,OAAO,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