@shivaedev/effect-pg-boss 0.10.1 → 0.11.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 +9 -0
- package/README.md +24 -4
- package/dist/server/definition.d.ts +15 -3
- package/dist/server/definition.d.ts.map +1 -1
- package/dist/server/definition.js +21 -3
- package/dist/server/definition.js.map +1 -1
- package/dist/server/internal/batchHandler.d.ts.map +1 -1
- package/dist/server/internal/batchHandler.js +13 -7
- package/dist/server/internal/batchHandler.js.map +1 -1
- package/dist/server/internal/deferrableAttempt.d.ts +7 -0
- package/dist/server/internal/deferrableAttempt.d.ts.map +1 -0
- package/dist/server/internal/deferrableAttempt.js +28 -0
- package/dist/server/internal/deferrableAttempt.js.map +1 -0
- package/dist/server/internal/deferral.d.ts +15 -0
- package/dist/server/internal/deferral.d.ts.map +1 -0
- package/dist/server/internal/deferral.js +14 -0
- package/dist/server/internal/deferral.js.map +1 -0
- package/dist/server/internal/deferralStorePlan.d.ts +2 -0
- package/dist/server/internal/deferralStorePlan.d.ts.map +1 -0
- package/dist/server/internal/deferralStorePlan.js +34 -0
- package/dist/server/internal/deferralStorePlan.js.map +1 -0
- package/dist/server/internal/expireAttempt.d.ts +1 -1
- package/dist/server/internal/expireAttempt.d.ts.map +1 -1
- package/dist/server/internal/expireAttempt.js +4 -2
- package/dist/server/internal/expireAttempt.js.map +1 -1
- package/dist/server/internal/lifecycle.d.ts.map +1 -1
- package/dist/server/internal/lifecycle.js +4 -0
- package/dist/server/internal/lifecycle.js.map +1 -1
- package/dist/server/internal/register.d.ts +1 -1
- package/dist/server/internal/register.d.ts.map +1 -1
- package/dist/server/internal/register.js +10 -10
- package/dist/server/internal/register.js.map +1 -1
- package/dist/server/internal/registerWorker.d.ts +2 -2
- package/dist/server/internal/registerWorker.d.ts.map +1 -1
- package/dist/server/internal/registerWorker.js +7 -2
- package/dist/server/internal/registerWorker.js.map +1 -1
- package/dist/server/internal/settleDeferral.d.ts +7 -0
- package/dist/server/internal/settleDeferral.d.ts.map +1 -0
- package/dist/server/internal/settleDeferral.js +47 -0
- package/dist/server/internal/settleDeferral.js.map +1 -0
- 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/testingDeferrals.d.ts +11 -0
- package/dist/server/internal/testingDeferrals.d.ts.map +1 -0
- package/dist/server/internal/testingDeferrals.js +28 -0
- package/dist/server/internal/testingDeferrals.js.map +1 -0
- package/dist/server/schema.d.ts.map +1 -1
- package/dist/server/schema.js +8 -1
- package/dist/server/schema.js.map +1 -1
- package/dist/server/service.js +1 -1
- package/dist/server/service.js.map +1 -1
- package/dist/server/testing.d.ts +5 -0
- package/dist/server/testing.d.ts.map +1 -1
- package/dist/server/testing.js +4 -0
- package/dist/server/testing.js.map +1 -1
- package/package.json +3 -3
- package/src/server/definition.ts +29 -5
- package/src/server/internal/batchHandler.ts +21 -6
- package/src/server/internal/deferrableAttempt.ts +41 -0
- package/src/server/internal/deferral.ts +19 -0
- package/src/server/internal/deferralStorePlan.ts +34 -0
- package/src/server/internal/expireAttempt.ts +4 -2
- package/src/server/internal/lifecycle.ts +4 -0
- package/src/server/internal/register.ts +15 -15
- package/src/server/internal/registerWorker.ts +39 -26
- package/src/server/internal/settleDeferral.ts +53 -0
- package/src/server/internal/testingClient.ts +4 -1
- package/src/server/internal/testingDeferrals.ts +43 -0
- package/src/server/schema.ts +8 -1
- package/src/server/service.ts +1 -1
- package/src/server/testing.ts +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.11.0 - 2026-10-18
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Fail a queue or scheduled handler with `RetryAt({ at, reason })` from `definition.ts` to defer the same job until a UTC time without spending a retry, changing its payload or singleton key, or calling `onError`. A deferred attempt ends its span OK with a `job.deferred` event. The exported `QueueOptions` type adds `maxDeferrals`, and queue and schedule definitions expose its resolved value. `queue.maxDeferrals` defaults to 10 per job; subsequent deferrals fail normally. Deferred jobs use the polling backstop, including with `notify: true`.
|
|
8
|
+
- Inspect waiting deferrals with the testing controller's `deferred(queue)`, returning `{ at, reason }[]`, and pull them forward with `runDeferredNow(queue)`. Both integrate with the controller's revision and change notification controls.
|
|
9
|
+
- Deferral counts survive native expiry and heartbeat failures. Automatic migrations and `installPgBossSchema` install the adapter's durable counter table alongside the pg-boss schema.
|
|
10
|
+
- Stately jobs sharing a singleton key can defer together without colliding or spending retries, and resume one at a time. Waiting deferrals use the `effect-stately-deferred` policy in native job metadata; an adapter-installed database trigger restores `stately` when claimed.
|
|
11
|
+
|
|
3
12
|
## 0.10.1 - 2026-10-18
|
|
4
13
|
|
|
5
14
|
### Fixed
|
package/README.md
CHANGED
|
@@ -130,6 +130,24 @@ This worker runs up to five handlers at once. `worker` accepts pg-boss 12's `Wor
|
|
|
130
130
|
|
|
131
131
|
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 belongs to the worker Layer's scope and is canceled when that scope closes. 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.
|
|
132
132
|
|
|
133
|
+
### Defer until a provider is ready
|
|
134
|
+
|
|
135
|
+
Fail a queue handler or scheduled Effect with `RetryAt` when a provider gives a time to try again:
|
|
136
|
+
|
|
137
|
+
```ts
|
|
138
|
+
import { DateTime, Effect } from "effect";
|
|
139
|
+
import { RetryAt } from "@shivaedev/effect-pg-boss/definition.ts";
|
|
140
|
+
|
|
141
|
+
const waitForQuota = Effect.fail(new RetryAt({
|
|
142
|
+
at: DateTime.makeUnsafe("2030-01-01T00:01:00Z"),
|
|
143
|
+
reason: "Provider quota resets",
|
|
144
|
+
}));
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
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. Deferred jobs rely on polling, including queues using `notify: true`. 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.
|
|
148
|
+
|
|
149
|
+
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. Automatic migrations and `installPgBossSchema` create this table and the stately claim trigger; use `installPgBossSchema` before starting workers with `migrate: false`.
|
|
150
|
+
|
|
133
151
|
### Size batches against expiry
|
|
134
152
|
|
|
135
153
|
pg-boss marks every job in a fetched batch active together. Each job's expiry window starts at its stored `startedOn`, including time waiting for earlier handlers. Size each queue's batch so its sequential work fits within that window; use a small batch for long-running work and keep the default for short work:
|
|
@@ -275,7 +293,7 @@ export const inspectEmail = (id: string) => Effect.gen(function* () {
|
|
|
275
293
|
|
|
276
294
|
### Queue settings on startup
|
|
277
295
|
|
|
278
|
-
`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.
|
|
296
|
+
`queue` accepts pg-boss `Queue` options except `name` and `deadLetter`, which the definition and adapter own, plus the adapter’s `maxDeferrals` limit. For prompt delivery, set `queue: { notify: true }` and enable `useListenNotify: true` in the worker Layer's constructor options.
|
|
279
297
|
|
|
280
298
|
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.
|
|
281
299
|
|
|
@@ -381,6 +399,8 @@ Set `retryPolicy: testRetryPolicy` through the controller to override queue and
|
|
|
381
399
|
|
|
382
400
|
`failNextSend(queue)` arms one send failure for that queue. The next valid `enqueue` fails with the usual typed `PgBossError` (`operation: "enqueue"`); the following send proceeds normally. `expireAfter(queue, n)` takes a positive attempt count: configure it before enqueueing to limit subsequent jobs to `n` attempts. Each successful send keeps its own expiry rule; later changes and duplicate-ID sends do not alter pending jobs. Earlier attempts run the handler normally; on attempt `n`, the controller expires the claimed job instead of invoking its handler. PostgreSQL supervision performs the terminal failure and dead lettering. A job that succeeds earlier completes normally. This expiry hook supports pg-boss schema version 45.
|
|
383
401
|
|
|
402
|
+
`deferred(queue)` returns waiting deferrals as `{ at: DateTime.Utc, reason: string }[]`. `runDeferredNow(queue)` pulls those jobs forward to the database’s current time and wakes local workers without waiting for their original due time. Read `revision` before reading deferrals and use `waitForChange(revision)` as with other controls.
|
|
403
|
+
|
|
384
404
|
`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`.
|
|
385
405
|
|
|
386
406
|
A kit can capture `revision` before reading jobs and yield `waitForChange(revision)` when its condition is unmet. The wait resumes after a local send, settlement, worker fetch or return to idle, including terminal native worker timeouts whose handler promises remain pending. 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.
|
|
@@ -391,7 +411,7 @@ Import the module that defines the name; the package has no root entry.
|
|
|
391
411
|
|
|
392
412
|
| Module | Public names |
|
|
393
413
|
| --- | --- |
|
|
394
|
-
| `@shivaedev/effect-pg-boss/definition.ts` | `defineQueue`, `defineSchedule`, `jobContext`; `DefineQueueOptions`, `DefineScheduleOptions`, `JobContext`, `JobPayloadSchema`, `JobRegistration`, `QueueDefinition`, `QueueWorker`, `RegistrationRequirements`, `ScheduleDefinition`, `ScheduledWorker` |
|
|
414
|
+
| `@shivaedev/effect-pg-boss/definition.ts` | `defineQueue`, `defineSchedule`, `jobContext`, `RetryAt`; `DefineQueueOptions`, `DefineScheduleOptions`, `JobContext`, `JobPayloadSchema`, `JobRegistration`, `QueueDefinition`, `QueueOptions`, `QueueWorker`, `RegistrationRequirements`, `ScheduleDefinition`, `ScheduledWorker` |
|
|
395
415
|
| `@shivaedev/effect-pg-boss/service.ts` | `makePgBoss`; `PgBossDefinition`, `PgBossLayerOptions`, `PgBossService` |
|
|
396
416
|
| `@shivaedev/effect-pg-boss/schema.ts` | `installPgBossSchema`; `PgBossSchemaOptions` |
|
|
397
417
|
| `@shivaedev/effect-pg-boss/health.ts` | `deadLetterQueueName`; `JobsHealth`, `QueueCounts`, `QueueHealth` |
|
|
@@ -399,9 +419,9 @@ Import the module that defines the name; the package has no root entry.
|
|
|
399
419
|
| `@shivaedev/effect-pg-boss/client.ts` | `defaultClientFactory`; `PgBossClient`, `PgBossClientFactory` |
|
|
400
420
|
| `@shivaedev/effect-pg-boss/testing.ts` | `makePgBossTesting`, `testRetryPolicy`; `PgBossTesting`, `PgBossTestingOptions` |
|
|
401
421
|
|
|
402
|
-
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`.
|
|
422
|
+
The definition options keep the pg-boss names: `queue` uses `QueueOptions` (`Queue` except `name` and `deadLetter`, plus `maxDeferrals`), `worker` uses `WorkOptions`, and a schedule's `schedule` uses `ScheduleOptions`. A queue also requires `name` and `schema`; a schedule requires `name` and `cron`.
|
|
403
423
|
|
|
404
|
-
`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`. Producer-only clients do not need them. Custom clients can also 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.
|
|
424
|
+
`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`. Producer-only clients do not need them. Custom clients can also supply the optional native capabilities `findJobs`, `retry`, `update`, `getDb` and `updateQueue` for lookup, retry, live counts, deferral and reconciliation; a requested operation fails with `PgBossError` if its required capability is absent.
|
|
405
425
|
|
|
406
426
|
`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.
|
|
407
427
|
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
import { Duration, Effect,
|
|
1
|
+
import { Duration, Effect, Schema } from "effect";
|
|
2
2
|
import type { Job, Queue, ScheduleOptions, WorkOptions } from "pg-boss";
|
|
3
|
+
declare const RetryAt_base: Schema.Class<RetryAt, Schema.TaggedStruct<"RetryAt", {
|
|
4
|
+
readonly at: Schema.DateTimeUtc;
|
|
5
|
+
readonly reason: Schema.String;
|
|
6
|
+
}>, import("effect/Cause").YieldableError>;
|
|
7
|
+
export declare class RetryAt extends RetryAt_base {
|
|
8
|
+
}
|
|
9
|
+
export type QueueOptions = Omit<Queue, "name" | "deadLetter"> & {
|
|
10
|
+
readonly maxDeferrals?: number;
|
|
11
|
+
};
|
|
3
12
|
export interface JobPayloadSchema extends Schema.Top {
|
|
4
13
|
readonly Encoded: object;
|
|
5
14
|
readonly Type: object;
|
|
@@ -15,6 +24,7 @@ export interface JobContext {
|
|
|
15
24
|
export interface QueueDefinition<Name extends string = string, Payload extends JobPayloadSchema = JobPayloadSchema> {
|
|
16
25
|
readonly _tag: "QueueDefinition";
|
|
17
26
|
readonly handle: <E, R>(handler: (payload: Schema.Schema.Type<Payload>, job: JobContext) => Effect.Effect<unknown, E, R>) => QueueWorker<Payload, R>;
|
|
27
|
+
readonly maxDeferrals: number;
|
|
18
28
|
readonly name: Name;
|
|
19
29
|
readonly queueOptions: Omit<Queue, "name" | "deadLetter">;
|
|
20
30
|
readonly schema: Payload;
|
|
@@ -31,6 +41,7 @@ export interface JobRegistration {
|
|
|
31
41
|
export interface ScheduleDefinition<Name extends string = string> {
|
|
32
42
|
readonly _tag: "ScheduleDefinition";
|
|
33
43
|
readonly cron: string;
|
|
44
|
+
readonly maxDeferrals: number;
|
|
34
45
|
readonly name: Name;
|
|
35
46
|
readonly queueOptions: Omit<Queue, "name" | "deadLetter">;
|
|
36
47
|
readonly run: <E, R>(effect: Effect.Effect<unknown, E, R>) => ScheduledWorker<R>;
|
|
@@ -45,7 +56,7 @@ export interface ScheduledWorker<Requirements = unknown> {
|
|
|
45
56
|
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;
|
|
46
57
|
export interface DefineQueueOptions<Name extends string, Payload extends JobPayloadSchema> {
|
|
47
58
|
readonly name: Name;
|
|
48
|
-
readonly queue?:
|
|
59
|
+
readonly queue?: QueueOptions;
|
|
49
60
|
readonly schema: Payload;
|
|
50
61
|
readonly worker?: WorkOptions;
|
|
51
62
|
}
|
|
@@ -53,10 +64,11 @@ export declare const defineQueue: <const Name extends string, const Payload exte
|
|
|
53
64
|
export interface DefineScheduleOptions<Name extends string> {
|
|
54
65
|
readonly cron: string;
|
|
55
66
|
readonly name: Name;
|
|
56
|
-
readonly queue?:
|
|
67
|
+
readonly queue?: QueueOptions;
|
|
57
68
|
readonly schedule?: ScheduleOptions;
|
|
58
69
|
readonly worker?: WorkOptions;
|
|
59
70
|
}
|
|
60
71
|
export declare const defineSchedule: <const Name extends string>(options: DefineScheduleOptions<Name>) => ScheduleDefinition<Name>;
|
|
61
72
|
export declare const jobContext: (job: Job<unknown>) => JobContext;
|
|
73
|
+
export {};
|
|
62
74
|
//# sourceMappingURL=definition.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../../src/server/definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,QAAQ,EAAE,MAAM,EAAE,
|
|
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,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;;;;;AAGxE,qBAAa,OAAQ,SAAQ,YAG3B;CAAG;AAEL,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAAC,GAAG;IAAE,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAenG,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,QAA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B,CAAC,GAC1C,YAAY,SAAS,eAAe,CAAC,MAAM,YAAY,CAAC,GACvD,YAAY,GACZ,KAAK,GACP,KAAK,CAAC;AAET,MAAM,WAAW,kBAAkB,CAAC,IAAI,SAAS,MAAM,EAAE,OAAO,SAAS,gBAAgB;IACxF,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,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,CAgB/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,YAAY,CAAC;IAC9B,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,CAiBvH,CAAC;AAEF,eAAO,MAAM,UAAU,QAAS,GAAG,CAAC,OAAO,CAAC,KAAG,UAO7C,CAAC"}
|
|
@@ -1,5 +1,21 @@
|
|
|
1
|
-
import { Clock, Duration, Effect } from "effect";
|
|
1
|
+
import { Clock, Duration, Effect, Schema } from "effect";
|
|
2
2
|
import { deadlineOf } from "#internal/deadlineOf.ts";
|
|
3
|
+
export class RetryAt extends Schema.TaggedError()("RetryAt", {
|
|
4
|
+
at: Schema.DateTimeUtc,
|
|
5
|
+
reason: Schema.String,
|
|
6
|
+
}) {
|
|
7
|
+
}
|
|
8
|
+
function maxDeferrals(options) {
|
|
9
|
+
const limit = options?.maxDeferrals ?? 10;
|
|
10
|
+
if (!Number.isSafeInteger(limit) || limit < 0) {
|
|
11
|
+
throw new RangeError("maxDeferrals must be a nonnegative safe integer");
|
|
12
|
+
}
|
|
13
|
+
return limit;
|
|
14
|
+
}
|
|
15
|
+
function nativeQueueOptions(options) {
|
|
16
|
+
const { maxDeferrals: _limit, ...native } = options ?? {};
|
|
17
|
+
return Object.freeze(native);
|
|
18
|
+
}
|
|
3
19
|
export const defineQueue = (options) => {
|
|
4
20
|
const definition = {
|
|
5
21
|
_tag: "QueueDefinition",
|
|
@@ -8,8 +24,9 @@ export const defineQueue = (options) => {
|
|
|
8
24
|
handler,
|
|
9
25
|
queue: definition,
|
|
10
26
|
}),
|
|
27
|
+
maxDeferrals: maxDeferrals(options.queue),
|
|
11
28
|
name: options.name,
|
|
12
|
-
queueOptions:
|
|
29
|
+
queueOptions: nativeQueueOptions(options.queue),
|
|
13
30
|
schema: options.schema,
|
|
14
31
|
workerOptions: Object.freeze({ batchSize: 10, burstWhenBatchFull: true, ...options.worker }),
|
|
15
32
|
};
|
|
@@ -19,8 +36,9 @@ export const defineSchedule = (options) => {
|
|
|
19
36
|
const definition = {
|
|
20
37
|
_tag: "ScheduleDefinition",
|
|
21
38
|
cron: options.cron,
|
|
39
|
+
maxDeferrals: maxDeferrals(options.queue),
|
|
22
40
|
name: options.name,
|
|
23
|
-
queueOptions:
|
|
41
|
+
queueOptions: nativeQueueOptions(options.queue),
|
|
24
42
|
run: (effect) => Object.freeze({
|
|
25
43
|
_tag: "ScheduledWorker",
|
|
26
44
|
effect,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../../src/server/definition.ts"],"names":[],"mappings":"AAA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AAG,CAAC,gBAAgB;IACtC,EAAE,EAAE,GAAG,CAAC,EAAE;IACV,IAAI,EAAE,GAAG,CAAC,IAAI;IACd,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,UAAU,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;IAClH,MAAM,EAAE,GAAG,CAAC,MAAM;CAClB,CAAC,CAAC"}
|
|
@@ -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;AACnC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;
|
|
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;AACnC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AA2B/C,wBAAgB,YAAY,CAC3B,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,EAC3D,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,UAQ/B,SAAS,GAAG,CAAC,OAAO,CAAC,EAAE,KAAG,OAAO,CAAC,IAAI,CAAC,CAyB3D"}
|
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
import { Cause, Clock, Effect, Exit } from "effect";
|
|
2
2
|
import { deadlineOf } from "#internal/deadlineOf.ts";
|
|
3
|
+
import { deferredAttempt } from "#internal/deferral.ts";
|
|
3
4
|
function failureOutput(cause) {
|
|
4
5
|
const error = Cause.squash(cause);
|
|
5
6
|
return typeof error === "object" && error !== null ? error : { message: String(error) };
|
|
6
7
|
}
|
|
8
|
+
async function settleAttempt(complete, fail, name, job, exit, afterFailure) {
|
|
9
|
+
if (Exit.isSuccess(exit)) {
|
|
10
|
+
if (exit.value !== deferredAttempt) {
|
|
11
|
+
await complete(name, job);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
await fail(name, job, failureOutput(exit.cause));
|
|
16
|
+
await afterFailure?.(job);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
7
19
|
export function batchHandler(client, name, run, afterFailure) {
|
|
8
20
|
const complete = client.complete?.bind(client);
|
|
9
21
|
const fail = client.fail?.bind(client);
|
|
@@ -26,13 +38,7 @@ export function batchHandler(client, name, run, afterFailure) {
|
|
|
26
38
|
// Returning would let pg-boss complete the unprocessed jobs; its expiry owns them instead.
|
|
27
39
|
return new Promise(() => undefined);
|
|
28
40
|
}
|
|
29
|
-
|
|
30
|
-
await complete(name, job);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
await fail(name, job, failureOutput(exit.cause));
|
|
34
|
-
await afterFailure?.(job);
|
|
35
|
-
}
|
|
41
|
+
await settleAttempt(complete, fail, name, job, exit, afterFailure);
|
|
36
42
|
}
|
|
37
43
|
if (expired) {
|
|
38
44
|
return new Promise(() => undefined);
|
|
@@ -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,E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,CAAC,EAAE,CAAC;gBACrF,2FAA2F;gBAC3F,OAAO,IAAI,OAAO,CAAQ,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;YAC5C,CAAC;YACD,MAAM,aAAa,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;QACpE,CAAC;QACD,IAAI,OAAO,EAAE,CAAC;YACb,OAAO,IAAI,OAAO,CAAQ,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC5C,CAAC;IACF,CAAC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import type { Job } from "pg-boss";
|
|
3
|
+
import type { PgBossClient } from "#client.ts";
|
|
4
|
+
import { RetryAt } from "#definition.ts";
|
|
5
|
+
import { deferredAttempt } from "#internal/deferral.ts";
|
|
6
|
+
export declare function deferrableAttempt<A, E, R>(effect: Effect.Effect<A, E, R>, client: PgBossClient, schema: string, job: Job<unknown>, maxDeferrals: number): Effect.Effect<typeof deferredAttempt | A, Exclude<E, import("effect/Types").NoInfer<E> & RetryAt> | (import("effect/Types").NoInfer<E> & RetryAt), R>;
|
|
7
|
+
//# sourceMappingURL=deferrableAttempt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deferrableAttempt.d.ts","sourceRoot":"","sources":["../../../src/server/internal/deferrableAttempt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,MAAM,EAAU,MAAM,QAAQ,CAAC;AACzD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAqB,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAQ3E,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EACxC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAC9B,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,EACjB,YAAY,EAAE,MAAM,yJAuBpB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Clock, DateTime, Effect, Schema } from "effect";
|
|
2
|
+
import { RetryAt } from "#definition.ts";
|
|
3
|
+
import { deferralObservers, deferredAttempt } from "#internal/deferral.ts";
|
|
4
|
+
import { settleDeferral } from "#internal/settleDeferral.ts";
|
|
5
|
+
const recordDeferral = Effect.fnUntraced(function* (at, reason) {
|
|
6
|
+
const span = yield* Effect.currentSpan.pipe(Effect.orDie);
|
|
7
|
+
span.event("job.deferred", yield* Clock.currentTimeNanos, { at, reason });
|
|
8
|
+
});
|
|
9
|
+
export function deferrableAttempt(effect, client, schema, job, maxDeferrals) {
|
|
10
|
+
return effect.pipe(Effect.catchIf(Schema.is(RetryAt), (error) => {
|
|
11
|
+
if (maxDeferrals === 0) {
|
|
12
|
+
return Effect.fail(error);
|
|
13
|
+
}
|
|
14
|
+
const at = DateTime.formatIso(error.at);
|
|
15
|
+
return Effect.promise(() => settleDeferral(client, schema, job, at, error.reason, maxDeferrals)).pipe(Effect.flatMap((settled) => {
|
|
16
|
+
if (settled.claimed && !settled.deferred) {
|
|
17
|
+
return Effect.fail(error);
|
|
18
|
+
}
|
|
19
|
+
// Native batch settlement must not match a sibling's new claim at the unchanged retry count.
|
|
20
|
+
job.retryCount = Number.MAX_SAFE_INTEGER;
|
|
21
|
+
if (settled.deferred) {
|
|
22
|
+
deferralObservers.get(client)?.();
|
|
23
|
+
}
|
|
24
|
+
return (settled.deferred ? recordDeferral(at, error.reason) : Effect.void).pipe(Effect.as(deferredAttempt));
|
|
25
|
+
}));
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=deferrableAttempt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deferrableAttempt.js","sourceRoot":"","sources":["../../../src/server/internal/deferrableAttempt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGzD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,MAAM,cAAc,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,EAAU,EAAE,MAAc;IAC7E,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1D,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC,KAAK,CAAC,gBAAgB,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;AAC3E,CAAC,CAAC,CAAC;AAEH,MAAM,UAAU,iBAAiB,CAChC,MAA8B,EAC9B,MAAoB,EACpB,MAAc,EACd,GAAiB,EACjB,YAAoB;IAEpB,OAAO,MAAM,CAAC,IAAI,CACjB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE;QAC5C,IAAI,YAAY,KAAK,CAAC,EAAE,CAAC;YACxB,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC3B,CAAC;QACD,MAAM,EAAE,GAAG,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACxC,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,IAAI,CACpG,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC1B,IAAI,OAAO,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;gBAC1C,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAC3B,CAAC;YACD,6FAA6F;YAC7F,GAAG,CAAC,UAAU,GAAG,MAAM,CAAC,gBAAgB,CAAC;YACzC,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;gBACtB,iBAAiB,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;YACnC,CAAC;YACD,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,EAAE,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC;QAC7G,CAAC,CAAC,CACF,CAAC;IACH,CAAC,CAAC,CACF,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import type { Job } from "pg-boss";
|
|
3
|
+
import type { PgBossClient } from "#client.ts";
|
|
4
|
+
export declare const deferredAttempt: unique symbol;
|
|
5
|
+
export declare const deferralObservers: WeakMap<PgBossClient, () => void>;
|
|
6
|
+
export declare const STATELY_DEFERRAL_POLICY = "effect-stately-deferred";
|
|
7
|
+
export declare const Deferral: Schema.Struct<{
|
|
8
|
+
readonly at: Schema.String;
|
|
9
|
+
readonly reason: Schema.String;
|
|
10
|
+
}>;
|
|
11
|
+
export declare function deferralOf(job: Job<unknown>): {
|
|
12
|
+
readonly at: string;
|
|
13
|
+
readonly reason: string;
|
|
14
|
+
} | undefined;
|
|
15
|
+
//# sourceMappingURL=deferral.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deferral.d.ts","sourceRoot":"","sources":["../../../src/server/internal/deferral.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,eAAO,MAAM,eAAe,eAA4B,CAAC;AACzD,eAAO,MAAM,iBAAiB,8BAAmC,IAAI,CAAG,CAAC;AACzE,eAAO,MAAM,uBAAuB,4BAA4B,CAAC;AAEjE,eAAO,MAAM,QAAQ;;;EAGnB,CAAC;AAIH,wBAAgB,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC;;;cAG3C"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
export const deferredAttempt = Symbol("deferredAttempt");
|
|
3
|
+
export const deferralObservers = new WeakMap();
|
|
4
|
+
export const STATELY_DEFERRAL_POLICY = "effect-stately-deferred";
|
|
5
|
+
export const Deferral = Schema.Struct({
|
|
6
|
+
at: Schema.String,
|
|
7
|
+
reason: Schema.String,
|
|
8
|
+
});
|
|
9
|
+
const Output = Schema.Struct({ jobDeferral: Deferral });
|
|
10
|
+
export function deferralOf(job) {
|
|
11
|
+
const output = Reflect.get(job, "output");
|
|
12
|
+
return Schema.is(Output)(output) ? output.jobDeferral : undefined;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=deferral.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deferral.js","sourceRoot":"","sources":["../../../src/server/internal/deferral.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAIhC,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC;AACzD,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,OAAO,EAA4B,CAAC;AACzE,MAAM,CAAC,MAAM,uBAAuB,GAAG,yBAAyB,CAAC;AAEjE,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC;IACrC,EAAE,EAAE,MAAM,CAAC,MAAM;IACjB,MAAM,EAAE,MAAM,CAAC,MAAM;CACrB,CAAC,CAAC;AAEH,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,CAAC;AAExD,MAAM,UAAU,UAAU,CAAC,GAAiB;IAC3C,MAAM,MAAM,GAAY,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IACnD,OAAO,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deferralStorePlan.d.ts","sourceRoot":"","sources":["../../../src/server/internal/deferralStorePlan.ts"],"names":[],"mappings":"AAEA,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CA+BxD"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { STATELY_DEFERRAL_POLICY } from "./deferral.js";
|
|
2
|
+
export function deferralStorePlan(schema) {
|
|
3
|
+
const quoted = `"${schema.replaceAll('"', '""')}"`;
|
|
4
|
+
const jobTable = `${quoted}.job`.replaceAll("'", "''");
|
|
5
|
+
const key = `${schema}.effect_job_deferral`.replaceAll("'", "''");
|
|
6
|
+
const body = `BEGIN
|
|
7
|
+
PERFORM pg_advisory_xact_lock(hashtextextended('${key}', 0));
|
|
8
|
+
CREATE TABLE IF NOT EXISTS ${quoted}.effect_job_deferral (
|
|
9
|
+
name text NOT NULL,
|
|
10
|
+
id uuid NOT NULL,
|
|
11
|
+
created_on timestamptz NOT NULL,
|
|
12
|
+
count bigint NOT NULL,
|
|
13
|
+
keep_until timestamptz NOT NULL,
|
|
14
|
+
PRIMARY KEY (name, id)
|
|
15
|
+
);
|
|
16
|
+
CREATE INDEX IF NOT EXISTS effect_job_deferral_keep_until ON ${quoted}.effect_job_deferral (keep_until);
|
|
17
|
+
CREATE OR REPLACE FUNCTION ${quoted}.effect_stately_deferral() RETURNS trigger LANGUAGE plpgsql AS $claim$
|
|
18
|
+
BEGIN
|
|
19
|
+
IF NEW.policy = '${STATELY_DEFERRAL_POLICY}' AND NEW.state = 'active' THEN
|
|
20
|
+
NEW.policy := 'stately';
|
|
21
|
+
END IF;
|
|
22
|
+
RETURN NEW;
|
|
23
|
+
END
|
|
24
|
+
$claim$;
|
|
25
|
+
IF NOT EXISTS (
|
|
26
|
+
SELECT 1 FROM pg_trigger WHERE tgrelid = '${jobTable}'::regclass AND tgname = 'effect_stately_deferral'
|
|
27
|
+
) THEN
|
|
28
|
+
CREATE TRIGGER effect_stately_deferral BEFORE UPDATE OF state, policy ON ${quoted}.job
|
|
29
|
+
FOR EACH ROW EXECUTE FUNCTION ${quoted}.effect_stately_deferral();
|
|
30
|
+
END IF;
|
|
31
|
+
END`;
|
|
32
|
+
return `DO '${body.replaceAll("'", "''")}'`;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=deferralStorePlan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deferralStorePlan.js","sourceRoot":"","sources":["../../../src/server/internal/deferralStorePlan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAExD,MAAM,UAAU,iBAAiB,CAAC,MAAc;IAC/C,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC;IACnD,MAAM,QAAQ,GAAG,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACvD,MAAM,GAAG,GAAG,GAAG,MAAM,sBAAsB,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAClE,MAAM,IAAI,GAAG;oDACsC,GAAG;+BACxB,MAAM;;;;;;;;iEAQ4B,MAAM;+BACxC,MAAM;;sBAEf,uBAAuB;;;;;;;+CAOE,QAAQ;;8EAEuB,MAAM;mCACjD,MAAM;;KAEpC,CAAC;IACL,OAAO,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC;AAC7C,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Job, PgBoss } from "pg-boss";
|
|
2
|
-
export declare function expireAttempt(client: PgBoss, schema: string, job: Job<unknown
|
|
2
|
+
export declare function expireAttempt(client: PgBoss, schema: string, job: Job<unknown>, cause?: "expiry" | "heartbeat"): Promise<void>;
|
|
3
3
|
//# sourceMappingURL=expireAttempt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expireAttempt.d.ts","sourceRoot":"","sources":["../../../src/server/internal/expireAttempt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAE3C,wBAAsB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"expireAttempt.d.ts","sourceRoot":"","sources":["../../../src/server/internal/expireAttempt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAE3C,wBAAsB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,OAAO,CAAC,EAAE,KAAK,GAAE,QAAQ,GAAG,WAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAiB9I"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
export async function expireAttempt(client, schema, job) {
|
|
1
|
+
export async function expireAttempt(client, schema, job, cause = "expiry") {
|
|
2
2
|
if ((await client.schemaVersion()) !== 45) {
|
|
3
3
|
throw new Error("Testing expiry requires pg-boss schema version 45");
|
|
4
4
|
}
|
|
5
5
|
const quoted = `"${schema.replaceAll('"', '""')}"`;
|
|
6
|
-
|
|
6
|
+
const timestamp = cause === "expiry" ? "started_on" : "heartbeat_on";
|
|
7
|
+
const seconds = cause === "expiry" ? "expire_seconds" : "heartbeat_seconds";
|
|
8
|
+
await client.getDb().executeSql(`UPDATE ${quoted}.job SET ${timestamp} = ${quoted}.job_now() - (${seconds} + 1) * interval '1 second'
|
|
7
9
|
WHERE name = $1 AND id = $2 AND retry_count = $3 AND state = 'active'`, [job.name, job.id, job.retryCount]);
|
|
8
10
|
// Supervision owns expiry and dead lettering; make its claim due with the job's deadline.
|
|
9
11
|
await client
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expireAttempt.js","sourceRoot":"","sources":["../../../src/server/internal/expireAttempt.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,MAAc,EAAE,MAAc,EAAE,GAAiB;
|
|
1
|
+
{"version":3,"file":"expireAttempt.js","sourceRoot":"","sources":["../../../src/server/internal/expireAttempt.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,MAAc,EAAE,MAAc,EAAE,GAAiB,EAAE,KAAK,GAA2B,QAAQ;IAC9H,IAAI,CAAC,MAAM,MAAM,CAAC,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC;QAC3C,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACtE,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC;IACnD,MAAM,SAAS,GAAG,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,cAAc,CAAC;IACrE,MAAM,OAAO,GAAG,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,mBAAmB,CAAC;IAC5E,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC,UAAU,CAC9B,UAAU,MAAM,YAAY,SAAS,MAAM,MAAM,iBAAiB,OAAO;wEACH,EACtE,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,UAAU,CAAC,CAClC,CAAC;IACF,0FAA0F;IAC1F,MAAM,MAAM;SACV,KAAK,EAAE;SACP,UAAU,CAAC,UAAU,MAAM,iCAAiC,MAAM,gDAAgD,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;IAClI,MAAM,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../../src/server/internal/lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAwB,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../../src/server/internal/lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAwB,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAM/F,MAAM,WAAW,oBAAoB;IACpC,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACtD,QAAQ,CAAC,aAAa,CAAC,EAAE,mBAAmB,GAAG,SAAS,CAAC;IACzD,QAAQ,CAAC,WAAW,EAAE,kBAAkB,CAAC;CACzC;AAED,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CACzB;AAqBD,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,OAAO,WAAW,EAAE,WAAW,CAAC,CAgB3H;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,cAAc,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAUtG"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import { defaultClientFactory } from "#client.ts";
|
|
3
3
|
import { toPgBossError } from "#error.ts";
|
|
4
|
+
import { deferralStorePlan } from "#internal/deferralStorePlan.ts";
|
|
4
5
|
import { acquireCachedClient, releaseCachedClient } from "./clientCache.js";
|
|
5
6
|
import { logClientError, observeClientErrors } from "./clientErrors.js";
|
|
6
7
|
async function startClient(options, report) {
|
|
@@ -8,6 +9,9 @@ async function startClient(options, report) {
|
|
|
8
9
|
observeClientErrors(client, report);
|
|
9
10
|
try {
|
|
10
11
|
await client.start();
|
|
12
|
+
if (options.constructor.migrate !== false && client.getDb !== undefined) {
|
|
13
|
+
await client.getDb().executeSql(deferralStorePlan(options.constructor.schema ?? "pgboss"));
|
|
14
|
+
}
|
|
11
15
|
return client;
|
|
12
16
|
}
|
|
13
17
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../../../src/server/internal/lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,oBAAoB,EAA+C,MAAM,YAAY,CAAC;AAC/F,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAcxE,KAAK,UAAU,WAAW,CAAC,OAA6B,EAAE,MAA8B;IACvF,MAAM,MAAM,GAAG,CAAC,OAAO,CAAC,aAAa,IAAI,oBAAoB,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IACpF,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,IAAI,CAAC;QACJ,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACrB,OAAO,MAAM,CAAC;IACf,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,IAAI,CAAC;YACJ,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;QACrB,CAAC;QAAC,MAAM,CAAC;YACR,2EAA2E;QAC5E,CAAC;QACD,MAAM,KAAK,CAAC;IACb,CAAC;AACF,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,OAA6B;IAC1D,OAAO,MAAM,CAAC,WAAW,CAAC,CAAC,OAAO,EAAE,EAAE;QACrC,MAAM,GAAG,GAAG,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QACxC,SAAS,MAAM,CAAC,KAAY;YAC3B,GAAG,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC;QAC5B,CAAC;QACD,OAAO,MAAM,CAAC,UAAU,CAAC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C,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -4,5 +4,5 @@ import { type JobRegistration } from "#definition.ts";
|
|
|
4
4
|
import { PgBossError, PgBossQueueOptionsError } from "#error.ts";
|
|
5
5
|
export declare function registrationName(registration: JobRegistration): string;
|
|
6
6
|
export declare const registrationNames: (registrations: readonly JobRegistration[]) => readonly string[];
|
|
7
|
-
export declare const registerJobs: <R>(client: PgBossClient, registrations: readonly JobRegistration[], context: Context.Context<R>, replaceWorkers: boolean) => Effect.Effect<void, PgBossError | PgBossQueueOptionsError, Scope.Scope>;
|
|
7
|
+
export declare const registerJobs: <R>(client: PgBossClient, registrations: readonly JobRegistration[], context: Context.Context<R>, replaceWorkers: boolean, schema?: string) => Effect.Effect<void, PgBossError | PgBossQueueOptionsError, Scope.Scope>;
|
|
8
8
|
//# 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,EAAoB,KAAK,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EACN,KAAK,eAAe,EAMpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,WAAW,EAAsB,uBAAuB,EAAiB,MAAM,WAAW,CAAC;AA8BpG,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,eAAe,GAAG,MAAM,CAEtE;
|
|
1
|
+
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../src/server/internal/register.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,EAAoB,KAAK,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EACN,KAAK,eAAe,EAMpB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,WAAW,EAAsB,uBAAuB,EAAiB,MAAM,WAAW,CAAC;AA8BpG,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,eAAe,GAAG,MAAM,CAEtE;AAiED,eAAO,MAAM,iBAAiB,kBAAmB,SAAS,eAAe,EAAE,KAAG,SAAS,MAAM,EAM5F,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,CAAC,UACrB,YAAY,iBACL,SAAS,eAAe,EAAE,WAChC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,kBACX,OAAO,sBAErB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,WAAW,GAAG,uBAAuB,EAAE,KAAK,CAAC,KAAK,CAiBvE,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { jobContext, } from "#definition.ts";
|
|
|
3
3
|
import { PgBossError, PgBossPayloadError, PgBossQueueOptionsError, toPgBossError } from "#error.ts";
|
|
4
4
|
import { ensureQueue } from "#internal/ensureQueue.ts";
|
|
5
5
|
import { registerWorker } from "#internal/registerWorker.ts";
|
|
6
|
-
import { payloadOf
|
|
6
|
+
import { payloadOf } from "#internal/tracing.ts";
|
|
7
7
|
function isQueueWorker(registration) {
|
|
8
8
|
return registration._tag === "QueueWorker";
|
|
9
9
|
}
|
|
@@ -47,24 +47,24 @@ async function prepareQueues(client, registrations, replaceWorkers) {
|
|
|
47
47
|
function workerContext(context) {
|
|
48
48
|
return context;
|
|
49
49
|
}
|
|
50
|
-
function runQueueWorker(worker, job
|
|
50
|
+
function runQueueWorker(worker, job) {
|
|
51
51
|
return Schema.decodeUnknownEffect(worker.queue.schema)(payloadOf(job.data)).pipe(Effect.mapError((error) => new PgBossPayloadError({
|
|
52
52
|
direction: "decode",
|
|
53
53
|
original: Redacted.make(error),
|
|
54
54
|
queue: worker.queue.name,
|
|
55
|
-
})), Effect.flatMap((payload) => worker.handler(payload, jobContext(job)))
|
|
55
|
+
})), Effect.flatMap((payload) => worker.handler(payload, jobContext(job))));
|
|
56
56
|
}
|
|
57
|
-
async function registerQueue(client, registration, context, scope) {
|
|
57
|
+
async function registerQueue(client, registration, context, scope, schema) {
|
|
58
58
|
const queue = registration._tag === "QueueWorker" ? registration.queue : registration;
|
|
59
59
|
const name = queue.name;
|
|
60
60
|
if (registration._tag === "QueueDefinition") {
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
63
|
-
await registerWorker(client, name, queue.workerOptions, (job) => runQueueWorker(registration, job,
|
|
63
|
+
await registerWorker(client, name, queue.workerOptions, (job) => runQueueWorker(registration, job), scope, schema, queue.maxDeferrals, context);
|
|
64
64
|
}
|
|
65
|
-
async function registerSchedule(client, worker, context, scope) {
|
|
65
|
+
async function registerSchedule(client, worker, context, scope, schema) {
|
|
66
66
|
const { schedule } = worker;
|
|
67
|
-
await registerWorker(client, schedule.name, schedule.workerOptions, (
|
|
67
|
+
await registerWorker(client, schedule.name, schedule.workerOptions, () => worker.effect, scope, schema, schedule.maxDeferrals, context);
|
|
68
68
|
await client.schedule(schedule.name, schedule.cron, null, schedule.scheduleOptions);
|
|
69
69
|
}
|
|
70
70
|
export const registrationNames = (registrations) => {
|
|
@@ -74,7 +74,7 @@ export const registrationNames = (registrations) => {
|
|
|
74
74
|
}
|
|
75
75
|
return names;
|
|
76
76
|
};
|
|
77
|
-
export const registerJobs = (client, registrations, context, replaceWorkers) => Effect.flatMap(Effect.scope, (scope) => Effect.tryPromise({
|
|
77
|
+
export const registerJobs = (client, registrations, context, replaceWorkers, schema = "pgboss") => Effect.flatMap(Effect.scope, (scope) => Effect.tryPromise({
|
|
78
78
|
catch: (error) => (error instanceof PgBossQueueOptionsError || error instanceof PgBossError ? error : toPgBossError("register", error)),
|
|
79
79
|
try: async () => {
|
|
80
80
|
registrationNames(registrations);
|
|
@@ -82,10 +82,10 @@ export const registerJobs = (client, registrations, context, replaceWorkers) =>
|
|
|
82
82
|
const provided = workerContext(context);
|
|
83
83
|
for (const registration of registrations) {
|
|
84
84
|
if (isQueueWorker(registration) || isQueueDefinition(registration)) {
|
|
85
|
-
await registerQueue(client, registration, provided, scope);
|
|
85
|
+
await registerQueue(client, registration, provided, scope, schema);
|
|
86
86
|
}
|
|
87
87
|
else if (isScheduledWorker(registration)) {
|
|
88
|
-
await registerSchedule(client, registration, provided, scope);
|
|
88
|
+
await registerSchedule(client, registration, provided, scope, schema);
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
},
|
|
@@ -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,EAAc,MAAM,QAAQ,CAAC;AAG5E,OAAO,EAEN,UAAU,GAKV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AACpG,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"register.js","sourceRoot":"","sources":["../../../src/server/internal/register.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAc,MAAM,QAAQ,CAAC;AAG5E,OAAO,EAEN,UAAU,GAKV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AACpG,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7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OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CACtC,MAAM,CAAC,UAAU,CAAC;IACjB,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,YAAY,uBAAuB,IAAI,KAAK,YAAY,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IACvI,GAAG,EAAE,KAAK,IAAI,EAAE;QACf,iBAAiB,CAAC,aAAa,CAAC,CAAC;QACjC,MAAM,aAAa,CAAC,MAAM,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC;QAC3D,MAAM,QAAQ,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;QACxC,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE,CAAC;YAC1C,IAAI,aAAa,CAAC,YAAY,CAAC,IAAI,iBAAiB,CAAC,YAAY,CAAC,EAAE,CAAC;gBACpE,MAAM,aAAa,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;YACpE,CAAC;iBAAM,IAAI,iBAAiB,CAAC,YAAY,CAAC,EAAE,CAAC;gBAC5C,MAAM,gBAAgB,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;YACvE,CAAC;QACF,CAAC;IACF,CAAC;CACD,CAAC,CACF,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Effect, type Scope } from "effect";
|
|
1
|
+
import { type Context, Effect, type Scope } from "effect";
|
|
2
2
|
import type { Job, WorkOptions } from "pg-boss";
|
|
3
3
|
import type { PgBossClient } from "#client.ts";
|
|
4
|
-
export declare function registerWorker(client: PgBossClient, name: string, options: WorkOptions, run: (job: Job<unknown>) => Effect.Effect<unknown, unknown>, scope: Scope.Scope): Promise<string>;
|
|
4
|
+
export declare function registerWorker(client: PgBossClient, name: string, options: WorkOptions, run: (job: Job<unknown>) => Effect.Effect<unknown, unknown, unknown>, scope: Scope.Scope, schema: string, maxDeferrals: number, context: Context.Context<unknown>): Promise<string>;
|
|
5
5
|
//# sourceMappingURL=registerWorker.d.ts.map
|