@shivaedev/effect-pg-boss 0.2.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/README.md +198 -82
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js.map +1 -0
- package/dist/definition.d.ts.map +1 -1
- package/dist/error.d.ts.map +1 -1
- package/dist/health.d.ts.map +1 -1
- package/dist/internal/health.d.ts +1 -1
- package/dist/internal/health.d.ts.map +1 -1
- package/dist/internal/health.js.map +1 -1
- package/dist/internal/lifecycle.d.ts +1 -1
- package/dist/internal/lifecycle.d.ts.map +1 -1
- package/dist/internal/lifecycle.js +11 -9
- package/dist/internal/lifecycle.js.map +1 -1
- package/dist/internal/register.d.ts +1 -1
- package/dist/internal/register.d.ts.map +1 -1
- package/dist/internal/register.js +24 -16
- package/dist/internal/register.js.map +1 -1
- package/dist/internal/service.d.ts +1 -1
- package/dist/internal/service.d.ts.map +1 -1
- package/dist/internal/service.js.map +1 -1
- package/dist/service.d.ts +8 -12
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +3 -1
- package/dist/service.js.map +1 -1
- package/docs/north-star.md +48 -0
- package/docs/roadmap.md +26 -0
- package/package.json +18 -13
- package/src/internal/health.ts +1 -1
- package/src/internal/lifecycle.ts +13 -10
- package/src/internal/register.ts +22 -15
- package/src/internal/service.ts +1 -1
- package/src/service.ts +21 -23
- package/dist/index.d.ts +0 -6
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -5
- package/dist/index.js.map +0 -1
- package/dist/internal/client.d.ts.map +0 -1
- package/dist/internal/client.js.map +0 -1
- package/src/index.ts +0 -33
- /package/dist/{internal/client.d.ts → client.d.ts} +0 -0
- /package/dist/{internal/client.js → client.js} +0 -0
- /package/src/{internal/client.ts → client.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.0 - 2026-10-12
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- Explain the jobs boundary in a package north star, agent guidance, usage guide and roadmap, and publish the guide and `docs/` with the package.
|
|
8
|
+
- Build package JavaScript, declarations and source maps with TypeScript 7.
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- Preserve the literal identifier of each `makePgBoss(identifier)` in its service and Layer types, so a Layer for another jobs definition leaves the required service unprovided at compile time. This is breaking only for code that names the shared `PgBossIdentifier` type; use the definition's literal identifier instead.
|
|
13
|
+
|
|
14
|
+
## 0.3.0 - 2026-10-04
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- Breaking: no root entry and no module that re-exports another. `exports` maps one `"./*.ts"` pattern to every module outside `internal/` (`src` under the `source` condition, `dist` otherwise), and `"./internal/*": null` keeps `internal/` modules private, so you import the module that defines a name, and a bundler sees only the modules you use. Where each name now lives:
|
|
19
|
+
- `@shivaedev/effect-pg-boss`: `@shivaedev/effect-pg-boss/client.ts` (`PgBossClient`, `PgBossClientFactory`), `@shivaedev/effect-pg-boss/definition.ts` (`DefineQueueOptions`, `DefineScheduleOptions`, `defineQueue`, `defineSchedule`, `JobContext`, `JobPayloadSchema`, `JobRegistration`, `QueueDefinition`, `QueueWorker`, `ScheduleDefinition`, `ScheduledWorker`), `@shivaedev/effect-pg-boss/error.ts` (`PgBossError`, `PgBossOperation`, `PgBossPayloadError`), `@shivaedev/effect-pg-boss/health.ts` (`deadLetterQueueName`, `JobsHealth`, `QueueHealth`), `@shivaedev/effect-pg-boss/service.ts` (`makePgBoss`, `PgBossDefinition`, `PgBossLayerOptions`, `PgBossService`)
|
|
20
|
+
- `PgBossClient` and `PgBossClientFactory` live in `client.ts`, moved out of `internal/` because they are public.
|
|
21
|
+
|
|
3
22
|
## 0.2.1 - 2026-10-04
|
|
4
23
|
|
|
5
24
|
### Changed
|
package/README.md
CHANGED
|
@@ -1,119 +1,235 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @shivaedev/effect-pg-boss
|
|
2
2
|
|
|
3
|
-
Effect
|
|
4
|
-
pg-boss.
|
|
3
|
+
Run PostgreSQL jobs through the same Effect services as the rest of your application. A queue has one payload Schema for enqueueing and handling, and an Effect Layer owns the pg-boss client, workers and schedules.
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
pg-boss. It is built for ShivaeDev applications and may change without a
|
|
8
|
-
deprecation period.
|
|
5
|
+
## Why you want this
|
|
9
6
|
|
|
10
|
-
|
|
7
|
+
A background worker lives outside the request that queued it. Without a shared boundary, the producer writes one payload shape, the worker assumes another, and every worker rebuilds its dependencies and shutdown plumbing. This package puts those decisions in one place:
|
|
11
8
|
|
|
12
|
-
```
|
|
13
|
-
|
|
9
|
+
```ts
|
|
10
|
+
import { defineQueue } from "@shivaedev/effect-pg-boss/definition.ts";
|
|
11
|
+
import { Effect, Schema } from "effect";
|
|
12
|
+
import { Mail } from "./services.ts";
|
|
13
|
+
|
|
14
|
+
const SendEmail = defineQueue({
|
|
15
|
+
name: "send-email",
|
|
16
|
+
schema: Schema.Struct({ userId: Schema.NumberFromString }),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const emailWorker = SendEmail.handle(({ userId }) =>
|
|
20
|
+
Effect.flatMap(Mail, (mail) => mail.send(userId)),
|
|
21
|
+
);
|
|
14
22
|
```
|
|
15
23
|
|
|
16
|
-
|
|
24
|
+
`Mail` is the application's Effect service, defined in the guide below. The worker receives a number even though the durable payload stores a string. The same Schema encodes the producer's payload and decodes the worker's input; malformed stored data fails before the handler runs. Provide the worker's services when the jobs Layer starts, and the handler uses that captured context when pg-boss calls it later.
|
|
25
|
+
|
|
26
|
+
## Using it
|
|
27
|
+
|
|
28
|
+
### How to think about it
|
|
29
|
+
|
|
30
|
+
A **queue definition** names a pg-boss queue and the Schema of its payload. Application code uses the Schema's decoded type; pg-boss receives its encoded type. Both must be objects. Defining a queue describes the contract; `queue.handle(handler)` pairs it with the Effect that performs the work.
|
|
31
|
+
|
|
32
|
+
A **schedule definition** describes a queue with a cron trigger. `schedule.run(effect)` pairs it with an Effect that needs no payload. Queue workers and scheduled workers are **registrations**: the values you put in the jobs Layer's `jobs` list.
|
|
33
|
+
|
|
34
|
+
The application creates one jobs service with `makePgBoss(identifier)`. Its Layer starts a client, registers the job list and captures the services those workers need. The Layer's scope owns its client reference and releases it when the scope ends; the final reference closes the client. Callers use the jobs service to enqueue a decoded payload or read queue health.
|
|
17
35
|
|
|
18
|
-
|
|
19
|
-
|
|
36
|
+
Use a distinct literal identifier for each jobs service. The service and its Layer keep that identifier in their types, so providing a Layer for a different identifier leaves the required jobs service unprovided at compile time.
|
|
37
|
+
|
|
38
|
+
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.
|
|
39
|
+
|
|
40
|
+
### Once per application: the jobs service
|
|
41
|
+
|
|
42
|
+
Define the application's jobs service and worker dependencies in `services.ts`:
|
|
20
43
|
|
|
21
44
|
```ts
|
|
22
|
-
import {
|
|
23
|
-
import { Effect,
|
|
24
|
-
|
|
25
|
-
export const EmailQueue = defineQueue({
|
|
26
|
-
name: "email",
|
|
27
|
-
schema: Schema.Struct({
|
|
28
|
-
userId: Schema.String,
|
|
29
|
-
attempt: Schema.NumberFromString,
|
|
30
|
-
}),
|
|
31
|
-
queue: {
|
|
32
|
-
retryLimit: 5,
|
|
33
|
-
retryBackoff: true,
|
|
34
|
-
},
|
|
35
|
-
})
|
|
45
|
+
import { makePgBoss } from "@shivaedev/effect-pg-boss/service.ts";
|
|
46
|
+
import { Context, Effect, Layer } from "effect";
|
|
36
47
|
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
)
|
|
48
|
+
export const Jobs = makePgBoss("@app/Jobs");
|
|
49
|
+
|
|
50
|
+
export class Mail extends Context.Service<Mail, {
|
|
51
|
+
readonly send: (userId: number) => Effect.Effect<void>;
|
|
52
|
+
readonly removeExpired: Effect.Effect<void>;
|
|
53
|
+
}>()("@app/Mail") {}
|
|
54
|
+
|
|
55
|
+
export const MailLive = Layer.succeed(Mail, {
|
|
56
|
+
send: (userId) => Effect.log({ event: "send_email", userId }),
|
|
57
|
+
removeExpired: Effect.log({ event: "remove_expired_mail" }),
|
|
58
|
+
});
|
|
43
59
|
```
|
|
44
60
|
|
|
45
|
-
|
|
46
|
-
|
|
61
|
+
`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.
|
|
62
|
+
|
|
63
|
+
### Once per feature: the payload and handler
|
|
47
64
|
|
|
48
|
-
|
|
65
|
+
Define the feature's registrations in `jobs.ts`:
|
|
49
66
|
|
|
50
67
|
```ts
|
|
51
|
-
import { defineSchedule } from "@shivaedev/effect-pg-boss"
|
|
68
|
+
import { defineQueue, defineSchedule } from "@shivaedev/effect-pg-boss/definition.ts";
|
|
69
|
+
import { Effect, Schema } from "effect";
|
|
70
|
+
import { Mail } from "./services.ts";
|
|
52
71
|
|
|
53
|
-
const
|
|
54
|
-
name: "
|
|
55
|
-
|
|
56
|
-
}
|
|
72
|
+
export const SendEmail = defineQueue({
|
|
73
|
+
name: "send-email",
|
|
74
|
+
schema: Schema.Struct({ userId: Schema.NumberFromString }),
|
|
75
|
+
queue: { retryLimit: 5 },
|
|
76
|
+
});
|
|
57
77
|
|
|
58
|
-
const
|
|
78
|
+
export const emailWorker = SendEmail.handle(({ userId }, job) =>
|
|
59
79
|
Effect.gen(function* () {
|
|
60
|
-
const
|
|
61
|
-
yield*
|
|
80
|
+
const mail = yield* Mail;
|
|
81
|
+
yield* mail.send(userId);
|
|
82
|
+
yield* Effect.log({ jobId: job.id });
|
|
62
83
|
}),
|
|
63
|
-
)
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
export const Cleanup = defineSchedule({
|
|
87
|
+
name: "cleanup-mail",
|
|
88
|
+
cron: "17 3 * * *",
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
export const cleanupWorker = Cleanup.run(
|
|
92
|
+
Effect.flatMap(Mail, (mail) => mail.removeExpired),
|
|
93
|
+
);
|
|
64
94
|
```
|
|
65
95
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
96
|
+
The queue takes `{ userId: number }` in application code and stores `{ userId: string }`. Its handler receives the decoded number and a job context, including the job's `id`. Keep the queue definition available to producers; the runtime registers the worker created by `handle`.
|
|
97
|
+
|
|
98
|
+
The schedule runs a payload-free Effect. This schedule registers its cron expression with `tz: "UTC"`. The package creates a `<name>-dlq` dead-letter queue for both kinds of worker and supplies `retryLimit: 3` and `retryBackoff: true` by default. The email queue above overrides the retry limit to five. These are pg-boss registration settings; pg-boss runs the retry and scheduling engine.
|
|
69
99
|
|
|
70
|
-
|
|
100
|
+
The Layer requires the workers' Effect services. Leaving `Mail` unprovided leaves that requirement in the resulting Effect's type. A primitive Schema such as `Schema.String` is rejected as a queue definition because the durable contract must be an object.
|
|
71
101
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
102
|
+
### Once per runtime: provide the workers
|
|
103
|
+
|
|
104
|
+
Build the jobs Layer in `runtime.ts`:
|
|
75
105
|
|
|
76
106
|
```ts
|
|
77
|
-
import {
|
|
107
|
+
import { Layer } from "effect";
|
|
108
|
+
import { cleanupWorker, emailWorker } from "./jobs.ts";
|
|
109
|
+
import { Jobs, MailLive } from "./services.ts";
|
|
110
|
+
|
|
111
|
+
export const jobsLayer = (databaseUrl: string) =>
|
|
112
|
+
Jobs.layer({
|
|
113
|
+
connectionString: databaseUrl,
|
|
114
|
+
schema: "app_jobs",
|
|
115
|
+
jobs: [emailWorker, cleanupWorker],
|
|
116
|
+
}).pipe(Layer.provide(MailLive));
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
The constructor options belong to pg-boss. `jobs` is the complete list of registrations for this Layer. The Layer captures `MailLive` for both the queue handler and the scheduled Effect. A startup or registration failure fails Layer acquisition with `PgBossError` and releases its acquired client reference. A shared client stays running while another scope still owns a reference.
|
|
78
120
|
|
|
79
|
-
|
|
121
|
+
Keep the Layer in the application's worker runtime scope. A short scope is useful for an acquisition or health check; a worker process needs its scope to remain open while it handles jobs.
|
|
80
122
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
123
|
+
```ts
|
|
124
|
+
import { Effect } from "effect";
|
|
125
|
+
import { jobsLayer } from "./runtime.ts";
|
|
126
|
+
import { Jobs } from "./services.ts";
|
|
127
|
+
|
|
128
|
+
const inspectJobs = (databaseUrl: string) =>
|
|
129
|
+
Effect.scoped(
|
|
130
|
+
Effect.gen(function* () {
|
|
131
|
+
const jobs = yield* Jobs;
|
|
132
|
+
return yield* jobs.health;
|
|
133
|
+
}).pipe(Effect.provide(jobsLayer(databaseUrl))),
|
|
134
|
+
);
|
|
87
135
|
```
|
|
88
136
|
|
|
89
|
-
|
|
90
|
-
builds that share the key, such as development module reloads. The package does
|
|
91
|
-
not inspect `NODE_ENV`; without a key every build starts its own client.
|
|
92
|
-
Applications decide which key and registrations are passed to the Layer, so
|
|
93
|
-
environment rules such as development caching and production-only schedules
|
|
94
|
-
remain application policy.
|
|
137
|
+
This Effect starts the jobs Layer, reads health and closes the scope. The client stops when that scope closes.
|
|
95
138
|
|
|
96
|
-
|
|
97
|
-
logging or telemetry. Without one, errors use Effect logging.
|
|
139
|
+
### In application code: enqueue
|
|
98
140
|
|
|
99
|
-
|
|
141
|
+
```ts
|
|
142
|
+
import { Effect } from "effect";
|
|
143
|
+
import { SendEmail } from "./jobs.ts";
|
|
144
|
+
import { Jobs } from "./services.ts";
|
|
145
|
+
|
|
146
|
+
export const enqueueEmail = (userId: number) =>
|
|
147
|
+
Effect.gen(function* () {
|
|
148
|
+
const jobs = yield* Jobs;
|
|
149
|
+
return yield* jobs.enqueue(SendEmail, { userId });
|
|
150
|
+
});
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Provide `Jobs` through the application's existing runtime. `enqueue` takes the decoded payload, so passing a string `userId` is a type error. It encodes the number to a string before calling pg-boss. The result type is `Option.Option<string>`: a job identifier becomes `Some`, and a `null` send result becomes `None`.
|
|
154
|
+
|
|
155
|
+
`PgBossPayloadError` names a payload boundary failure; malformed durable input is rejected before the worker's domain code runs. The PostgreSQL test also checks that invalid data sent directly to pg-boss reaches the dead-letter queue without reaching the handler.
|
|
156
|
+
|
|
157
|
+
### Read health
|
|
100
158
|
|
|
101
159
|
```ts
|
|
102
|
-
|
|
103
|
-
|
|
160
|
+
import { Effect } from "effect";
|
|
161
|
+
import { Jobs } from "./services.ts";
|
|
162
|
+
|
|
163
|
+
export const readJobCounts = Effect.gen(function* () {
|
|
164
|
+
const jobs = yield* Jobs;
|
|
165
|
+
const health = yield* jobs.health;
|
|
166
|
+
return {
|
|
167
|
+
active: health.activeTotal,
|
|
168
|
+
deadLettered: health.deadLetteredTotal,
|
|
169
|
+
failed: health.failedTotal,
|
|
170
|
+
queued: health.queuedTotal,
|
|
171
|
+
ready: health.readyTotal,
|
|
172
|
+
};
|
|
173
|
+
});
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
`health` exposes pg-boss queue counts as data. Its total fields include the registered queue's active, failed, queued and ready counts, plus the dead-letter queue's queued count. Decide in the application which values affect an HTTP health response or an alert.
|
|
177
|
+
|
|
178
|
+
### Share a client between Layer builds
|
|
179
|
+
|
|
180
|
+
```ts
|
|
181
|
+
import { Layer } from "effect";
|
|
182
|
+
import { cleanupWorker, emailWorker } from "./jobs.ts";
|
|
183
|
+
import { Jobs, MailLive } from "./services.ts";
|
|
184
|
+
|
|
185
|
+
const sharedJobsLayer = (databaseUrl: string) =>
|
|
186
|
+
Jobs.layer({
|
|
187
|
+
connectionString: databaseUrl,
|
|
188
|
+
schema: "app_jobs",
|
|
189
|
+
clientCacheKey: "app-jobs",
|
|
190
|
+
jobs: [emailWorker, cleanupWorker],
|
|
191
|
+
}).pipe(Layer.provide(MailLive));
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Overlapping Layer builds with the same `clientCacheKey` share one started client. The later build replaces the registered worker, and the final scope release stops the shared client. A later build after that release starts a new client. Without a key, each build creates its own client. The application chooses whether to pass a key.
|
|
195
|
+
|
|
196
|
+
### API
|
|
104
197
|
|
|
105
|
-
|
|
106
|
-
userId: "user-1",
|
|
107
|
-
attempt: 1,
|
|
108
|
-
})
|
|
198
|
+
Import the module that defines the name; the package has no root entry.
|
|
109
199
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
200
|
+
| Module | Public names |
|
|
201
|
+
| --- | --- |
|
|
202
|
+
| `@shivaedev/effect-pg-boss/definition.ts` | `defineQueue`, `defineSchedule`, `jobContext`; `DefineQueueOptions`, `DefineScheduleOptions`, `JobContext`, `JobPayloadSchema`, `JobRegistration`, `QueueDefinition`, `QueueWorker`, `RegistrationRequirements`, `ScheduleDefinition`, `ScheduledWorker` |
|
|
203
|
+
| `@shivaedev/effect-pg-boss/service.ts` | `makePgBoss`; `PgBossDefinition`, `PgBossLayerOptions`, `PgBossService` |
|
|
204
|
+
| `@shivaedev/effect-pg-boss/health.ts` | `deadLetterQueueName`; `JobsHealth`, `QueueHealth` |
|
|
205
|
+
| `@shivaedev/effect-pg-boss/error.ts` | `PgBossError`, `PgBossPayloadError`, `toPgBossError`; `PgBossOperation` |
|
|
206
|
+
| `@shivaedev/effect-pg-boss/client.ts` | `defaultClientFactory`; `PgBossClient`, `PgBossClientFactory` |
|
|
207
|
+
|
|
208
|
+
The definition options keep the pg-boss names: `queue` uses `QueueOptions` except `deadLetter`, `worker` uses `WorkOptions`, and a schedule's `schedule` uses `ScheduleOptions`. A queue also requires `name` and `schema`; a schedule requires `name` and `cron`.
|
|
209
|
+
|
|
210
|
+
The application's service has two operations:
|
|
211
|
+
|
|
212
|
+
- `enqueue(queue, payload, options?)`: an Effect returning `Option.Option<string>`, with `PgBossError | PgBossPayloadError` in its error type. Its options use pg-boss `SendOptions`.
|
|
213
|
+
- `health`: an Effect returning `JobsHealth`, with `PgBossError` in its error type.
|
|
214
|
+
|
|
215
|
+
`Jobs.layer(options)` accepts pg-boss `ConstructorOptions` plus `jobs`, optional `clientCacheKey`, optional `clientFactory`, optional `onError` and optional `stop`. The factory type accepts constructor options and returns `PgBossClient`; `onError` has the type `(error: Error) => Effect.Effect<unknown, never, R>`; `stop` uses pg-boss `StopOptions`.
|
|
216
|
+
|
|
217
|
+
`onError` handles pg-boss client `error` events using the services captured by the Layer. The Layer's requirement type includes the workers' services, the payload Schemas' `DecodingServices` and the callback's services. `enqueue` includes the payload Schema's `EncodingServices` in its requirement type.
|
|
218
|
+
|
|
219
|
+
`JobContext` has `id`, `name`, `signal`, `expireInSeconds` and `heartbeatSeconds`. `QueueHealth` has `name`, `activeCount`, `deadLetteredCount`, `failedCount`, `queuedCount` and `readyCount`. `JobsHealth` has `jobs` and the corresponding `activeTotal`, `deadLetteredTotal`, `failedTotal`, `queuedTotal` and `readyTotal` fields.
|
|
220
|
+
|
|
221
|
+
`PgBossError` has `operation`, optional `queue` and a `Redacted` `original`. `PgBossPayloadError` has `direction`, `queue` and a `Redacted` `original`. Those fields distinguish the pg-boss operation from the payload boundary.
|
|
222
|
+
|
|
223
|
+
### Install, setup and limits
|
|
224
|
+
|
|
225
|
+
```sh
|
|
226
|
+
pnpm add @shivaedev/effect-pg-boss effect@4.0.0-rc.112 pg-boss@12.23.1
|
|
113
227
|
```
|
|
114
228
|
|
|
115
|
-
`
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
229
|
+
The package requires Node.js 24 or later and PostgreSQL. `effect` and `pg-boss` are peers; use versions that satisfy the package's published peer ranges.
|
|
230
|
+
|
|
231
|
+
Provide the database connection and job registrations at the application runtime boundary. Application services own the domain work and provider calls; pg-boss owns queue execution. Treat enqueueing and an application database transaction as separate operations, and choose any required transaction or outbox policy in the application.
|
|
232
|
+
|
|
233
|
+
For package development, the real PostgreSQL test uses `PLATFORM_EFFECT_PG_BOSS_TEST_DATABASE_URL` and skips when the variable is absent. A skipped test does not establish durable queue behavior. Fake-client tests cover registration and lifecycle calls; they do not establish real cron execution, retry timing or deployment behavior. The package is built for ShivaeDev applications and may change without a deprecation period.
|
|
234
|
+
|
|
235
|
+
The [north star](./docs/north-star.md) explains the design trade-offs; the [roadmap](./docs/roadmap.md) owns package work and open choices.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGnI,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACrF,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACjE,QAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,KAAK,OAAO,CAAC;IAC5E,QAAQ,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAClD,QAAQ,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,KAAK,OAAO,CAAC;IAC3E,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,OAAO,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAClH,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,OAAO,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACrG,QAAQ,CAAC,KAAK,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IACvC,QAAQ,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,GAAG,CAAC,OAAO,CAAC,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CACrI;AAED,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,EAAE,kBAAkB,KAAK,YAAY,CAAC;AAEhF,eAAO,MAAM,oBAAoB,EAAE,mBAAsD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAiBjC,MAAM,CAAC,MAAM,oBAAoB,GAAwB,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC"}
|
package/dist/definition.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../src/definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,M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Q,CAAC,IAAI,EAAE,SAAS,WAAW,EAAE,CAAC;IACtC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC5B;AAED,eAAO,MAAM,mBAAmB,cAAe,MAAM,KAAG,MAA4B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
+
import type { PgBossClient } from "#client.ts";
|
|
2
3
|
import { type JobsHealth } from "#health.ts";
|
|
3
|
-
import type { PgBossClient } from "./client.ts";
|
|
4
4
|
export declare const healthFor: (client: PgBossClient, names: readonly string[]) => Effect.Effect<JobsHealth, import("#error.ts").PgBossError>;
|
|
5
5
|
//# sourceMappingURL=health.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../src/internal/health.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../src/internal/health.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,EAAuB,KAAK,UAAU,EAAoB,MAAM,YAAY,CAAC;AAEpF,eAAO,MAAM,SAAS,WAAY,YAAY,SAAS,SAAS,MAAM,EAAE,KAAG,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,OAAO,WAAW,EAAE,WAAW,CA4BlI,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"health.js","sourceRoot":"","sources":["../../src/internal/health.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"health.js","sourceRoot":"","sources":["../../src/internal/health.ts"],"names":[],"mappings":"AAA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I,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,CAAC,iBAAiB,EAAE,CAAC,CAAC;IAC5E,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;IAChE,IAAI;IACJ,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;IAChE,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;CAC9D,CAAC,CAAC,CACH,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import type { ConstructorOptions, StopOptions } from "pg-boss";
|
|
3
|
-
import { type PgBossClient, type PgBossClientFactory } from "
|
|
3
|
+
import { type PgBossClient, type PgBossClientFactory } from "#client.ts";
|
|
4
4
|
export interface AcquireClientOptions {
|
|
5
5
|
readonly clientCacheKey?: string | symbol | undefined;
|
|
6
6
|
readonly clientFactory?: PgBossClientFactory | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../src/internal/lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../src/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;AA2B/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;AAiBD,eAAO,MAAM,aAAa,YAAa,oBAAoB,KAAG,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,OAAO,WAAW,EAAE,WAAW,CA6CxH,CAAC;AAEJ,eAAO,MAAM,aAAa,aAAc,cAAc,gBAAgB,WAAW,KAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAoB7C,CAAC"}
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
+
import { defaultClientFactory } from "#client.ts";
|
|
2
3
|
import { toPgBossError } from "#error.ts";
|
|
3
|
-
import { defaultClientFactory } from "./client.js";
|
|
4
4
|
const CacheKey = Symbol.for("@shivaedev/effect-pg-boss/client-cache");
|
|
5
5
|
const sharedCache = Reflect.get(globalThis, CacheKey);
|
|
6
6
|
const clientCache = sharedCache instanceof Map ? sharedCache : new Map();
|
|
7
7
|
Reflect.set(globalThis, CacheKey, clientCache);
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
function isCachedClient(value) {
|
|
9
|
+
return (typeof value === "object"
|
|
10
|
+
&& value !== null
|
|
11
|
+
&& Reflect.get(value, "client") instanceof Promise
|
|
12
|
+
&& typeof Reflect.get(value, "references") === "number");
|
|
13
|
+
}
|
|
14
|
+
function cachedClient(key) {
|
|
13
15
|
const entry = clientCache.get(key);
|
|
14
16
|
return isCachedClient(entry) ? entry : undefined;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
+
}
|
|
18
|
+
function startClient(options) {
|
|
17
19
|
const client = (options.clientFactory ?? defaultClientFactory)(options.constructor);
|
|
18
20
|
return client.start().then(() => client, async (error) => {
|
|
19
21
|
try {
|
|
@@ -24,7 +26,7 @@ const startClient = (options) => {
|
|
|
24
26
|
}
|
|
25
27
|
throw error;
|
|
26
28
|
});
|
|
27
|
-
}
|
|
29
|
+
}
|
|
28
30
|
export const acquireClient = (options) => Effect.tryPromise({
|
|
29
31
|
catch: (error) => toPgBossError("start", error),
|
|
30
32
|
try: async () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../../src/internal/lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"lifecycle.js","sourceRoot":"","sources":["../../src/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;AAO1C,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAC;AACtE,MAAM,WAAW,GAAY,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;AAC/D,MAAM,WAAW,GAAkC,WAAW,YAAY,GAAG,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,GAAG,EAA4B,CAAC;AAClI,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EAAE,KAAK,CAAC;IAC9C,GAAG,EAAE,KAAK,IAAI,EAAE;QACf,IAAI,QAAQ,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YACrC,MAAM,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YACxC,OAAO;QACR,CAAC;QAED,MAAM,KAAK,GAAG,YAAY,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC9C,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACzB,OAAO;QACR,CAAC;QACD,KAAK,CAAC,UAAU,IAAI,CAAC,CAAC;QACtB,IAAI,KAAK,CAAC,UAAU,GAAG,CAAC,EAAE,CAAC;YAC1B,OAAO;QACR,CAAC;QACD,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACtC,MAAM,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACzC,CAAC;CACD,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Context, Effect } from "effect";
|
|
2
|
+
import type { PgBossClient } from "#client.ts";
|
|
2
3
|
import { type JobRegistration } from "#definition.ts";
|
|
3
|
-
import type { PgBossClient } from "./client.ts";
|
|
4
4
|
export declare const registrationName: (registration: JobRegistration) => string;
|
|
5
5
|
export declare const registrationNames: (registrations: readonly JobRegistration[]) => readonly string[];
|
|
6
6
|
export declare const registerJobs: <R>(client: PgBossClient, registrations: readonly JobRegistration[], context: Context.Context<R>, replaceWorkers: boolean) => Effect.Effect<void, import("#error.ts").PgBossError>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../src/internal/register.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,EAAoB,MAAM,QAAQ,CAAC;AAEhE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../src/internal/register.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,EAAoB,MAAM,QAAQ,CAAC;AAEhE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,KAAK,eAAe,EAAsD,MAAM,gBAAgB,CAAC;AAoB1G,eAAO,MAAM,gBAAgB,iBAAkB,eAAe,KAAG,MAQhE,CAAC;AAsEF,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,KACrB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,WAAW,EAAE,WAAW,CAcnD,CAAC"}
|
|
@@ -2,13 +2,19 @@ import { Effect, Redacted, Schema } from "effect";
|
|
|
2
2
|
import { jobContext } from "#definition.ts";
|
|
3
3
|
import { PgBossPayloadError, toPgBossError } from "#error.ts";
|
|
4
4
|
import { deadLetterQueueName } from "#health.ts";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
function queueOptions(options) {
|
|
6
|
+
return {
|
|
7
|
+
retryBackoff: true,
|
|
8
|
+
retryLimit: 3,
|
|
9
|
+
...options,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function isQueueWorker(registration) {
|
|
13
|
+
return registration._tag === "QueueWorker";
|
|
14
|
+
}
|
|
15
|
+
function isScheduledWorker(registration) {
|
|
16
|
+
return registration._tag === "ScheduledWorker";
|
|
17
|
+
}
|
|
12
18
|
export const registrationName = (registration) => {
|
|
13
19
|
if (isQueueWorker(registration)) {
|
|
14
20
|
return registration.queue.name;
|
|
@@ -21,12 +27,14 @@ export const registrationName = (registration) => {
|
|
|
21
27
|
function workerContext(context) {
|
|
22
28
|
return context;
|
|
23
29
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
function runQueueWorker(worker, job, context) {
|
|
31
|
+
return Effect.runPromise(Schema.decodeUnknownEffect(worker.queue.schema)(job.data).pipe(Effect.mapError((error) => new PgBossPayloadError({
|
|
32
|
+
direction: "decode",
|
|
33
|
+
original: Redacted.make(error),
|
|
34
|
+
queue: worker.queue.name,
|
|
35
|
+
})), Effect.flatMap((payload) => worker.handler(payload, jobContext(job))), Effect.provide(context)), { signal: job.signal });
|
|
36
|
+
}
|
|
37
|
+
async function registerQueue(client, worker, context, replaceWorker) {
|
|
30
38
|
const name = worker.queue.name;
|
|
31
39
|
const deadLetter = deadLetterQueueName(name);
|
|
32
40
|
if (replaceWorker) {
|
|
@@ -42,8 +50,8 @@ const registerQueue = async (client, worker, context, replaceWorker) => {
|
|
|
42
50
|
await runQueueWorker(worker, job, context);
|
|
43
51
|
}
|
|
44
52
|
});
|
|
45
|
-
}
|
|
46
|
-
|
|
53
|
+
}
|
|
54
|
+
async function registerSchedule(client, worker, context, replaceWorker) {
|
|
47
55
|
const { schedule } = worker;
|
|
48
56
|
const deadLetter = deadLetterQueueName(schedule.name);
|
|
49
57
|
if (replaceWorker) {
|
|
@@ -62,7 +70,7 @@ const registerSchedule = async (client, worker, context, replaceWorker) => {
|
|
|
62
70
|
}
|
|
63
71
|
});
|
|
64
72
|
await client.schedule(schedule.name, schedule.cron, null, schedule.scheduleOptions);
|
|
65
|
-
}
|
|
73
|
+
}
|
|
66
74
|
export const registrationNames = (registrations) => {
|
|
67
75
|
const names = registrations.map(registrationName);
|
|
68
76
|
if (new Set(names).size !== names.length) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.js","sourceRoot":"","sources":["../../src/internal/register.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"register.js","sourceRoot":"","sources":["../../src/internal/register.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhE,OAAO,EAAwB,UAAU,EAA0C,MAAM,gBAAgB,CAAC;AAC1G,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,SAAS,YAAY,CAAC,OAA0C;IAC/D,OAAO;QACN,YAAY,EAAE,IAAI;QAClB,UAAU,EAAE,CAAC;QACb,GAAG,OAAO;KACV,CAAC;AACH,CAAC;AAED,SAAS,aAAa,CAAC,YAA6B;IACnD,OAAO,YAAY,CAAC,IAAI,KAAK,aAAa,CAAC;AAC5C,CAAC;AAED,SAAS,iBAAiB,CAAC,YAA6B;IACvD,OAAO,YAAY,CAAC,IAAI,KAAK,iBAAiB,CAAC;AAChD,CAAC;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,YAA6B,EAAU,EAAE;IACzE,IAAI,aAAa,CAAC,YAAY,CAAC,EAAE,CAAC;QACjC,OAAO,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC;IAChC,CAAC;IACD,IAAI,iBAAiB,CAAC,YAAY,CAAC,EAAE,CAAC;QACrC,OAAO,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC;IACnC,CAAC;IACD,MAAM,IAAI,SAAS,CAAC,iCAAiC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC;AAC3E,CAAC,CAAC;AAIF,SAAS,aAAa,CAAC,OAAgB;IACtC,OAAO,OAAO,CAAC;AAChB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AAM,iBAAiB,GAAG,CAAC,aAAyC,EAAqB,EAAE;IACjG,MAAM,KAAK,GAAG,aAAa,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAClD,IAAI,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,KAAK,CAAC,MAAM,EAAE,CAAC;QAC1C,MAAM,IAAI,SAAS,CAAC,kCAAkC,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CAC3B,MAAoB,EACpB,aAAyC,EACzC,OAA2B,EAC3B,cAAuB,EACgC,EAAE,CACzD,MAAM,CAAC,UAAU,CAAC;IACjB,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,KAAK,CAAC;IAClD,GAAG,EAAE,KAAK,IAAI,EAAE;QACf,iBAAiB,CAAC,aAAa,CAAC,CAAC;QACjC,MAAM,QAAQ,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;QACxC,KAAK,MAAM,YAAY,IAAI,aAAa,EAAE,CAAC;YAC1C,IAAI,aAAa,CAAC,YAAY,CAAC,EAAE,CAAC;gBACjC,MAAM,aAAa,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;YACrE,CAAC;iBAAM,IAAI,iBAAiB,CAAC,YAAY,CAAC,EAAE,CAAC;gBAC5C,MAAM,gBAAgB,CAAC,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;YACxE,CAAC;QACF,CAAC;IACF,CAAC;CACD,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
+
import type { PgBossClient } from "#client.ts";
|
|
1
2
|
import type { PgBossService } from "#service.ts";
|
|
2
|
-
import type { PgBossClient } from "./client.ts";
|
|
3
3
|
export declare const makeService: (client: PgBossClient, names: readonly string[]) => PgBossService;
|
|
4
4
|
//# sourceMappingURL=service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/internal/service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/internal/service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD,eAAO,MAAM,WAAW,WAAY,YAAY,SAAS,SAAS,MAAM,EAAE,KAAG,aA4B3E,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/internal/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/internal/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE1D,OAAO,EAAoB,kBAAkB,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAEhF,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,MAAoB,EAAE,KAAwB,EAAiB,EAAE,CAAC,CAAC;IAC9F,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,CACpC,MAAM,CAAC,mBAAmB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CACrD,MAAM,CAAC,QAAQ,CACd,CAAC,KAAK,EAAE,EAAE,CACT,IAAI,kBAAkB,CAAC;QACtB,SAAS,EAAE,QAAQ;QACnB,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC;QAC9B,KAAK,EAAE,KAAK,CAAC,IAAI;KACjB,CAAC,CACH,EACD,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,EAA0E,EAAE;QAClG,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;YACrD,OAAO,MAAM,CAAC,IAAI,CACjB,IAAI,kBAAkB,CAAC;gBACtB,SAAS,EAAE,QAAQ;gBACnB,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,yCAAyC,CAAC,CAAC;gBACjF,KAAK,EAAE,KAAK,CAAC,IAAI;aACjB,CAAC,CACF,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC,UAAU,CAAC;YACxB,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,SAAS,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC;YAC7D,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC;SACpD,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC;IAC3C,CAAC,CAAC,CACF;IACF,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC;CAChC,CAAC,CAAC"}
|
package/dist/service.d.ts
CHANGED
|
@@ -1,26 +1,22 @@
|
|
|
1
1
|
import { Context, Effect, Layer, type Option, type Schema } from "effect";
|
|
2
2
|
import type { ConstructorOptions, SendOptions, StopOptions } from "pg-boss";
|
|
3
|
-
import type { PgBossClientFactory } from "#
|
|
3
|
+
import type { PgBossClientFactory } from "#client.ts";
|
|
4
4
|
import type { JobPayloadSchema, JobRegistration, QueueDefinition, RegistrationRequirements } from "./definition.ts";
|
|
5
5
|
import type { PgBossError, PgBossPayloadError } from "./error.ts";
|
|
6
6
|
import type { JobsHealth } from "./health.ts";
|
|
7
7
|
export interface PgBossService {
|
|
8
|
-
readonly enqueue: <const
|
|
8
|
+
readonly enqueue: <const TName extends string, const TPayload extends JobPayloadSchema>(queue: QueueDefinition<TName, TPayload>, payload: Schema.Schema.Type<TPayload>, options?: SendOptions) => Effect.Effect<Option.Option<string>, PgBossError | PgBossPayloadError, TPayload["EncodingServices"]>;
|
|
9
9
|
readonly health: Effect.Effect<JobsHealth, PgBossError>;
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
readonly _pgBossIdentifier: unique symbol;
|
|
13
|
-
}
|
|
14
|
-
export type PgBossLayerOptions<Registrations extends readonly JobRegistration[], ErrorRequirements> = ConstructorOptions & {
|
|
11
|
+
export type PgBossLayerOptions<TRegistrations extends readonly JobRegistration[], TErrorRequirements> = ConstructorOptions & {
|
|
15
12
|
readonly clientFactory?: PgBossClientFactory;
|
|
16
13
|
readonly clientCacheKey?: string | symbol | undefined;
|
|
17
|
-
readonly jobs:
|
|
18
|
-
readonly onError?: (error: Error) => Effect.Effect<unknown, never,
|
|
14
|
+
readonly jobs: TRegistrations;
|
|
15
|
+
readonly onError?: (error: Error) => Effect.Effect<unknown, never, TErrorRequirements>;
|
|
19
16
|
readonly stop?: StopOptions;
|
|
20
17
|
};
|
|
21
|
-
export interface PgBossDefinition extends Context.Service<
|
|
22
|
-
readonly layer: <const
|
|
18
|
+
export interface PgBossDefinition<TIdentifier extends string = string> extends Context.Service<TIdentifier, PgBossService> {
|
|
19
|
+
readonly layer: <const TRegistrations extends readonly JobRegistration[], TErrorRequirements = never>(options: PgBossLayerOptions<TRegistrations, TErrorRequirements>) => Layer.Layer<TIdentifier, PgBossError, RegistrationRequirements<TRegistrations> | TErrorRequirements>;
|
|
23
20
|
}
|
|
24
|
-
export declare const makePgBoss: (identifier:
|
|
25
|
-
export {};
|
|
21
|
+
export declare const makePgBoss: <const TIdentifier extends string>(identifier: TIdentifier) => PgBossDefinition<TIdentifier>;
|
|
26
22
|
//# sourceMappingURL=service.d.ts.map
|
package/dist/service.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC1E,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAItD,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AACpH,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,KAAK,SAAS,MAAM,EAAE,KAAK,CAAC,QAAQ,SAAS,gBAAgB,EACrF,KAAK,EAAE,eAAe,CAAC,KAAK,EAAE,QAAQ,CAAC,EACvC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EACrC,OAAO,CAAC,EAAE,WAAW,KACjB,MAAM,CAAC,MAAM,CAAC,MA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, Effect, Layer } from "effect";
|
|
|
2
2
|
import { acquireClient, releaseClient } from "#internal/lifecycle.ts";
|
|
3
3
|
import { registerJobs, registrationName } from "#internal/register.ts";
|
|
4
4
|
import { makeService } from "#internal/service.ts";
|
|
5
|
-
|
|
5
|
+
function logClientError(error) {
|
|
6
|
+
return Effect.logError({ event: "pg_boss_error", message: error.message });
|
|
7
|
+
}
|
|
6
8
|
export const makePgBoss = (identifier) => {
|
|
7
9
|
const Service = Context.Service(identifier);
|
|
8
10
|
const layer = (options) => {
|
package/dist/service.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAA4B,MAAM,QAAQ,CAAC;AAG1E,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAA4B,MAAM,QAAQ,CAAC;AAG1E,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AA6BnD,SAAS,cAAc,CAAC,KAAY;IACnC,OAAO,MAAM,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;AAC5E,CAAC;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,CAAmC,UAAuB,EAAiC,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ACnB,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;gBAC5C,OAAO,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;YACtC,CAAC,CAAC,CACF,CAAC;QACH,CAAC,CAAC,EACF,CAAC,QAAQ,EAAE,EAAE;YACZ,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;YAC9D,OAAO,aAAa,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAC/C,CAAC,CACD,CAAC;QAEF,OAAO,KAAK,CAAC,MAAM,CAClB,OAAO,EACP,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAC1E,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;AAC1C,CAAC,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# North star
|
|
2
|
+
|
|
3
|
+
## The problem
|
|
4
|
+
|
|
5
|
+
A durable job crosses two boundaries at once. Data leaves the producer's process and is read later by a worker; execution leaves the request's Effect context and is called later by pg-boss. When applications bridge those boundaries by hand, they repeat payload validation, dependency capture, queue registration and shutdown logic. A producer can drift from its worker's payload shape, a worker can rebuild services differently from the rest of the application, and a client can outlive the scope that should own it.
|
|
6
|
+
|
|
7
|
+
The package exists to make that boundary one reusable path. pg-boss remains the PostgreSQL queue engine. Effect remains the application's language for services, errors and resources. The adapter should join those pieces without making the application learn another execution model.
|
|
8
|
+
|
|
9
|
+
## The ideal
|
|
10
|
+
|
|
11
|
+
A feature declares one object Schema for a queue, then attaches an ordinary Effect handler. The producer uses its decoded type; the durable boundary uses its encoded type; the handler receives decoded data. Domain code never has to guess what an old or malformed stored payload means.
|
|
12
|
+
|
|
13
|
+
A scheduled feature declares a name and cron expression, then attaches a payload-free Effect. Queue workers and scheduled workers become one list of registrations at the application's runtime boundary. The application's jobs Layer supplies the workers' services and owns the client that pg-boss calls through.
|
|
14
|
+
|
|
15
|
+
An application that needs only queueing should not import a repository framework, transport or UI package. A worker that needs application services should declare them through ordinary Effect requirements. The jobs adapter should preserve those requirements rather than hiding them in a global runtime or making each callback rebuild its dependencies.
|
|
16
|
+
|
|
17
|
+
## What good looks like
|
|
18
|
+
|
|
19
|
+
- The payload contract is authored once, including transformations between application and durable representations.
|
|
20
|
+
- Invalid stored data is rejected before the worker's domain handler executes.
|
|
21
|
+
- Worker services are supplied where the jobs Layer is built, and their requirements remain visible to TypeScript.
|
|
22
|
+
- The client starts under an Effect scope. Startup failure, registration failure and scope release have a clear resource owner.
|
|
23
|
+
- Client reuse is requested with a key. Applications choose the environments and registrations that should share a client.
|
|
24
|
+
- pg-boss options remain pg-boss options. The package removes repeated boundary plumbing, not the engine's vocabulary.
|
|
25
|
+
- Operational observations are data, such as queue counts; an application decides what those observations mean for its health endpoint and alerts.
|
|
26
|
+
- Documentation distinguishes a fake client's observed calls from durable behavior demonstrated against PostgreSQL.
|
|
27
|
+
|
|
28
|
+
## Trade-offs
|
|
29
|
+
|
|
30
|
+
**The durable contract wins over permissive input.** A queue Schema must describe object data on both sides. A malformed payload should not become a partially trusted value in domain code merely to keep a worker running.
|
|
31
|
+
|
|
32
|
+
**Explicit dependencies win over callback convenience.** The jobs Layer requires the services its handlers use. Adding a hidden runtime or service locator would make a worker shorter while moving its real dependencies out of the type system.
|
|
33
|
+
|
|
34
|
+
**Resource ownership wins over reuse.** Sharing a client can avoid duplicate starts across Layer builds, but a cache key is an application choice. It must not become a reason to ignore cleanup or silently infer environment policy.
|
|
35
|
+
|
|
36
|
+
**A thin boundary wins over orchestration features.** pg-boss already owns queue execution and scheduling. A new helper earns its place by removing repeated application code at the Effect boundary, with tests for the semantics it preserves.
|
|
37
|
+
|
|
38
|
+
**Proven behavior wins over a broader pitch.** Passing `retryBackoff: true` proves registration supplied that option. It does not prove retry timing. A fake client cannot establish a PostgreSQL delivery guarantee, and a PostgreSQL library test cannot establish application adoption or deployment behavior.
|
|
39
|
+
|
|
40
|
+
## What it deliberately leaves out
|
|
41
|
+
|
|
42
|
+
- A replacement for pg-boss storage, cron interpretation, queue policy or retry execution.
|
|
43
|
+
- Domain workers, authorization rules, external-provider interfaces and application logging or health policy.
|
|
44
|
+
- Another general service declaration system; native Context and Layer stay available, and general declaration ergonomics belong to `effect-service`.
|
|
45
|
+
- Application repositories or migration ownership; those belong to `effect-sql`.
|
|
46
|
+
- An implicit link between enqueueing and an application's database transaction. Transaction and outbox policy remain application decisions; after-commit changes have their own path through `effect-changes`.
|
|
47
|
+
- A promise of exactly-once domain side effects or provider idempotency. Those need application-specific decisions and evidence.
|
|
48
|
+
- Browser, device or offline synchronization behavior. A PostgreSQL queue boundary cannot establish those product contracts.
|
package/docs/roadmap.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Roadmap
|
|
2
|
+
|
|
3
|
+
This file owns the package's implementation inventory and open API choices. The [framework roadmap](https://github.com/ShivaeDev/platform/blob/main/docs/framework/roadmap.md#next-application-and-deployment-acceptance) owns jobs integration with application services and external providers, including deployment and device validation.
|
|
4
|
+
|
|
5
|
+
## Built
|
|
6
|
+
|
|
7
|
+
- [x] `makePgBoss` retains its literal service identity in `PgBossDefinition` and its Layer type, so a different jobs Layer does not satisfy the required service. [Compiler evidence](https://github.com/ShivaeDev/platform/blob/main/packages/effect-pg-boss/src/service.typecheck.test.ts).
|
|
8
|
+
- [x] Object payload Schema definitions, decoded enqueue types and queue workers. Type tests reject primitive schemas, missing fields and encoded values passed as decoded payloads.
|
|
9
|
+
- [x] Encoding at enqueue and decoding before the handler. The PostgreSQL test round-trips a transformed payload and checks that malformed stored data reaches the dead-letter queue without calling the domain handler.
|
|
10
|
+
- [x] Queue and schedule registration, with dead-letter queues, default retry settings and UTC schedule registration. Fake-client tests verify the supplied settings and a retry-limit override.
|
|
11
|
+
- [x] Worker and scheduled Effect service capture. Runtime and packed-consumer type tests preserve handler requirements.
|
|
12
|
+
- [x] Scoped startup and shutdown, including cleanup when startup or registration fails.
|
|
13
|
+
- [x] Explicit keyed client reuse and unkeyed per-build acquisition. Lifecycle tests cover two builds sharing one client and replacing the registered worker.
|
|
14
|
+
- [x] Queue health totals for active, failed, queued, ready and dead-lettered counts, verified with a populated fake queue.
|
|
15
|
+
- [x] Public defining-module imports and an installed-package type fixture.
|
|
16
|
+
|
|
17
|
+
## Next
|
|
18
|
+
|
|
19
|
+
No further package API expansion is selected. Let the framework's jobs integration work identify the next package change, and preserve the existing payload and lifecycle contracts while it does. That integration's status stays in the framework roadmap.
|
|
20
|
+
|
|
21
|
+
## Open questions
|
|
22
|
+
|
|
23
|
+
- Which application boundary should choose how a database write becomes a durable job: an explicit after-commit action, an outbox, or another demonstrated approach? The enqueue API is independent of application SQL; no transaction coupling is selected.
|
|
24
|
+
- Should a shared client key be checked against constructor settings and registration changes? The lifecycle fixture uses the same Layer twice; it does not settle incompatible configurations under one key.
|
|
25
|
+
- Which public hooks need dedicated regression coverage before the guide makes stronger claims? Error-event reporting, cancellation through a job's AbortSignal, a declined send result, multi-queue health and actual cron/retry execution are implemented boundaries or engine behaviors without focused evidence here.
|
|
26
|
+
- Should the package grow only when an application's integration needs a helper, or is a wider jobs API intended? The package has no in-repo application consumer to settle that question.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shivaedev/effect-pg-boss",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Effect-native jobs and lifecycle management for pg-boss",
|
|
5
5
|
"homepage": "https://github.com/ShivaeDev/platform/tree/main/packages/effect-pg-boss#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"sideEffects": false,
|
|
16
16
|
"type": "module",
|
|
17
17
|
"imports": {
|
|
18
|
-
"#test/*": "./test/*",
|
|
18
|
+
"#test/*": "./src/test-support/*",
|
|
19
19
|
"#*.ts": {
|
|
20
20
|
"source": "./src/*.ts",
|
|
21
21
|
"types": "./dist/*.d.ts",
|
|
@@ -23,32 +23,37 @@
|
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
"exports": {
|
|
26
|
-
"
|
|
27
|
-
"types": "./dist
|
|
28
|
-
"source": "./src
|
|
29
|
-
"import": "./dist
|
|
30
|
-
"default": "./dist
|
|
26
|
+
"./*.ts": {
|
|
27
|
+
"types": "./dist/*.d.ts",
|
|
28
|
+
"source": "./src/*.ts",
|
|
29
|
+
"import": "./dist/*.js",
|
|
30
|
+
"default": "./dist/*.js"
|
|
31
31
|
},
|
|
32
|
+
"./internal/*": null,
|
|
32
33
|
"./package.json": "./package.json"
|
|
33
34
|
},
|
|
34
35
|
"files": [
|
|
35
36
|
"dist",
|
|
36
37
|
"src",
|
|
38
|
+
"!src/**/*.test.ts",
|
|
39
|
+
"!src/**/*.spec.ts",
|
|
40
|
+
"!src/**/test-support",
|
|
41
|
+
"docs",
|
|
37
42
|
"CHANGELOG.md",
|
|
38
43
|
"README.md"
|
|
39
44
|
],
|
|
40
45
|
"devDependencies": {
|
|
41
|
-
"@shivaedev/quality": "0.
|
|
42
|
-
"@types/node": "24.
|
|
46
|
+
"@shivaedev/quality": "0.19.0",
|
|
47
|
+
"@types/node": "24.19.1",
|
|
43
48
|
"@typescript/native": "npm:typescript@7.0.2",
|
|
44
49
|
"effect": "4.0.0-rc.112",
|
|
45
|
-
"pg-boss": "12.
|
|
50
|
+
"pg-boss": "12.36.0",
|
|
46
51
|
"typescript": "npm:@typescript/typescript6@6.0.2",
|
|
47
|
-
"vitest": "4.1.
|
|
52
|
+
"vitest": "4.1.11"
|
|
48
53
|
},
|
|
49
54
|
"peerDependencies": {
|
|
50
55
|
"effect": "4.0.0-rc.112",
|
|
51
|
-
"pg-boss": "12.
|
|
56
|
+
"pg-boss": "12.36.0"
|
|
52
57
|
},
|
|
53
58
|
"engines": {
|
|
54
59
|
"node": ">=24"
|
|
@@ -58,7 +63,7 @@
|
|
|
58
63
|
"provenance": true
|
|
59
64
|
},
|
|
60
65
|
"scripts": {
|
|
61
|
-
"build": "node --eval \"import('node:fs').then(({ rmSync }) => rmSync('dist', { force: true, recursive: true }))\" &&
|
|
66
|
+
"build": "node --eval \"import('node:fs').then(({ rmSync }) => rmSync('dist', { force: true, recursive: true }))\" && tsc --project tsconfig.build.json",
|
|
62
67
|
"ready": "pnpm typecheck && pnpm test && pnpm build",
|
|
63
68
|
"test": "vitest run",
|
|
64
69
|
"typecheck": "tsc --noEmit"
|
package/src/internal/health.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
+
import type { PgBossClient } from "#client.ts";
|
|
2
3
|
import { toPgBossError } from "#error.ts";
|
|
3
4
|
import { deadLetterQueueName, type JobsHealth, type QueueHealth } from "#health.ts";
|
|
4
|
-
import type { PgBossClient } from "./client.ts";
|
|
5
5
|
|
|
6
6
|
export const healthFor = (client: PgBossClient, names: readonly string[]): Effect.Effect<JobsHealth, import("#error.ts").PgBossError> =>
|
|
7
7
|
Effect.forEach(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import type { ConstructorOptions, StopOptions } from "pg-boss";
|
|
3
|
+
import { defaultClientFactory, type PgBossClient, type PgBossClientFactory } from "#client.ts";
|
|
3
4
|
import { toPgBossError } from "#error.ts";
|
|
4
|
-
import { defaultClientFactory, type PgBossClient, type PgBossClientFactory } from "./client.ts";
|
|
5
5
|
|
|
6
6
|
interface CachedClient {
|
|
7
7
|
readonly client: Promise<PgBossClient>;
|
|
@@ -13,16 +13,19 @@ const sharedCache: unknown = Reflect.get(globalThis, CacheKey);
|
|
|
13
13
|
const clientCache: Map<string | symbol, unknown> = sharedCache instanceof Map ? sharedCache : new Map<string | symbol, unknown>();
|
|
14
14
|
Reflect.set(globalThis, CacheKey, clientCache);
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
function isCachedClient(value: unknown): value is CachedClient {
|
|
17
|
+
return (
|
|
18
|
+
typeof value === "object"
|
|
19
|
+
&& value !== null
|
|
20
|
+
&& Reflect.get(value, "client") instanceof Promise
|
|
21
|
+
&& typeof Reflect.get(value, "references") === "number"
|
|
22
|
+
);
|
|
23
|
+
}
|
|
21
24
|
|
|
22
|
-
|
|
25
|
+
function cachedClient(key: string | symbol): CachedClient | undefined {
|
|
23
26
|
const entry = clientCache.get(key);
|
|
24
27
|
return isCachedClient(entry) ? entry : undefined;
|
|
25
|
-
}
|
|
28
|
+
}
|
|
26
29
|
|
|
27
30
|
export interface AcquireClientOptions {
|
|
28
31
|
readonly clientCacheKey?: string | symbol | undefined;
|
|
@@ -36,7 +39,7 @@ export interface AcquiredClient {
|
|
|
36
39
|
readonly reused: boolean;
|
|
37
40
|
}
|
|
38
41
|
|
|
39
|
-
|
|
42
|
+
function startClient(options: AcquireClientOptions): Promise<PgBossClient> {
|
|
40
43
|
const client = (options.clientFactory ?? defaultClientFactory)(options.constructor);
|
|
41
44
|
return client.start().then(
|
|
42
45
|
() => client,
|
|
@@ -49,7 +52,7 @@ const startClient = (options: AcquireClientOptions): Promise<PgBossClient> => {
|
|
|
49
52
|
throw error;
|
|
50
53
|
},
|
|
51
54
|
);
|
|
52
|
-
}
|
|
55
|
+
}
|
|
53
56
|
|
|
54
57
|
export const acquireClient = (options: AcquireClientOptions): Effect.Effect<AcquiredClient, import("#error.ts").PgBossError> =>
|
|
55
58
|
Effect.tryPromise({
|
package/src/internal/register.ts
CHANGED
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
import { type Context, Effect, Redacted, Schema } from "effect";
|
|
2
2
|
import type { Job } from "pg-boss";
|
|
3
|
+
import type { PgBossClient } from "#client.ts";
|
|
3
4
|
import { type JobRegistration, jobContext, type QueueWorker, type ScheduledWorker } from "#definition.ts";
|
|
4
5
|
import { PgBossPayloadError, toPgBossError } from "#error.ts";
|
|
5
6
|
import { deadLetterQueueName } from "#health.ts";
|
|
6
|
-
import type { PgBossClient } from "./client.ts";
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
function queueOptions(options: Readonly<Record<string, unknown>>) {
|
|
9
|
+
return {
|
|
10
|
+
retryBackoff: true,
|
|
11
|
+
retryLimit: 3,
|
|
12
|
+
...options,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
function isQueueWorker(registration: JobRegistration): registration is QueueWorker {
|
|
17
|
+
return registration._tag === "QueueWorker";
|
|
18
|
+
}
|
|
15
19
|
|
|
16
|
-
|
|
20
|
+
function isScheduledWorker(registration: JobRegistration): registration is ScheduledWorker {
|
|
21
|
+
return registration._tag === "ScheduledWorker";
|
|
22
|
+
}
|
|
17
23
|
|
|
18
24
|
export const registrationName = (registration: JobRegistration): string => {
|
|
19
25
|
if (isQueueWorker(registration)) {
|
|
@@ -31,8 +37,8 @@ function workerContext(context: unknown): unknown {
|
|
|
31
37
|
return context;
|
|
32
38
|
}
|
|
33
39
|
|
|
34
|
-
|
|
35
|
-
Effect.runPromise(
|
|
40
|
+
function runQueueWorker(worker: QueueWorker, job: Job<unknown>, context: Context.Context<unknown>): Promise<unknown> {
|
|
41
|
+
return Effect.runPromise(
|
|
36
42
|
Schema.decodeUnknownEffect(worker.queue.schema)(job.data).pipe(
|
|
37
43
|
Effect.mapError(
|
|
38
44
|
(error) =>
|
|
@@ -47,8 +53,9 @@ const runQueueWorker = (worker: QueueWorker, job: Job<unknown>, context: Context
|
|
|
47
53
|
),
|
|
48
54
|
{ signal: job.signal },
|
|
49
55
|
);
|
|
56
|
+
}
|
|
50
57
|
|
|
51
|
-
|
|
58
|
+
async function registerQueue(client: PgBossClient, worker: QueueWorker, context: Context.Context<unknown>, replaceWorker: boolean): Promise<void> {
|
|
52
59
|
const name = worker.queue.name;
|
|
53
60
|
const deadLetter = deadLetterQueueName(name);
|
|
54
61
|
if (replaceWorker) {
|
|
@@ -64,14 +71,14 @@ const registerQueue = async (client: PgBossClient, worker: QueueWorker, context:
|
|
|
64
71
|
await runQueueWorker(worker, job, context);
|
|
65
72
|
}
|
|
66
73
|
});
|
|
67
|
-
}
|
|
74
|
+
}
|
|
68
75
|
|
|
69
|
-
|
|
76
|
+
async function registerSchedule(
|
|
70
77
|
client: PgBossClient,
|
|
71
78
|
worker: ScheduledWorker,
|
|
72
79
|
context: Context.Context<unknown>,
|
|
73
80
|
replaceWorker: boolean,
|
|
74
|
-
): Promise<void>
|
|
81
|
+
): Promise<void> {
|
|
75
82
|
const { schedule } = worker;
|
|
76
83
|
const deadLetter = deadLetterQueueName(schedule.name);
|
|
77
84
|
if (replaceWorker) {
|
|
@@ -90,7 +97,7 @@ const registerSchedule = async (
|
|
|
90
97
|
}
|
|
91
98
|
});
|
|
92
99
|
await client.schedule(schedule.name, schedule.cron, null, schedule.scheduleOptions);
|
|
93
|
-
}
|
|
100
|
+
}
|
|
94
101
|
|
|
95
102
|
export const registrationNames = (registrations: readonly JobRegistration[]): readonly string[] => {
|
|
96
103
|
const names = registrations.map(registrationName);
|
package/src/internal/service.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Effect, Option, Redacted, Schema } from "effect";
|
|
2
|
+
import type { PgBossClient } from "#client.ts";
|
|
2
3
|
import { type PgBossError, PgBossPayloadError, toPgBossError } from "#error.ts";
|
|
3
4
|
import type { PgBossService } from "#service.ts";
|
|
4
|
-
import type { PgBossClient } from "./client.ts";
|
|
5
5
|
import { healthFor } from "./health.ts";
|
|
6
6
|
|
|
7
7
|
export const makeService = (client: PgBossClient, names: readonly string[]): PgBossService => ({
|
package/src/service.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Context, Effect, Layer, type Option, type Schema } from "effect";
|
|
2
2
|
import type { ConstructorOptions, SendOptions, StopOptions } from "pg-boss";
|
|
3
|
-
import type { PgBossClientFactory } from "#
|
|
3
|
+
import type { PgBossClientFactory } from "#client.ts";
|
|
4
4
|
import { acquireClient, releaseClient } from "#internal/lifecycle.ts";
|
|
5
5
|
import { registerJobs, registrationName } from "#internal/register.ts";
|
|
6
6
|
import { makeService } from "#internal/service.ts";
|
|
@@ -9,42 +9,40 @@ import type { PgBossError, PgBossPayloadError } from "./error.ts";
|
|
|
9
9
|
import type { JobsHealth } from "./health.ts";
|
|
10
10
|
|
|
11
11
|
export interface PgBossService {
|
|
12
|
-
readonly enqueue: <const
|
|
13
|
-
queue: QueueDefinition<
|
|
14
|
-
payload: Schema.Schema.Type<
|
|
12
|
+
readonly enqueue: <const TName extends string, const TPayload extends JobPayloadSchema>(
|
|
13
|
+
queue: QueueDefinition<TName, TPayload>,
|
|
14
|
+
payload: Schema.Schema.Type<TPayload>,
|
|
15
15
|
options?: SendOptions,
|
|
16
|
-
) => Effect.Effect<Option.Option<string>, PgBossError | PgBossPayloadError,
|
|
16
|
+
) => Effect.Effect<Option.Option<string>, PgBossError | PgBossPayloadError, TPayload["EncodingServices"]>;
|
|
17
17
|
readonly health: Effect.Effect<JobsHealth, PgBossError>;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
readonly _pgBossIdentifier: unique symbol;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export type PgBossLayerOptions<Registrations extends readonly JobRegistration[], ErrorRequirements> = ConstructorOptions & {
|
|
20
|
+
export type PgBossLayerOptions<TRegistrations extends readonly JobRegistration[], TErrorRequirements> = ConstructorOptions & {
|
|
25
21
|
readonly clientFactory?: PgBossClientFactory;
|
|
26
22
|
// One started client is reference-counted per key, so development module reloads reuse it instead of starting another.
|
|
27
23
|
readonly clientCacheKey?: string | symbol | undefined;
|
|
28
|
-
readonly jobs:
|
|
29
|
-
readonly onError?: (error: Error) => Effect.Effect<unknown, never,
|
|
24
|
+
readonly jobs: TRegistrations;
|
|
25
|
+
readonly onError?: (error: Error) => Effect.Effect<unknown, never, TErrorRequirements>;
|
|
30
26
|
readonly stop?: StopOptions;
|
|
31
27
|
};
|
|
32
28
|
|
|
33
|
-
export interface PgBossDefinition extends Context.Service<
|
|
34
|
-
readonly layer: <const
|
|
35
|
-
options: PgBossLayerOptions<
|
|
36
|
-
) => Layer.Layer<
|
|
29
|
+
export interface PgBossDefinition<TIdentifier extends string = string> extends Context.Service<TIdentifier, PgBossService> {
|
|
30
|
+
readonly layer: <const TRegistrations extends readonly JobRegistration[], TErrorRequirements = never>(
|
|
31
|
+
options: PgBossLayerOptions<TRegistrations, TErrorRequirements>,
|
|
32
|
+
) => Layer.Layer<TIdentifier, PgBossError, RegistrationRequirements<TRegistrations> | TErrorRequirements>;
|
|
37
33
|
}
|
|
38
34
|
|
|
39
|
-
|
|
35
|
+
function logClientError(error: Error): Effect.Effect<void> {
|
|
36
|
+
return Effect.logError({ event: "pg_boss_error", message: error.message });
|
|
37
|
+
}
|
|
40
38
|
|
|
41
|
-
export const makePgBoss = (identifier:
|
|
42
|
-
const Service = Context.Service<
|
|
39
|
+
export const makePgBoss = <const TIdentifier extends string>(identifier: TIdentifier): PgBossDefinition<TIdentifier> => {
|
|
40
|
+
const Service = Context.Service<TIdentifier, PgBossService>(identifier);
|
|
43
41
|
|
|
44
|
-
const layer = <const
|
|
45
|
-
options: PgBossLayerOptions<
|
|
46
|
-
): Layer.Layer<
|
|
47
|
-
type Requirements = RegistrationRequirements<
|
|
42
|
+
const layer = <const TRegistrations extends readonly JobRegistration[], TErrorRequirements = never>(
|
|
43
|
+
options: PgBossLayerOptions<TRegistrations, TErrorRequirements>,
|
|
44
|
+
): Layer.Layer<TIdentifier, PgBossError, RegistrationRequirements<TRegistrations> | TErrorRequirements> => {
|
|
45
|
+
type Requirements = RegistrationRequirements<TRegistrations> | TErrorRequirements;
|
|
48
46
|
const names = options.jobs.map(registrationName);
|
|
49
47
|
const { clientFactory, clientCacheKey, jobs, onError, stop, ...constructorOptions } = options;
|
|
50
48
|
|
package/dist/index.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export type { PgBossClient, PgBossClientFactory, } from "#internal/client.ts";
|
|
2
|
-
export { type DefineQueueOptions, type DefineScheduleOptions, defineQueue, defineSchedule, type JobContext, type JobPayloadSchema, type JobRegistration, type QueueDefinition, type QueueWorker, type ScheduleDefinition, type ScheduledWorker, } from "./definition.ts";
|
|
3
|
-
export { PgBossError, type PgBossOperation, PgBossPayloadError, } from "./error.ts";
|
|
4
|
-
export { deadLetterQueueName, type JobsHealth, type QueueHealth, } from "./health.ts";
|
|
5
|
-
export { makePgBoss, type PgBossDefinition, type PgBossLayerOptions, type PgBossService, } from "./service.ts";
|
|
6
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACX,YAAY,EACZ,mBAAmB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACN,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,WAAW,EACX,cAAc,EACd,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,eAAe,GACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,WAAW,EACX,KAAK,eAAe,EACpB,kBAAkB,GAClB,MAAM,YAAY,CAAC;AACpB,OAAO,EACN,mBAAmB,EACnB,KAAK,UAAU,EACf,KAAK,WAAW,GAChB,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,UAAU,EACV,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,aAAa,GAClB,MAAM,cAAc,CAAC"}
|
package/dist/index.js
DELETED
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAGN,WAAW,EACX,cAAc,GAQd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,WAAW,EAEX,kBAAkB,GAClB,MAAM,YAAY,CAAC;AACpB,OAAO,EACN,mBAAmB,GAGnB,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,UAAU,GAIV,MAAM,cAAc,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/internal/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGnI,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACrF,QAAQ,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACjE,QAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,KAAK,OAAO,CAAC;IAC5E,QAAQ,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAClD,QAAQ,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,QAA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0,0 @@
|
|
|
1
|
-
export type {
|
|
2
|
-
PgBossClient,
|
|
3
|
-
PgBossClientFactory,
|
|
4
|
-
} from "#internal/client.ts";
|
|
5
|
-
export {
|
|
6
|
-
type DefineQueueOptions,
|
|
7
|
-
type DefineScheduleOptions,
|
|
8
|
-
defineQueue,
|
|
9
|
-
defineSchedule,
|
|
10
|
-
type JobContext,
|
|
11
|
-
type JobPayloadSchema,
|
|
12
|
-
type JobRegistration,
|
|
13
|
-
type QueueDefinition,
|
|
14
|
-
type QueueWorker,
|
|
15
|
-
type ScheduleDefinition,
|
|
16
|
-
type ScheduledWorker,
|
|
17
|
-
} from "./definition.ts";
|
|
18
|
-
export {
|
|
19
|
-
PgBossError,
|
|
20
|
-
type PgBossOperation,
|
|
21
|
-
PgBossPayloadError,
|
|
22
|
-
} from "./error.ts";
|
|
23
|
-
export {
|
|
24
|
-
deadLetterQueueName,
|
|
25
|
-
type JobsHealth,
|
|
26
|
-
type QueueHealth,
|
|
27
|
-
} from "./health.ts";
|
|
28
|
-
export {
|
|
29
|
-
makePgBoss,
|
|
30
|
-
type PgBossDefinition,
|
|
31
|
-
type PgBossLayerOptions,
|
|
32
|
-
type PgBossService,
|
|
33
|
-
} from "./service.ts";
|
|
File without changes
|
|
File without changes
|
|
File without changes
|