@shivaedev/jobs 0.29.1 → 0.30.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.
- package/CHANGELOG.md +22 -0
- package/README.md +26 -5
- package/dist/server/adapters/clientErrorLogger.d.ts +3 -0
- package/dist/server/adapters/clientErrorLogger.d.ts.map +1 -0
- package/dist/server/adapters/clientErrorLogger.js +9 -0
- package/dist/server/adapters/clientErrorLogger.js.map +1 -0
- package/dist/server/adapters/clientErrorReporter.d.ts +1 -1
- package/dist/server/adapters/clientErrorReporter.d.ts.map +1 -1
- package/dist/server/adapters/clientErrorReporter.js +3 -3
- package/dist/server/adapters/clientErrorReporter.js.map +1 -1
- package/dist/server/adapters/registerWorker.d.ts +2 -2
- package/dist/server/adapters/registerWorker.d.ts.map +1 -1
- package/dist/server/adapters/registerWorker.js +22 -7
- package/dist/server/adapters/registerWorker.js.map +1 -1
- package/dist/server/definition.d.ts +3 -3
- package/dist/server/definition.d.ts.map +1 -1
- package/dist/server/definition.js.map +1 -1
- package/dist/server/internal/batchHandler.d.ts +1 -1
- package/dist/server/internal/batchHandler.d.ts.map +1 -1
- package/dist/server/internal/batchHandler.js +3 -3
- package/dist/server/internal/batchHandler.js.map +1 -1
- package/dist/server/internal/jobControl.d.ts.map +1 -1
- package/dist/server/internal/jobControl.js +17 -5
- package/dist/server/internal/jobControl.js.map +1 -1
- package/dist/server/internal/register.d.ts +3 -2
- package/dist/server/internal/register.d.ts.map +1 -1
- package/dist/server/internal/register.js +20 -31
- package/dist/server/internal/register.js.map +1 -1
- package/dist/server/internal/registerReleasedJobs.d.ts +2 -1
- package/dist/server/internal/registerReleasedJobs.d.ts.map +1 -1
- package/dist/server/internal/registerReleasedJobs.js +3 -3
- package/dist/server/internal/registerReleasedJobs.js.map +1 -1
- package/dist/server/internal/retryWake.d.ts +1 -1
- package/dist/server/internal/retryWake.d.ts.map +1 -1
- package/dist/server/internal/retryWake.js +4 -2
- package/dist/server/internal/retryWake.js.map +1 -1
- package/dist/server/internal/runQueueWorker.d.ts +4 -2
- package/dist/server/internal/runQueueWorker.d.ts.map +1 -1
- package/dist/server/internal/runQueueWorker.js.map +1 -1
- package/dist/server/internal/testingClient.d.ts.map +1 -1
- package/dist/server/internal/testingClient.js +4 -1
- package/dist/server/internal/testingClient.js.map +1 -1
- package/dist/server/internal/testingIdle.d.ts.map +1 -1
- package/dist/server/internal/testingIdle.js +9 -3
- package/dist/server/internal/testingIdle.js.map +1 -1
- package/dist/server/internal/testingRegistrations.d.ts +4 -0
- package/dist/server/internal/testingRegistrations.d.ts.map +1 -0
- package/dist/server/internal/testingRegistrations.js +8 -0
- package/dist/server/internal/testingRegistrations.js.map +1 -0
- package/dist/server/internal/testingSnapshot.d.ts.map +1 -1
- package/dist/server/internal/testingSnapshot.js +5 -2
- package/dist/server/internal/testingSnapshot.js.map +1 -1
- package/dist/server/jobModule.d.ts +7 -0
- package/dist/server/jobModule.d.ts.map +1 -0
- package/dist/server/jobModule.js +13 -0
- package/dist/server/jobModule.js.map +1 -0
- package/dist/server/service.d.ts.map +1 -1
- package/dist/server/service.js +10 -7
- package/dist/server/service.js.map +1 -1
- package/dist/server/testing.d.ts +3 -2
- package/dist/server/testing.d.ts.map +1 -1
- package/dist/server/testing.js +5 -0
- package/dist/server/testing.js.map +1 -1
- package/package.json +9 -9
- package/src/server/adapters/clientErrorLogger.ts +9 -0
- package/src/server/adapters/clientErrorReporter.ts +3 -3
- package/src/server/adapters/registerWorker.ts +30 -11
- package/src/server/definition.ts +4 -3
- package/src/server/internal/batchHandler.ts +3 -3
- package/src/server/internal/jobControl.ts +23 -6
- package/src/server/internal/register.ts +38 -47
- package/src/server/internal/registerReleasedJobs.ts +5 -4
- package/src/server/internal/retryWake.ts +4 -2
- package/src/server/internal/runQueueWorker.ts +8 -2
- package/src/server/internal/testingClient.ts +4 -1
- package/src/server/internal/testingIdle.ts +8 -3
- package/src/server/internal/testingRegistrations.ts +10 -0
- package/src/server/internal/testingSnapshot.ts +5 -2
- package/src/server/jobModule.ts +18 -0
- package/src/server/service.ts +26 -22
- package/src/server/testing.ts +13 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.30.0 - 2026-11-02
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- Wake idle workers when `RetryAt` deferrals become due, without waiting for the polling backstop. Retry and deferral wakes account for differences between the runtime and PostgreSQL clocks.
|
|
8
|
+
|
|
9
|
+
### Breaking
|
|
10
|
+
|
|
11
|
+
- Job registrations require complete queue definitions, queue workers or scheduled workers. Reusable collections retain service requirements in the jobs Layer instead of erasing them. Replace tag-only registrations with `defineQueue`, `.handle` or `.run` results. Replace broad `JobRegistration[]` annotations with `satisfies readonly JobRegistration[]` or `readonly JobRegistration<Services>[]`, naming the union of handler, payload-decoding and scheduled-effect services.
|
|
12
|
+
- `waitForIdle` discovers all registered job queues, including producer-only definitions, and waits for ready and active work across clients. Consumers that previously ignored ready jobs without local workers must run a worker for those jobs or leave them scheduled for the future before settling.
|
|
13
|
+
- `UnfinishedJob.state` includes `deferred`. Handle this state when reading `snapshot(queues)`: a future `RetryAt` deferral reads as `deferred`, while a due deferral or a retry after a failure reads as `retry`.
|
|
14
|
+
- Queue and scheduled workers now fail Layer acquisition with a registration `PgBossError` when `worker.perJobResults` or `worker.transactional` is `true`. Omit these options or set them to `false`; the adapter owns per-job settlement and does not pass a pg-boss transaction client to handlers. Consumers needing pg-boss's result-array or transactional callback contracts must register those workers through pg-boss directly.
|
|
15
|
+
|
|
16
|
+
## 0.29.2 - 2026-11-02
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- Bound worker shutdown drain by `stop.timeout` (30 seconds by default). Workers drain concurrently, interrupt in-flight Effects at the timeout and log a warning for each registration that times out. Work that finishes within the timeout completes normally.
|
|
21
|
+
- Tie `onError` callbacks to the jobs Layer's lifetime. Closing the Layer interrupts pending callbacks and waits for them to end before release completes; callbacks that finish before shutdown behave as before.
|
|
22
|
+
- Redact scheduled worker logs using the same diagnostic policy as queue workers. Job details sanitize stored failure output and source failure output through the same schema as job listings, including native pg-boss timeout records.
|
|
23
|
+
- Fail the scope coordinating a worker release with the original cause when heartbeat or ownership polling retries are exhausted, and stop registered jobs workers before removing the release lease. Application-host workers can no longer keep fetching after their release coordinator fails.
|
|
24
|
+
|
|
3
25
|
## 0.29.1 - 2026-11-01
|
|
4
26
|
|
|
5
27
|
### Changed
|
package/README.md
CHANGED
|
@@ -35,6 +35,19 @@ Use a distinct literal identifier for each jobs service. The service and its Lay
|
|
|
35
35
|
|
|
36
36
|
The work separates naturally: declare the application services once, define a queue and its worker for each feature, provide the complete registration list at the runtime boundary, and enqueue from ordinary application Effects.
|
|
37
37
|
|
|
38
|
+
### Contribute workers to application modules
|
|
39
|
+
|
|
40
|
+
`jobModule` from `@shivaedev/jobs/server/jobModule.ts` returns `queues` and `workers` fields for an `AppModule` in `@shivaedev/server`. Its queue declarations come from the same registrations its worker Layer runs:
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import { jobModule } from "@shivaedev/jobs/server/jobModule.ts";
|
|
44
|
+
import { Jobs, SendEmail, Mail } from "./app.ts";
|
|
45
|
+
|
|
46
|
+
const jobs = jobModule(Jobs.layer, { jobs: [SendEmail.handle(({ userId }) => Mail.send(userId))] });
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Spread these fields into the owning module. Keep the producer's jobs Layer in its services or ports. The application builds `appModules` once and passes its result to `appHost` or `workerHost`; both hosts provide the module's services and ports to their work. Queue definitions without handlers and scheduled workers can also appear in the registration list.
|
|
50
|
+
|
|
38
51
|
### Share queue names with the browser
|
|
39
52
|
|
|
40
53
|
Keep names and payload Schemas in a browser-safe module such as `queues.ts`:
|
|
@@ -87,6 +100,8 @@ With server's `appDatabase({ migrations: { mode: "wait", release, ... } })`, eac
|
|
|
87
100
|
|
|
88
101
|
A paused worker keeps its process registered with sql's worker release while active jobs drain, so the owning release waits for it; [sql's worker release](https://github.com/ShivaeDev/platform/blob/main/packages/sql/README.md) owns the heartbeat and how long a crashed worker can block. Closing the jobs Layer's scope waits for the native pg-boss `stop` before releasing the services the Layer captured. Choose the three bounds together: each queue's `expireInSeconds`, a `stop: { graceful: true, timeout }` in milliseconds that covers it, and a host termination grace beyond that timeout. For example, a queue with `expireInSeconds: 60` pairs with `stop: { graceful: true, timeout: 65_000 }` under a 75-second termination grace.
|
|
89
102
|
|
|
103
|
+
Worker registrations drain concurrently when their Layer closes. `stop.timeout` bounds each drain in milliseconds, defaulting to 30 seconds. Work that finishes within that budget completes normally. At the timeout, the adapter logs a warning naming the queue and interrupts its in-flight Effect fibers before releasing their services. `stop.graceful: false` interrupts without waiting for drain. Keep handlers interruptible, as described under [batch expiry](#size-batches-against-expiry). The drain budget does not bound PostgreSQL disconnect acknowledgements; shutdown still waits for the pool to close.
|
|
104
|
+
|
|
90
105
|
`installPgBossSchema` installs or upgrades pg-boss through the provided Effect SQL client without starting workers or schedules. Run it outside an application transaction, in a release step or the `fixtures` Effect of `makePostgresTestLayer`, so stories inherit the schema from the migrated template:
|
|
91
106
|
|
|
92
107
|
```ts
|
|
@@ -125,6 +140,8 @@ export const MailLive = Mail.layer;
|
|
|
125
140
|
|
|
126
141
|
`Jobs` is the service that callers yield. `Mail` is a separate domain service that workers use. The example implementation logs calls so the wiring is complete; an application supplies its own implementation of those methods. The jobs package does not need a provider-specific interface.
|
|
127
142
|
|
|
143
|
+
Registration collections retain their workers' handler, payload-decoding and scheduled-effect service requirements in `Jobs.layer`. Use `satisfies readonly JobRegistration[]` to check a reusable collection while preserving its inferred requirements, or annotate it as `readonly JobRegistration<Services>[]` with the union of services it needs. A plain `JobRegistration[]` leaves requirements `unknown`. Queue workers require both their queue and handler; scheduled workers require both their schedule and effect. Incomplete registrations are TypeScript errors. Producer-only queue definitions need no handler or decoding services at startup.
|
|
144
|
+
|
|
128
145
|
### Once per feature: the payload and handler
|
|
129
146
|
|
|
130
147
|
Define the feature's registrations in `jobs.ts`:
|
|
@@ -192,7 +209,7 @@ const Compare = defineQueue({
|
|
|
192
209
|
|
|
193
210
|
This worker runs up to five handlers at once. `worker` accepts pg-boss 12's `WorkOptions`, including `batchSize`, `localConcurrency`, `pollingIntervalSeconds`, `notifyPollingIntervalSeconds` and the burst options. Explicit options override the adapter defaults. pg-boss ignores `burstWhenBatchFull` at `batchSize: 1`; keep a batch size of at least two for immediate backlog draining. Each job is settled separately through pg-boss: success completes that job, and a typed failure, payload decoding failure or defect fails only that job with its own error. A failed job does not spend the retries of other jobs in its batch or rerun their successful handlers. Interruption stops the batch and leaves the interrupted and remaining jobs to pg-boss expiry; handlers must still tolerate repeated side effects across retries and interrupted attempts.
|
|
194
211
|
|
|
195
|
-
Apps do not need to shorten the polling backstop to drain a backlog. With `notify: true` and an active LISTEN/NOTIFY listener, pg-boss wakes workers on notifications and defaults to a 30-second backstop (`notifyPollingIntervalSeconds`). Without active notifications its base poll defaults to two seconds (`pollingIntervalSeconds`). Bursting takes precedence over both intervals. After an adapter worker fails a job, it reads pg-boss's stored retry time and schedules a wake for every native worker in its registration at that time, so an idle sibling can retry while another worker is busy. The wake, including its retry-time read, belongs to the worker Layer's scope and is canceled when that scope closes. Wake failures are logged with redacted diagnostics and do not fail the batch. Override the backstop when the application needs a different bound for other work that becomes runnable without a notification, such as delayed jobs or retries initiated outside the adapter worker.
|
|
212
|
+
Apps do not need to shorten the polling backstop to drain a backlog. With `notify: true` and an active LISTEN/NOTIFY listener, pg-boss wakes workers on notifications and defaults to a 30-second backstop (`notifyPollingIntervalSeconds`). Without active notifications its base poll defaults to two seconds (`pollingIntervalSeconds`). Bursting takes precedence over both intervals. After an adapter worker fails or defers a job, it reads pg-boss's stored retry time and schedules a wake for every native worker in its registration at that time, so an idle sibling can retry while another worker is busy. The wake accounts for differences between the runtime and PostgreSQL clocks. The wake, including its retry-time read, belongs to the worker Layer's scope and is canceled when that scope closes. Wake failures are logged with redacted diagnostics and do not fail the batch. Override the backstop when the application needs a different bound for other work that becomes runnable without a notification, such as delayed jobs or retries initiated outside the adapter worker.
|
|
196
213
|
|
|
197
214
|
### Defer until a provider is ready
|
|
198
215
|
|
|
@@ -210,7 +227,7 @@ const waitForQuota = Effect.fail(
|
|
|
210
227
|
);
|
|
211
228
|
```
|
|
212
229
|
|
|
213
|
-
The same job returns to waiting with `startAfter` set to `at`; its ID, singleton key, payload and retry count stay unchanged. A past or current `at` is eligible on the next fetch. Deferral does not dead-letter the job or call `onError`. Its job span ends OK with a `job.deferred` event whose `at` is an ISO UTC string and whose `reason` is the supplied string.
|
|
230
|
+
The same job returns to waiting with `startAfter` set to `at`; its ID, singleton key, payload and retry count stay unchanged. A past or current `at` is eligible on the next fetch. Deferral does not dead-letter the job or call `onError`. Its job span ends OK with a `job.deferred` event whose `at` is an ISO UTC string and whose `reason` is the supplied string. The adapter wakes workers in the same registration when the deferral becomes due, including queues using `notify: true`, so they can resume the job without waiting for the polling backstop. Stately jobs sharing a singleton key can defer together and still run one at a time. While waiting, their native job metadata reports the adapter's `effect-stately-deferred` policy; a database trigger restores `stately` when pg-boss claims them, preserving its active-job exclusion.
|
|
214
231
|
|
|
215
232
|
Set `queue: { maxDeferrals: 20 }` on a queue or schedule to change the default limit of ten deferrals per job. The limit must be a nonnegative safe integer; zero disables deferral. Once the limit is reached, `RetryAt` follows the normal failure and retry path. The adapter stores the count in its own table in the pg-boss schema, preserving it across worker restarts, ordinary failures, expiry and heartbeat timeouts. Queue handlers read this table before every attempt, including handlers that never defer. Automatic migrations and `installPgBossSchema` create this table and the stately claim trigger; use `installPgBossSchema` or the `pgBossSchema` migration component before starting workers with `migrate: false`.
|
|
216
233
|
|
|
@@ -483,6 +500,8 @@ Include every target queue in `jobs`, as either a worker or a producer-only defi
|
|
|
483
500
|
|
|
484
501
|
### Test through the queue contract
|
|
485
502
|
|
|
503
|
+
`linkedWorkerSpans(sender, spans)` from `@shivaedev/jobs/server/testing.ts` reads native recorded Effect spans and returns the pg-boss consumer spans whose links match both the sender's `traceId` and `spanId`. It returns every matching attempt, including retries, and no matches before a worker runs. An untraced job has no sender link. Settle the workers before reading their completed attempts; this readout does not wait or read queue storage.
|
|
504
|
+
|
|
486
505
|
`testing.ts` gives story kits a controller for one real pg-boss client. Create a fresh controller per runtime, pass its `clientFactory` to `pgBossLayer`, and keep that Layer scoped as usual. `jobs(queue, options?)` returns native job metadata with `data` decoded through the queue's Schema, including traced payloads. Invalid durable data fails with `PgBossPayloadError`; decoding services remain in the Effect's requirements.
|
|
487
506
|
|
|
488
507
|
This producer story uses the `SendEmail` definition and `Jobs` service from above. `databaseUrl` points to the story's PostgreSQL database:
|
|
@@ -533,9 +552,9 @@ Set `retryPolicy: testRetryPolicy` through the controller to override queue and
|
|
|
533
552
|
|
|
534
553
|
`checkBatchWindow(queue, millisecondsPerJob)` checks that the declared sequential batch fits strictly inside the stored queue expiry window. `schemaVersion` reads the installed version, and `checkSchemaVersion(expected)` fails when it differs. Test control, read and check failures use `PgBossTestingError` with `operation`, optional `queue` and a redacted `original`.
|
|
535
554
|
|
|
536
|
-
`snapshot(queues)` reads the unfinished jobs of several queues in one query, so the result is one consistent PostgreSQL snapshot. It returns jobs in the `created`, `retry`, `active` and `failed` states, never completed ones, oldest first by creation. Each entry has the job's `id`, `queue` (the definition's name), `state`, `startAfter` as a UTC `DateTime` and `data` decoded by that queue's Schema. Only unfinished rows are decoded, so a completed job whose stored data the Schema no longer accepts does not fail the read; invalid unfinished data fails with `PgBossPayloadError`.
|
|
555
|
+
`snapshot(queues)` reads the unfinished jobs of several queues in one query, so the result is one consistent PostgreSQL snapshot. It returns jobs in the `created`, `retry`, `active` and `failed` states, never completed ones, oldest first by creation. A waiting `RetryAt` job reads as `deferred` while its `startAfter` is in the future; once due, it reads as `retry` until claimed. A retry after a handler failure reads as `retry` even when its next attempt is in the future. Each entry has the job's `id`, `queue` (the definition's name), `state`, `startAfter` as a UTC `DateTime` and `data` decoded by that queue's Schema. Only unfinished rows are decoded, so a completed job whose stored data the Schema no longer accepts does not fail the read; invalid unfinished data fails with `PgBossPayloadError`.
|
|
537
556
|
|
|
538
|
-
`waitForIdle`
|
|
557
|
+
`waitForIdle` discovers queues from the jobs registered in the controller's Layer, including producer-only definitions and schedules; it takes no queue list. It completes when none of those queues has an active job or an unblocked job ready to fetch, including work claimed by another client. Ready jobs keep the wait open even when no local worker runs them. A terminal native worker timeout lets the wait complete after pg-boss fails the job. Jobs whose `startAfter` is in the future do not hold the wait open. While a local fetched batch has no settlement yet, the wait reads nothing and waits for the next local change; otherwise it checks PostgreSQL on local changes and at 50 ms intervals to observe other clients. These intervals use wall time even on a story's `TestClock`. A kit settles by yielding `waitForIdle` and then reading jobs once. As with any idle snapshot, a producer can enqueue more work after the wait returns.
|
|
539
558
|
|
|
540
559
|
A kit can also capture `revision` before reading jobs and yield `waitForChange(revision)` when its condition is unmet. The wait resumes after a local send, settlement or worker fetch, and when a local worker returns to idle as `waitForIdle` defines it, including terminal native worker timeouts. It also resumes immediately if a change occurred between the read and the wait. This signal observes the controller's client; external clients, future scheduled work and external database writes need their own wake source. Stories should retain a bounded test timeout.
|
|
541
560
|
|
|
@@ -565,9 +584,11 @@ Import the module that defines the name; the package has no root entry.
|
|
|
565
584
|
|
|
566
585
|
The definition options keep the pg-boss names: `queue` uses `QueueOptions` (`Queue` except `name` and `deadLetter`, with literal `QueuePolicy` values and `maxDeferrals`), `worker` uses `WorkOptions`, and a schedule's `schedule` uses `ScheduleOptions`. A queue also requires `name` and `schema`; a schedule requires `name` and `cron`.
|
|
567
586
|
|
|
587
|
+
Queue and scheduled workers reject `perJobResults: true` and `transactional: true` during Layer acquisition with a registration `PgBossError`; its redacted `original` names the unsupported options. Omit these options or set them to `false`. The adapter settles each job itself and does not expose pg-boss's transaction client to handlers.
|
|
588
|
+
|
|
568
589
|
`Jobs.layer(options)` accepts pg-boss `ConstructorOptions` plus the adapter's own options. Custom clients must supply native `complete` and `fail` capabilities to register queue or schedule workers; missing settlement capabilities fail Layer acquisition with a registration `PgBossError`. Workers also require `getDb()` to read the PostgreSQL clock when a batch arrives. Producer-only clients do not need these capabilities. Custom clients can also supply the optional native capabilities `findJobs`, `retry`, `update`, `getDb` and `updateQueue` for lookup, retry, live counts and listings, deferral and reconciliation; a requested operation fails with `PgBossError` if its required capability is absent.
|
|
569
590
|
|
|
570
|
-
`onError` handles pg-boss client `error` events using the services captured by the Layer. Only the owning jobs service is supplied automatically; a handler using another jobs definition still requires that definition's Layer.
|
|
591
|
+
`onError` handles pg-boss client `error` events using the services captured by the Layer. The Layer interrupts pending callbacks and waits for them to end before release completes. Only the owning jobs service is supplied automatically; a handler using another jobs definition still requires that definition's Layer.
|
|
571
592
|
|
|
572
593
|
Worker registration always requests `includeMetadata: true`, including when `worker` supplies `includeMetadata: false`; custom clients must return pg-boss's `startedOn` metadata. Direct callers use `jobContext(job, deadline)`, where `deadline` is in runtime Clock milliseconds: measure the remaining expiry against PostgreSQL time, then add it to the runtime Clock time. Registered workers receive that translation automatically.
|
|
573
594
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clientErrorLogger.d.ts","sourceRoot":"","sources":["../../../src/server/adapters/clientErrorLogger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,eAAO,MAAM,iBAAiB,8BAEd,KAAK,KAAG,IAAI,eAG1B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { logClientError } from "#internal/clientErrors.ts";
|
|
3
|
+
export const clientErrorLogger = Effect.fnUntraced(function* () {
|
|
4
|
+
const run = Effect.runForkWith(yield* Effect.context());
|
|
5
|
+
return (error) => {
|
|
6
|
+
run(Effect.exit(logClientError(error)));
|
|
7
|
+
};
|
|
8
|
+
});
|
|
9
|
+
//# sourceMappingURL=clientErrorLogger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clientErrorLogger.js","sourceRoot":"","sources":["../../../src/server/adapters/clientErrorLogger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC;IAC3D,MAAM,GAAG,GAAG,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,EAAS,CAAC,CAAC;IAC/D,OAAO,CAAC,KAAY,EAAQ,EAAE;QAC7B,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACzC,CAAC,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
-
export declare const clientErrorReporter: <R>(report: (error: Error) => Effect.Effect<unknown, never, R>) => Effect.Effect<(error: Error) => void, never, R>;
|
|
2
|
+
export declare const clientErrorReporter: <R>(report: (error: Error) => Effect.Effect<unknown, never, R>) => Effect.Effect<(error: Error) => void, never, R | import("effect/Scope").Scope>;
|
|
3
3
|
//# sourceMappingURL=clientErrorReporter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientErrorReporter.d.ts","sourceRoot":"","sources":["../../../src/server/adapters/clientErrorReporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"clientErrorReporter.d.ts","sourceRoot":"","sources":["../../../src/server/adapters/clientErrorReporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAY,MAAM,QAAQ,CAAC;AAE1C,eAAO,MAAM,mBAAmB,GAAgC,CAAC,kBAAkB,KAAK,KAAK,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,2BAE7G,KAAK,KAAG,IAAI,0CAG1B,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Effect } from "effect";
|
|
1
|
+
import { Effect, FiberSet } from "effect";
|
|
2
2
|
export const clientErrorReporter = Effect.fnUntraced(function* (report) {
|
|
3
|
-
const run =
|
|
3
|
+
const run = yield* FiberSet.makeRuntime();
|
|
4
4
|
return (error) => {
|
|
5
|
-
|
|
5
|
+
run(Effect.exit(Effect.suspend(() => report(error))));
|
|
6
6
|
};
|
|
7
7
|
});
|
|
8
8
|
//# sourceMappingURL=clientErrorReporter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clientErrorReporter.js","sourceRoot":"","sources":["../../../src/server/adapters/clientErrorReporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"clientErrorReporter.js","sourceRoot":"","sources":["../../../src/server/adapters/clientErrorReporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAE1C,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAK,MAA0D;IAC5H,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,QAAQ,CAAC,WAAW,EAAK,CAAC;IAC7C,OAAO,CAAC,KAAY,EAAQ,EAAE;QAC7B,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACvD,CAAC,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect, Scope } from "effect";
|
|
2
|
-
import type { Job, WorkOptions } from "pg-boss";
|
|
2
|
+
import type { Job, StopOptions, WorkOptions } from "pg-boss";
|
|
3
3
|
import type { PgBossClient } from "#client.ts";
|
|
4
|
-
export declare const registerWorker: <R>(client: PgBossClient, name: string, options: WorkOptions, run: (job: Job<unknown>, deadline: number) => Effect.Effect<unknown, unknown, R>, scope: Scope.Scope, schema: string, maxDeferrals: number,
|
|
4
|
+
export declare const registerWorker: <R>(client: PgBossClient, name: string, options: WorkOptions, run: (job: Job<unknown>, deadline: number) => Effect.Effect<unknown, unknown, R>, scope: Scope.Scope, schema: string, maxDeferrals: number, stop?: StopOptions | undefined) => Effect.Effect<string, import("#error.ts").PgBossError, R>;
|
|
5
5
|
//# sourceMappingURL=registerWorker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerWorker.d.ts","sourceRoot":"","sources":["../../../src/server/adapters/registerWorker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAS,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"registerWorker.d.ts","sourceRoot":"","sources":["../../../src/server/adapters/registerWorker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAS,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAO/C,eAAO,MAAM,cAAc,GAAgC,CAAC,uEAIhD,GAAG,CAAC,OAAO,CAAC,YAAY,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,wJAqD/E,CAAC"}
|
|
@@ -4,28 +4,43 @@ import { batchHandler } from "#internal/batchHandler.ts";
|
|
|
4
4
|
import { deferrableAttempt } from "#internal/deferrableAttempt.ts";
|
|
5
5
|
import { retryWake } from "#internal/retryWake.ts";
|
|
6
6
|
import { traceJob } from "#internal/tracing.ts";
|
|
7
|
-
export const registerWorker = Effect.fnUntraced(function* (client, name, options, run, scope, schema, maxDeferrals,
|
|
7
|
+
export const registerWorker = Effect.fnUntraced(function* (client, name, options, run, scope, schema, maxDeferrals, stop) {
|
|
8
8
|
const execute = Effect.runPromiseWith(yield* Effect.context());
|
|
9
|
-
const
|
|
9
|
+
const workerScope = yield* Scope.fork(scope);
|
|
10
|
+
const fibers = yield* Scope.fork(workerScope);
|
|
10
11
|
function runJob(job, deadline) {
|
|
11
12
|
return traceJob(deferrableAttempt(run(job, deadline), client, schema, job, maxDeferrals), job, name);
|
|
12
13
|
}
|
|
13
|
-
function
|
|
14
|
-
return retryWake(client, name, attempt.id, registration).pipe(Effect.forkIn(fibers), Effect.asVoid);
|
|
14
|
+
function afterRetry(attempt) {
|
|
15
|
+
return retryWake(client, schema, name, attempt.id, registration).pipe(Effect.forkIn(fibers), Effect.asVoid);
|
|
15
16
|
}
|
|
16
17
|
const handle = yield* Effect.try({
|
|
17
18
|
catch: (error) => toPgBossError("register", error, name),
|
|
18
|
-
try: () =>
|
|
19
|
+
try: () => {
|
|
20
|
+
const unsupported = ["perJobResults", "transactional"].filter((mode) => options[mode] === true);
|
|
21
|
+
if (unsupported.length > 0) {
|
|
22
|
+
throw new TypeError(`Unsupported worker callback modes: ${unsupported.join(", ")}. Omit these options or set them to false.`);
|
|
23
|
+
}
|
|
24
|
+
return batchHandler(client, name, schema, runJob, afterRetry);
|
|
25
|
+
},
|
|
19
26
|
});
|
|
20
27
|
const registration = yield* Effect.try({
|
|
21
28
|
catch: (error) => toPgBossError("register", error, name),
|
|
22
29
|
try: () => client.work(name, { ...options, includeMetadata: true }, (jobs) => execute(handle(jobs).pipe(Effect.forkIn(fibers), Effect.flatMap(Fiber.join)))),
|
|
23
30
|
});
|
|
24
31
|
const id = yield* Effect.tryPromise({ catch: (error) => toPgBossError("register", error, name), try: () => registration });
|
|
25
|
-
|
|
32
|
+
const graceful = stop?.graceful !== false;
|
|
33
|
+
const timeout = stop?.timeout ?? 30_000;
|
|
34
|
+
const drain = Effect.tryPromise({
|
|
26
35
|
catch: (error) => toPgBossError("stop", error, name),
|
|
27
36
|
try: () => client.offWork(name, { id, wait: graceful }),
|
|
28
|
-
})
|
|
37
|
+
});
|
|
38
|
+
yield* Scope.addFinalizer(workerScope, (graceful
|
|
39
|
+
? drain.pipe(Effect.timeoutOrElse({
|
|
40
|
+
duration: timeout,
|
|
41
|
+
orElse: () => Effect.logWarning(`pg-boss worker drain timed out for queue ${name} after ${timeout}ms; interrupting in-flight work`),
|
|
42
|
+
}), Effect.interruptible)
|
|
43
|
+
: drain).pipe(Effect.catch(Effect.logError)));
|
|
29
44
|
return id;
|
|
30
45
|
});
|
|
31
46
|
//# sourceMappingURL=registerWorker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerWorker.js","sourceRoot":"","sources":["../../../src/server/adapters/registerWorker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAG9C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EACxD,MAAoB,EACpB,IAAY,EACZ,OAAoB,EACpB,GAAgF,EAChF,KAAkB,EAClB,MAAc,EACd,YAAoB,EACpB,
|
|
1
|
+
{"version":3,"file":"registerWorker.js","sourceRoot":"","sources":["../../../src/server/adapters/registerWorker.ts"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K,EAAE,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,YAAY,EAAE,CAAC,CAAC;IAC3H,MAAM,QAAQ,GAAG,IAAI,EAAE,QAAQ,KAAK,KAAK,CAAC;IAC1C,MAAM,OAAO,GAAG,IAAI,EAAE,OAAO,IAAI,MAAM,CAAC;IACxC,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC;QAC/B,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC;QACpD,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;KACvD,CAAC,CAAC;IACH,KAAK,CAAC,CAAC,KAAK,CAAC,YAAY,CACxB,WAAW,EACX,CAAC,QAAQ;QACR,CAAC,CAAC,KAAK,CAAC,IAAI,CACV,MAAM,CAAC,aAAa,CAAC;YACpB,QAAQ,EAAE,OAAO;YACjB,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,4CAA4C,IAAI,UAAU,OAAO,iCAAiC,CAAC;SACnI,CAAC,EACF,MAAM,CAAC,aAAa,CACpB;QACF,CAAC,CAAC,KAAK,CACP,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CACrC,CAAC;IACF,OAAO,EAAE,CAAC;AACX,CAAC,CAAC,CAAC"}
|
|
@@ -40,9 +40,9 @@ export interface QueueWorker<TPayload extends JobPayloadSchema = JobPayloadSchem
|
|
|
40
40
|
readonly handler: (payload: Schema.Schema.Type<TPayload>, job: JobContext) => Effect.Effect<unknown, unknown, TRequirements>;
|
|
41
41
|
readonly queue: QueueDefinition<string, TPayload>;
|
|
42
42
|
}
|
|
43
|
-
export
|
|
44
|
-
readonly
|
|
45
|
-
}
|
|
43
|
+
export type JobRegistration<TRequirements = unknown> = QueueDefinition | QueueWorker<JobPayloadSchema & {
|
|
44
|
+
readonly DecodingServices: TRequirements;
|
|
45
|
+
}, TRequirements> | ScheduledWorker<TRequirements>;
|
|
46
46
|
export interface ScheduleDefinition<TName extends string = string> {
|
|
47
47
|
readonly _tag: "ScheduleDefinition";
|
|
48
48
|
readonly cron: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../src/server/definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACzD,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;;;;;AAGlF,qBAAa,OAAQ,SAAQ,YAG3B;CAAG;AAEL,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,QAAQ,CAAC,CAAC,MAAM,OAAO,QAAQ,CAAC,CAAC;AACnE,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,GAAG,QAAQ,CAAC,GAAG;IAC1E,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC9B,CAAC;AAEF,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,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IACzC,QAAQ,CAAC,EAAE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G,UAAU,CAW7F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../../src/server/definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAElF,MAAM,OAAO,OAAQ,SAAQ,MAAM,CAAC,WAAW,EAAW,CAAC,SAAS,EAAE;IACrE,EAAE,EAAE,MAAM,CAAC,WAAW;IACtB,MAAM,EAAE,MAAM,CAAC,MAAM;CACrB,CAAC;CAAG;
|
|
1
|
+
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../../src/server/definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEzD,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAElF,MAAM,OAAO,OAAQ,SAAQ,MAAM,CAAC,WAAW,EAAW,CAAC,SAAS,EAAE;IACrE,EAAE,EAAE,MAAM,CAAC,WAAW;IACtB,MAAM,EAAE,MAAM,CAAC,MAAM;CACrB,CAAC;CAAG;AA2FL,MAAM,UAAU,WAAW,CAC1B,OAA4C;IAE5C,MAAM,UAAU,GAAqC;QACpD,IAAI,EAAE,iBAAiB;QACvB,GAAG,CAAC,OAAO,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC;QAC1D,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,CACnB,MAAM,CAAC,MAAM,CAAC;YACb,IAAI,EAAE,aAAsB;YAC5B,OAAO;YACP,KAAK,EAAE,UAAU;SACjB,CAAC;QACH,YAAY,EAAE,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC;QACzC,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,YAAY,EAAE,kBAAkB,CAAC,OAAO,CAAC,KAAK,CAAC;QAC/C,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,aAAa,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;KAC5F,CAAC;IACF,OAAO,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;AAClC,CAAC;AAUD,MAAM,UAAU,UAAU,CAAC,GAAiB,EAAE,QAAgB,EAAE,aAAa,GAAG,CAAC;IAChF,OAAO;QACN,aAAa;QACb,eAAe,EAAE,GAAG,CAAC,eAAe;QACpC,gBAAgB,EAAE,GAAG,CAAC,gBAAgB;QACtC,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,eAAe,EAAE,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,iBAAiB,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,GAAG,GAAG,CAAC,CAAC,CAAC;QAC3G,UAAU,EAAE,GAAG,CAAC,UAAU;QAC1B,MAAM,EAAE,GAAG,CAAC,MAAM;KAClB,CAAC;AACH,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import type { Job } from "pg-boss";
|
|
3
3
|
import type { PgBossClient } from "#client.ts";
|
|
4
|
-
export declare function batchHandler<R>(client: PgBossClient, name: string, schema: string, run: (job: Job<unknown>, deadline: number) => Effect.Effect<unknown, unknown, R>,
|
|
4
|
+
export declare function batchHandler<R>(client: PgBossClient, name: string, schema: string, run: (job: Job<unknown>, deadline: number) => Effect.Effect<unknown, unknown, R>, afterRetry?: (job: Job<unknown>) => Effect.Effect<void, unknown>): (jobs: readonly Job<unknown>[]) => Effect.Effect<void, unknown, R>;
|
|
5
5
|
//# sourceMappingURL=batchHandler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batchHandler.d.ts","sourceRoot":"","sources":["../../../src/server/internal/batchHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,MAAM,EAAQ,MAAM,QAAQ,CAAC;AACpD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAEnC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AA8C/C,wBAAgB,YAAY,CAAC,CAAC,EAC7B,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,EAChF,
|
|
1
|
+
{"version":3,"file":"batchHandler.d.ts","sourceRoot":"","sources":["../../../src/server/internal/batchHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,MAAM,EAAQ,MAAM,QAAQ,CAAC;AACpD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AAEnC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AA8C/C,wBAAgB,YAAY,CAAC,CAAC,EAC7B,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,EAChF,UAAU,GAAE,CAAC,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAqB,UA0BrE,SAAS,GAAG,CAAC,OAAO,CAAC,EAAE,qCAiBrC"}
|
|
@@ -36,7 +36,7 @@ function aborted(signal) {
|
|
|
36
36
|
return Effect.sync(() => signal.removeEventListener("abort", interrupt));
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
-
export function batchHandler(client, name, schema, run,
|
|
39
|
+
export function batchHandler(client, name, schema, run, afterRetry = () => Effect.void) {
|
|
40
40
|
const complete = client.complete?.bind(client);
|
|
41
41
|
const fail = client.fail?.bind(client);
|
|
42
42
|
if (complete === undefined || fail === undefined) {
|
|
@@ -56,8 +56,8 @@ export function batchHandler(client, name, schema, run, afterFailure = () => Eff
|
|
|
56
56
|
return "interrupted";
|
|
57
57
|
}
|
|
58
58
|
yield* settleAttempt(complete, fail, name, job, exit);
|
|
59
|
-
if (Exit.isFailure(exit)) {
|
|
60
|
-
yield*
|
|
59
|
+
if (Exit.isFailure(exit) || exit.value === deferredAttempt) {
|
|
60
|
+
yield* afterRetry(job);
|
|
61
61
|
}
|
|
62
62
|
return "settled";
|
|
63
63
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batchHandler.js","sourceRoot":"","sources":["../../../src/server/internal/batchHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEjE,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAErE,SAAS,aAAa,CAC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AO,KAAK,OAAO,KAAK,SAAS,CAAC;QACnC,CAAC;QACD,IAAI,OAAO,EAAE,CAAC;YACb,KAAK,CAAC,CAAC,aAAa,CAAC;QACtB,CAAC;IACF,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jobControl.d.ts","sourceRoot":"","sources":["../../../src/server/internal/jobControl.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"jobControl.d.ts","sourceRoot":"","sources":["../../../src/server/internal/jobControl.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAK/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAWjD,wBAAgB,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,aAAa,CAAC,QAAQ,CAAC,CAuBvE;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG,aAAa,CAAC,OAAO,CAAC,CAkBrE"}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import { Effect, Option } from "effect";
|
|
1
|
+
import { Effect, Option, Redacted, Schema } from "effect";
|
|
2
2
|
import { redact } from "@shivaedev/errors/redact.ts";
|
|
3
|
-
import { toPgBossError } from "#error.ts";
|
|
3
|
+
import { PgBossPayloadError, toPgBossError } from "#error.ts";
|
|
4
|
+
import { deferralOf } from "#internal/deferral.ts";
|
|
4
5
|
import { decodeStoredData } from "#internal/storedRows.ts";
|
|
6
|
+
import { JobFailure } from "#JobFailure.ts";
|
|
7
|
+
const StoredFailure = Schema.Union([JobFailure, Schema.Struct({ value: JobFailure })]);
|
|
8
|
+
function decodeFailure(queue, output) {
|
|
9
|
+
return Schema.decodeUnknownEffect(StoredFailure)(output).pipe(Effect.map((failure) => ("value" in failure ? failure.value : failure)), Effect.mapError((error) => new PgBossPayloadError({ direction: "decode", original: Redacted.make(error), queue })));
|
|
10
|
+
}
|
|
5
11
|
export function getJobFor(client) {
|
|
6
12
|
return (queue, id) => Effect.tryPromise({
|
|
7
13
|
catch: (error) => toPgBossError("getJob", error, queue.name),
|
|
@@ -11,9 +17,15 @@ export function getJobFor(client) {
|
|
|
11
17
|
}
|
|
12
18
|
return (await client.findJobs(queue.name, { id }))[0];
|
|
13
19
|
},
|
|
14
|
-
}).pipe(Effect.flatMap((job)
|
|
15
|
-
|
|
16
|
-
|
|
20
|
+
}).pipe(Effect.flatMap(Effect.fnUntraced(function* (job) {
|
|
21
|
+
if (job === undefined) {
|
|
22
|
+
return Option.none();
|
|
23
|
+
}
|
|
24
|
+
const data = yield* decodeStoredData(queue, job.data);
|
|
25
|
+
const output = job.output === null || deferralOf(job) !== undefined ? job.output : yield* decodeFailure(queue.name, job.output);
|
|
26
|
+
const sourceOutput = job.sourceOutput === null ? null : yield* decodeFailure(queue.name, job.sourceOutput);
|
|
27
|
+
return Option.some({ ...job, data: redact(data), output, sourceOutput });
|
|
28
|
+
})));
|
|
17
29
|
}
|
|
18
30
|
export function retryFor(client) {
|
|
19
31
|
return (queue, id) => Effect.tryPromise({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jobControl.js","sourceRoot":"","sources":["../../../src/server/internal/jobControl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
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;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAErD,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,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AK,SAAS,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,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,8 +1,9 @@
|
|
|
1
|
-
import { type Context, Effect,
|
|
1
|
+
import { type Context, Effect, Scope } from "effect";
|
|
2
|
+
import type { StopOptions } from "pg-boss";
|
|
2
3
|
import type { PgBossClient } from "#client.ts";
|
|
3
4
|
import type { JobRegistration } from "#definition.ts";
|
|
4
5
|
import { PgBossQueueOptionsError } from "#error.ts";
|
|
5
6
|
export declare function registrationName(registration: JobRegistration): string;
|
|
6
7
|
export declare function registrationNames(registrations: readonly JobRegistration[]): readonly string[];
|
|
7
|
-
export declare const registerJobs: <R>(client: PgBossClient, registrations: readonly JobRegistration[], context: Context.Context<R>, replaceWorkers: boolean, schema?: string | undefined, startWorkers?: boolean | undefined,
|
|
8
|
+
export declare const registerJobs: <R>(client: PgBossClient, registrations: readonly JobRegistration<R>[], context: Context.Context<R>, replaceWorkers: boolean, schema?: string | undefined, startWorkers?: boolean | undefined, stop?: StopOptions | undefined) => Effect.Effect<void, import("#error.ts").PgBossError | PgBossQueueOptionsError, Scope.Scope>;
|
|
8
9
|
//# sourceMappingURL=register.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../src/server/internal/register.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,EAAE,KAAK,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../src/server/internal/register.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAG3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,EAAoB,eAAe,EAAqE,MAAM,gBAAgB,CAAC;AAC3I,OAAO,EAAE,uBAAuB,EAAiB,MAAM,WAAW,CAAC;AAenE,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,eAAe,GAAG,MAAM,CAEtE;AAkED,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,SAAS,eAAe,EAAE,GAAG,SAAS,MAAM,EAAE,CAM9F;AAED,eAAO,MAAM,YAAY,GAAgC,CAAC,2TAyBxD,CAAC"}
|
|
@@ -1,35 +1,25 @@
|
|
|
1
|
-
import { Effect } from "effect";
|
|
1
|
+
import { Effect, Scope } from "effect";
|
|
2
2
|
import { registerWorker } from "#adapters/registerWorker.ts";
|
|
3
|
+
import { workerDiagnostics } from "#adapters/workerDiagnostics.ts";
|
|
3
4
|
import { PgBossQueueOptionsError, toPgBossError } from "#error.ts";
|
|
4
5
|
import { ensureQueue } from "#internal/ensureQueue.ts";
|
|
5
6
|
import { runQueueWorker } from "#internal/runQueueWorker.ts";
|
|
6
|
-
|
|
7
|
-
return registration._tag === "QueueWorker";
|
|
8
|
-
}
|
|
9
|
-
function isScheduledWorker(registration) {
|
|
10
|
-
return registration._tag === "ScheduledWorker";
|
|
11
|
-
}
|
|
12
|
-
function isQueueDefinition(registration) {
|
|
13
|
-
return registration._tag === "QueueDefinition";
|
|
14
|
-
}
|
|
7
|
+
import { registerTestingQueue } from "#internal/testingRegistrations.ts";
|
|
15
8
|
function registrationDefinition(registration) {
|
|
16
|
-
if (
|
|
9
|
+
if (registration._tag === "QueueDefinition") {
|
|
17
10
|
return registration;
|
|
18
11
|
}
|
|
19
|
-
if (
|
|
12
|
+
if (registration._tag === "QueueWorker") {
|
|
20
13
|
return registration.queue;
|
|
21
14
|
}
|
|
22
|
-
|
|
23
|
-
return registration.schedule;
|
|
24
|
-
}
|
|
25
|
-
throw new TypeError(`Unknown pg-boss registration: ${registration._tag}`);
|
|
15
|
+
return registration.schedule;
|
|
26
16
|
}
|
|
27
17
|
export function registrationName(registration) {
|
|
28
18
|
return registrationDefinition(registration).name;
|
|
29
19
|
}
|
|
30
20
|
const prepareQueues = Effect.fnUntraced(function* (client, registrations, replaceWorkers) {
|
|
31
21
|
for (const registration of registrations) {
|
|
32
|
-
if (replaceWorkers &&
|
|
22
|
+
if (replaceWorkers && registration._tag !== "QueueDefinition") {
|
|
33
23
|
yield* Effect.tryPromise({ catch: (error) => toPgBossError("register", error), try: () => client.offWork(registrationName(registration)) });
|
|
34
24
|
}
|
|
35
25
|
}
|
|
@@ -38,20 +28,17 @@ const prepareQueues = Effect.fnUntraced(function* (client, registrations, replac
|
|
|
38
28
|
yield* ensureQueue(client, definition.name, definition.queueOptions).pipe(Effect.mapError((error) => (error instanceof PgBossQueueOptionsError ? error : toPgBossError("register", error, definition.name))));
|
|
39
29
|
}
|
|
40
30
|
});
|
|
41
|
-
function
|
|
42
|
-
return context;
|
|
43
|
-
}
|
|
44
|
-
const registerQueue = Effect.fnUntraced(function* (client, registration, context, scope, schema, graceful) {
|
|
31
|
+
const registerQueue = Effect.fnUntraced(function* (client, registration, context, scope, schema, stop) {
|
|
45
32
|
const queue = registration._tag === "QueueWorker" ? registration.queue : registration;
|
|
46
33
|
const name = queue.name;
|
|
47
34
|
if (registration._tag === "QueueDefinition") {
|
|
48
35
|
return;
|
|
49
36
|
}
|
|
50
|
-
yield* registerWorker(client, name, queue.workerOptions, (job, deadline) => runQueueWorker(registration, job, deadline, client, schema), scope, schema, queue.maxDeferrals,
|
|
37
|
+
yield* registerWorker(client, name, queue.workerOptions, (job, deadline) => runQueueWorker(registration, job, deadline, client, schema), scope, schema, queue.maxDeferrals, stop).pipe(Effect.provide(context));
|
|
51
38
|
});
|
|
52
|
-
const registerSchedule = Effect.fnUntraced(function* (client, worker, context, scope, schema,
|
|
39
|
+
const registerSchedule = Effect.fnUntraced(function* (client, worker, context, scope, schema, stop) {
|
|
53
40
|
const { schedule } = worker;
|
|
54
|
-
yield* registerWorker(client, schedule.name, schedule.workerOptions, () => worker.effect, scope, schema, schedule.maxDeferrals,
|
|
41
|
+
yield* registerWorker(client, schedule.name, schedule.workerOptions, () => workerDiagnostics(worker.effect), scope, schema, schedule.maxDeferrals, stop).pipe(Effect.provide(context));
|
|
55
42
|
yield* Effect.tryPromise({
|
|
56
43
|
catch: (error) => toPgBossError("register", error, schedule.name),
|
|
57
44
|
try: () => client.schedule(schedule.name, schedule.cron, null, schedule.scheduleOptions),
|
|
@@ -64,20 +51,22 @@ export function registrationNames(registrations) {
|
|
|
64
51
|
}
|
|
65
52
|
return names;
|
|
66
53
|
}
|
|
67
|
-
export const registerJobs = Effect.fnUntraced(function* (client, registrations, context, replaceWorkers, schema = "pgboss", startWorkers = true,
|
|
68
|
-
const scope = yield* Effect.scope;
|
|
54
|
+
export const registerJobs = Effect.fnUntraced(function* (client, registrations, context, replaceWorkers, schema = "pgboss", startWorkers = true, stop) {
|
|
55
|
+
const scope = yield* Scope.fork(yield* Effect.scope, "parallel");
|
|
69
56
|
yield* Effect.try({ catch: (error) => toPgBossError("register", error), try: () => registrationNames(registrations) });
|
|
70
57
|
yield* prepareQueues(client, registrations, replaceWorkers);
|
|
58
|
+
for (const registration of registrations) {
|
|
59
|
+
registerTestingQueue(client, registrationName(registration));
|
|
60
|
+
}
|
|
71
61
|
if (!startWorkers) {
|
|
72
62
|
return;
|
|
73
63
|
}
|
|
74
|
-
const provided = workerContext(context);
|
|
75
64
|
for (const registration of registrations) {
|
|
76
|
-
if (
|
|
77
|
-
yield* registerQueue(client, registration,
|
|
65
|
+
if (registration._tag === "QueueWorker" || registration._tag === "QueueDefinition") {
|
|
66
|
+
yield* registerQueue(client, registration, context, scope, schema, stop);
|
|
78
67
|
}
|
|
79
|
-
else
|
|
80
|
-
yield* registerSchedule(client, registration,
|
|
68
|
+
else {
|
|
69
|
+
yield* registerSchedule(client, registration, context, scope, schema, stop);
|
|
81
70
|
}
|
|
82
71
|
}
|
|
83
72
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.js","sourceRoot":"","sources":["../../../src/server/internal/register.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,MAAM,
|
|
1
|
+
{"version":3,"file":"register.js","sourceRoot":"","sources":["../../../src/server/internal/register.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAErD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAGnE,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAEzE,SAAS,sBAAsB,CAAC,YAA6B;IAC5D,IAAI,YAAY,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