@shivaedev/effect-pg-boss 0.1.3 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -1
- package/README.md +7 -5
- package/dist/definition.d.ts +8 -8
- package/dist/definition.d.ts.map +1 -1
- package/dist/definition.js +6 -6
- package/dist/definition.js.map +1 -1
- package/dist/error.d.ts +1 -1
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +1 -1
- package/dist/error.js.map +1 -1
- package/dist/health.d.ts.map +1 -1
- package/dist/health.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/client.d.ts +2 -2
- package/dist/internal/client.d.ts.map +1 -1
- package/dist/internal/client.js.map +1 -1
- package/dist/internal/health.d.ts +3 -3
- package/dist/internal/health.d.ts.map +1 -1
- package/dist/internal/health.js +4 -7
- package/dist/internal/health.js.map +1 -1
- package/dist/internal/lifecycle.d.ts +5 -5
- package/dist/internal/lifecycle.d.ts.map +1 -1
- package/dist/internal/lifecycle.js +24 -15
- package/dist/internal/lifecycle.js.map +1 -1
- package/dist/internal/register.d.ts +5 -4
- package/dist/internal/register.d.ts.map +1 -1
- package/dist/internal/register.js +30 -14
- package/dist/internal/register.js.map +1 -1
- package/dist/internal/service.d.ts +2 -2
- package/dist/internal/service.d.ts.map +1 -1
- package/dist/internal/service.js +2 -2
- package/dist/internal/service.js.map +1 -1
- package/dist/service.d.ts +5 -6
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +8 -15
- package/dist/service.js.map +1 -1
- package/package.json +35 -29
- package/src/definition.ts +22 -46
- package/src/error.ts +4 -13
- package/src/health.ts +1 -2
- package/src/index.ts +8 -8
- package/src/internal/client.ts +7 -33
- package/src/internal/health.ts +7 -20
- package/src/internal/lifecycle.ts +35 -35
- package/src/internal/register.ts +58 -71
- package/src/internal/service.ts +20 -36
- package/src/service.ts +29 -91
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,35 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 0.2.1 - 2026-10-04
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- Imports that leave their folder go through `#` aliases declared in the `imports` field of `package.json`: `#*.ts` resolves to `src` under the `source` condition and to `dist` otherwise, and `#test/*` names a test file. The published modules and declarations name the package's own files through these aliases.
|
|
8
|
+
|
|
9
|
+
- Validate packed consumers and executable bins through the shared workspace gate.
|
|
10
|
+
|
|
11
|
+
- Replace JSDoc blocks with a short reason comment, so the package passes the comment rules of `@shivaedev/quality`.
|
|
12
|
+
|
|
13
|
+
- Build with the `@shivaedev/quality` tsconfig presets, which target ESNext and allow only erasable TypeScript syntax.
|
|
14
|
+
|
|
15
|
+
- Type-check with TypeScript 7 only. TypeScript 6 still builds the package.
|
|
16
|
+
|
|
17
|
+
- Lint and format with the `@shivaedev/quality` Biome preset through `quality lint` at the repository root, which replaces the package's `check` script.
|
|
18
|
+
|
|
19
|
+
- Run tests through the `@shivaedev/quality` Vitest projects, which take a test's environment from its file name. Type tests are named `*.typecheck.test.ts`.
|
|
20
|
+
|
|
21
|
+
- Keep `package.json` in sort-package-json key order, checked by `quality lint`.
|
|
22
|
+
|
|
23
|
+
## 0.2.0 - 2026-09-26
|
|
24
|
+
|
|
25
|
+
### Changed
|
|
26
|
+
|
|
27
|
+
- **Breaking:** Replace `developmentCacheKey` with `clientCacheKey`. The Layer
|
|
28
|
+
no longer reads `NODE_ENV`; passing a key always enables client reuse, so pass
|
|
29
|
+
it only in the environments that should share a client. `undefined` disables
|
|
30
|
+
reuse.
|
|
31
|
+
- Type the `PgBossClient.work` handler with `Job<unknown>` instead of a
|
|
32
|
+
caller-chosen payload type; each queue's schema decodes the payload.
|
|
4
33
|
|
|
5
34
|
## 0.1.3 - 2026-09-04
|
|
6
35
|
|
package/README.md
CHANGED
|
@@ -82,14 +82,16 @@ export const JobsLive = Jobs.layer({
|
|
|
82
82
|
connectionString: databaseUrl,
|
|
83
83
|
schema: "app_jobs",
|
|
84
84
|
jobs: [emailWorker, cleanupWorker],
|
|
85
|
-
|
|
85
|
+
clientCacheKey: isDevelopment ? "app-jobs" : undefined,
|
|
86
86
|
})
|
|
87
87
|
```
|
|
88
88
|
|
|
89
|
-
`
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
`clientCacheKey` reuses and reference-counts one started client across Layer
|
|
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.
|
|
93
95
|
|
|
94
96
|
An `onError` Effect can route pg-boss background errors through application
|
|
95
97
|
logging or telemetry. Without one, errors use Effect logging.
|
package/dist/definition.d.ts
CHANGED
|
@@ -5,24 +5,24 @@ export interface JobPayloadSchema extends Schema.Top {
|
|
|
5
5
|
readonly Type: object;
|
|
6
6
|
}
|
|
7
7
|
export interface JobContext {
|
|
8
|
+
readonly expireInSeconds: number;
|
|
9
|
+
readonly heartbeatSeconds: number | null;
|
|
8
10
|
readonly id: string;
|
|
9
11
|
readonly name: string;
|
|
10
12
|
readonly signal: AbortSignal;
|
|
11
|
-
readonly expireInSeconds: number;
|
|
12
|
-
readonly heartbeatSeconds: number | null;
|
|
13
13
|
}
|
|
14
14
|
export interface QueueDefinition<Name extends string = string, Payload extends JobPayloadSchema = JobPayloadSchema> {
|
|
15
15
|
readonly _tag: "QueueDefinition";
|
|
16
|
+
readonly handle: <E, R>(handler: (payload: Schema.Schema.Type<Payload>, job: JobContext) => Effect.Effect<unknown, E, R>) => QueueWorker<Payload, R>;
|
|
16
17
|
readonly name: Name;
|
|
17
|
-
readonly schema: Payload;
|
|
18
18
|
readonly queueOptions: Omit<QueueOptions, "deadLetter">;
|
|
19
|
+
readonly schema: Payload;
|
|
19
20
|
readonly workerOptions: WorkOptions;
|
|
20
|
-
readonly handle: <E, R>(handler: (payload: Schema.Schema.Type<Payload>, job: JobContext) => Effect.Effect<unknown, E, R>) => QueueWorker<Payload, R>;
|
|
21
21
|
}
|
|
22
22
|
export interface QueueWorker<Payload extends JobPayloadSchema = JobPayloadSchema, Requirements = unknown> {
|
|
23
23
|
readonly _tag: "QueueWorker";
|
|
24
|
-
readonly queue: QueueDefinition<string, Payload>;
|
|
25
24
|
readonly handler: (payload: Schema.Schema.Type<Payload>, job: JobContext) => Effect.Effect<unknown, unknown, Requirements>;
|
|
25
|
+
readonly queue: QueueDefinition<string, Payload>;
|
|
26
26
|
}
|
|
27
27
|
export interface JobRegistration {
|
|
28
28
|
readonly _tag: "QueueWorker" | "ScheduledWorker";
|
|
@@ -32,20 +32,20 @@ export interface ScheduleDefinition<Name extends string = string> {
|
|
|
32
32
|
readonly cron: string;
|
|
33
33
|
readonly name: Name;
|
|
34
34
|
readonly queueOptions: Omit<QueueOptions, "deadLetter">;
|
|
35
|
+
readonly run: <E, R>(effect: Effect.Effect<unknown, E, R>) => ScheduledWorker<R>;
|
|
35
36
|
readonly scheduleOptions: ScheduleOptions;
|
|
36
37
|
readonly workerOptions: WorkOptions;
|
|
37
|
-
readonly run: <E, R>(effect: Effect.Effect<unknown, E, R>) => ScheduledWorker<R>;
|
|
38
38
|
}
|
|
39
39
|
export interface ScheduledWorker<Requirements = unknown> {
|
|
40
40
|
readonly _tag: "ScheduledWorker";
|
|
41
|
-
readonly schedule: ScheduleDefinition;
|
|
42
41
|
readonly effect: Effect.Effect<unknown, unknown, Requirements>;
|
|
42
|
+
readonly schedule: ScheduleDefinition;
|
|
43
43
|
}
|
|
44
44
|
export type RegistrationRequirements<Registrations extends readonly JobRegistration[]> = Registrations[number] extends infer Registration ? Registration extends QueueWorker<infer Payload, infer Requirements> ? Requirements | Payload["DecodingServices"] : Registration extends ScheduledWorker<infer Requirements> ? Requirements : never : never;
|
|
45
45
|
export interface DefineQueueOptions<Name extends string, Payload extends JobPayloadSchema> {
|
|
46
46
|
readonly name: Name;
|
|
47
|
-
readonly schema: Payload;
|
|
48
47
|
readonly queue?: Omit<QueueOptions, "deadLetter">;
|
|
48
|
+
readonly schema: Payload;
|
|
49
49
|
readonly worker?: WorkOptions;
|
|
50
50
|
}
|
|
51
51
|
export declare const defineQueue: <const Name extends string, const Payload extends JobPayloadSchema>(options: DefineQueueOptions<Name, Payload>) => QueueDefinition<Name, Payload>;
|
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,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE/E,MAAM,WAAW,gBAAiB,SAAQ,MAAM,CAAC,GAAG;IACnD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../src/definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE/E,MAAM,WAAW,gBAAiB,SAAQ,MAAM,CAAC,GAAG;IACnD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC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AE,OAAO,SAAS,gBAAgB;IACxF,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;IAClD,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,EAC5F,SAAS,kBAAkB,CAAC,IAAI,EAAE,OAAO,CAAC,KACxC,eAAe,CAAC,IAAI,EAAE,OAAO,CAe/B,CAAC;AAEF,MAAM,WAAW,qBAAqB,CAAC,IAAI,SAAS,MAAM;IACzD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;IAClD,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,EAAE,SAAS,qBAAqB,CAAC,IAAI,CAAC,KAAG,kBAAkB,CAAC,IAAI,CAgBvH,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,KAAK,GAAG,CAAC,OAAO,CAAC,KAAG,UAM7C,CAAC"}
|
package/dist/definition.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
export const defineQueue = (options) => {
|
|
2
2
|
const definition = {
|
|
3
3
|
_tag: "QueueDefinition",
|
|
4
|
-
name: options.name,
|
|
5
|
-
queueOptions: Object.freeze({ ...options.queue }),
|
|
6
|
-
schema: options.schema,
|
|
7
|
-
workerOptions: Object.freeze({ batchSize: 1, ...options.worker }),
|
|
8
4
|
handle: (handler) => Object.freeze({
|
|
9
5
|
_tag: "QueueWorker",
|
|
10
6
|
handler,
|
|
11
7
|
queue: definition,
|
|
12
8
|
}),
|
|
9
|
+
name: options.name,
|
|
10
|
+
queueOptions: Object.freeze({ ...options.queue }),
|
|
11
|
+
schema: options.schema,
|
|
12
|
+
workerOptions: Object.freeze({ batchSize: 1, ...options.worker }),
|
|
13
13
|
};
|
|
14
14
|
return Object.freeze(definition);
|
|
15
15
|
};
|
|
@@ -19,13 +19,13 @@ export const defineSchedule = (options) => {
|
|
|
19
19
|
cron: options.cron,
|
|
20
20
|
name: options.name,
|
|
21
21
|
queueOptions: Object.freeze({ ...options.queue }),
|
|
22
|
-
scheduleOptions: Object.freeze({ tz: "UTC", ...options.schedule }),
|
|
23
|
-
workerOptions: Object.freeze({ batchSize: 1, ...options.worker }),
|
|
24
22
|
run: (effect) => Object.freeze({
|
|
25
23
|
_tag: "ScheduledWorker",
|
|
26
24
|
effect,
|
|
27
25
|
schedule: definition,
|
|
28
26
|
}),
|
|
27
|
+
scheduleOptions: Object.freeze({ tz: "UTC", ...options.schedule }),
|
|
28
|
+
workerOptions: Object.freeze({ batchSize: 1, ...options.worker }),
|
|
29
29
|
};
|
|
30
30
|
return Object.freeze(definition);
|
|
31
31
|
};
|
package/dist/definition.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../src/definition.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../src/definition.ts"],"names":[],"mappings":"AAoEA,MAAM,CAAC,MAAM,WAAW,GAAG,CAC1B,OAA0C,EACT,EAAE;IACnC,MAAM,UAAU,GAAmC;QAClD,IAAI,EAAE,iBAAiB;QACvB,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,CACnB,MAAM,CAAC,MAAM,CAAC;YACb,IAAI,EAAE,aAAsB;YAC5B,OAAO;YACP,KAA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AC,gBAAgB;IACtC,EAAE,EAAE,GAAG,CAAC,EAAE;IACV,IAAI,EAAE,GAAG,CAAC,IAAI;IACd,MAAM,EAAE,GAAG,CAAC,MAAM;CAClB,CAAC,CAAC"}
|
package/dist/error.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ declare const PgBossError_base: new <A extends Record<string, any> = {}>(args: i
|
|
|
5
5
|
} & Readonly<A>;
|
|
6
6
|
export declare class PgBossError extends PgBossError_base<{
|
|
7
7
|
readonly operation: PgBossOperation;
|
|
8
|
-
readonly queue?: string;
|
|
8
|
+
readonly queue?: string | undefined;
|
|
9
9
|
readonly original: Redacted.Redacted<unknown>;
|
|
10
10
|
}> {
|
|
11
11
|
}
|
package/dist/error.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAExC,MAAM,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAExC,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,QAAQ,GAAG,UAAU,GAAG,OAAO,GAAG,MAAM,CAAC;;;;AAEnF,qBAAa,WAAY,SAAQ,iBAAgC;IAChE,QAAQ,CAAC,SAAS,EAAE,eAAe,CAAC;IACpC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;CAC9C,CAAC;CAAG;;;;AAEL,qBAAa,kBAAmB,SAAQ,wBAAuC;IAC9E,QAAQ,CAAC,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAAC;IACxC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;CAC9C,CAAC;CAAG;AAEL,eAAO,MAAM,aAAa,GAAI,WAAW,eAAe,EAAE,OAAO,OAAO,EAAE,QAAQ,MAAM,KAAG,WAKxF,CAAC"}
|
package/dist/error.js
CHANGED
|
@@ -5,7 +5,7 @@ export class PgBossPayloadError extends Data.TaggedError("PgBossPayloadError") {
|
|
|
5
5
|
}
|
|
6
6
|
export const toPgBossError = (operation, error, queue) => new PgBossError({
|
|
7
7
|
operation,
|
|
8
|
-
queue,
|
|
9
8
|
original: Redacted.make(error),
|
|
9
|
+
queue,
|
|
10
10
|
});
|
|
11
11
|
//# sourceMappingURL=error.js.map
|
package/dist/error.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAIxC,MAAM,OAAO,WAAY,SAAQ,IAAI,CAAC,WAAW,CAAC,aAAa,CAI7D;CAAG;AAEL,MAAM,OAAO,kBAAmB,SAAQ,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAI3E;CAAG;AAEL,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,SAA0B,EAAE,KAAc,EAAE,KAAc,EAAe,EAAE,CACxG,IAAI,WAAW,CAAC;IACf,SAAS;IACT,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC;IAC9B,KAAK;CACL,CAAC,CAAC"}
|
package/dist/health.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../src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I,EAAE,SAAS,WAAW,EAAE,CAAC;IACtC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC5B;AAED,eAAO,MAAM,mBAAmB,GAAI,WAAW,MAAM,KAAG,MAA4B,CAAC"}
|
package/dist/health.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"health.js","sourceRoot":"","sources":["../src/health.ts"],"names":[],"mappings":"AAkBA,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,SAAiB,EAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"health.js","sourceRoot":"","sources":["../src/health.ts"],"names":[],"mappings":"AAkBA,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,SAAiB,EAAU,EAAE,CAAC,GAAG,SAAS,MAAM,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export
|
|
5
|
-
export { makePgBoss, type PgBossDefinition, type PgBossLayerOptions, type PgBossService, } from "./service.
|
|
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
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,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,
|
|
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.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
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"}
|
|
@@ -2,14 +2,14 @@ import type { ConstructorOptions, Job, Queue, QueueResult, ScheduleOptions, Send
|
|
|
2
2
|
export interface PgBossClient {
|
|
3
3
|
readonly createQueue: (name: string, options?: Omit<Queue, "name">) => Promise<void>;
|
|
4
4
|
readonly getQueue: (name: string) => Promise<QueueResult | null>;
|
|
5
|
+
readonly off: (event: "error", listener: (error: Error) => void) => unknown;
|
|
5
6
|
readonly offWork: (name: string) => Promise<void>;
|
|
6
7
|
readonly on: (event: "error", listener: (error: Error) => void) => unknown;
|
|
7
|
-
readonly off: (event: "error", listener: (error: Error) => void) => unknown;
|
|
8
8
|
readonly schedule: (name: string, cron: string, data?: object | null, options?: ScheduleOptions) => Promise<void>;
|
|
9
9
|
readonly send: (name: string, data?: object | null, options?: SendOptions) => Promise<string | null>;
|
|
10
10
|
readonly start: () => Promise<unknown>;
|
|
11
11
|
readonly stop: (options?: StopOptions) => Promise<void>;
|
|
12
|
-
readonly work:
|
|
12
|
+
readonly work: (name: string, options: WorkOptions, handler: (jobs: readonly Job<unknown>[]) => Promise<unknown>) => Promise<string>;
|
|
13
13
|
}
|
|
14
14
|
export type PgBossClientFactory = (options: ConstructorOptions) => PgBossClient;
|
|
15
15
|
export declare const defaultClientFactory: PgBossClientFactory;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/internal/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/internal/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAk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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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/internal/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/internal/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAiBjC,MAAM,CAAC,MAAM,oBAAoB,GAAwB,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
-
import { type JobsHealth } from "
|
|
3
|
-
import type { PgBossClient } from "./client.
|
|
4
|
-
export declare const healthFor: (client: PgBossClient, names: readonly string[]) => Effect.Effect<JobsHealth, import("
|
|
2
|
+
import { type JobsHealth } from "#health.ts";
|
|
3
|
+
import type { PgBossClient } from "./client.ts";
|
|
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;AAEhC,OAAO,
|
|
1
|
+
{"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../src/internal/health.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAuB,KAAK,UAAU,EAAoB,MAAM,YAAY,CAAC;AACpF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,eAAO,MAAM,SAAS,GAAI,QAAQ,YAAY,EAAE,OAAO,SAAS,MAAM,EAAE,KAAG,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,OAAO,WAAW,EAAE,WAAW,CA4BlI,CAAC"}
|
package/dist/internal/health.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
-
import { toPgBossError } from "
|
|
3
|
-
import { deadLetterQueueName
|
|
2
|
+
import { toPgBossError } from "#error.ts";
|
|
3
|
+
import { deadLetterQueueName } from "#health.ts";
|
|
4
4
|
export const healthFor = (client, names) => Effect.forEach(names, (name) => Effect.tryPromise({
|
|
5
|
+
catch: (error) => toPgBossError("health", error, name),
|
|
5
6
|
try: async () => {
|
|
6
|
-
const [queue, deadLetter] = await Promise.all([
|
|
7
|
-
client.getQueue(name),
|
|
8
|
-
client.getQueue(deadLetterQueueName(name)),
|
|
9
|
-
]);
|
|
7
|
+
const [queue, deadLetter] = await Promise.all([client.getQueue(name), client.getQueue(deadLetterQueueName(name))]);
|
|
10
8
|
return {
|
|
11
9
|
activeCount: queue?.activeCount ?? 0,
|
|
12
10
|
deadLetteredCount: deadLetter?.queuedCount ?? 0,
|
|
@@ -16,7 +14,6 @@ export const healthFor = (client, names) => Effect.forEach(names, (name) => Effe
|
|
|
16
14
|
readyCount: queue?.readyCount ?? 0,
|
|
17
15
|
};
|
|
18
16
|
},
|
|
19
|
-
catch: (error) => toPgBossError("health", error, name),
|
|
20
17
|
}), { concurrency: "unbounded" }).pipe(Effect.map((jobs) => ({
|
|
21
18
|
activeTotal: jobs.reduce((sum, job) => sum + job.activeCount, 0),
|
|
22
19
|
deadLetteredTotal: jobs.reduce((sum, job) => sum + job.deadLetteredCount, 0),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"health.js","sourceRoot":"","sources":["../../src/internal/health.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"health.js","sourceRoot":"","sources":["../../src/internal/health.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAqC,MAAM,YAAY,CAAC;AAGpF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,MAAoB,EAAE,KAAwB,EAA8D,EAAE,CACvI,MAAM,CAAC,OAAO,CACb,KAAK,EACL,CAAC,IAAI,EAAE,EAAE,CACR,MAAM,CAAC,UAAU,CAAC;IACjB,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC;IACtD,GAAG,EAAE,KAAK,IAA0B,EAAE;QACrC,MAAM,CAAC,KAAK,EAAE,UAAU,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACnH,OAAO;YACN,WAAW,EAAE,KAAK,EAAE,WAAW,IAAI,CAAC;YACpC,iBAAiB,EAAE,UAAU,EAAE,WAAW,IAAI,CAAC;YAC/C,WAAW,EAAE,KAAK,EAAE,WAAW,IAAI,CAAC;YACpC,IAAI;YACJ,WAAW,EAAE,KAAK,EAAE,WAAW,IAAI,CAAC;YACpC,UAAU,EAAE,KAAK,EAAE,UAAU,IAAI,CAAC;SAClC,CAAC;IACH,CAAC;CACD,CAAC,EACH,EAAE,WAAW,EAAE,WAAW,EAAE,CAC5B,CAAC,IAAI,CACL,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACrB,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;IAChE,iBAAiB,EAAE,IAAI,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,16 +1,16 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
2
|
import type { ConstructorOptions, StopOptions } from "pg-boss";
|
|
3
|
-
import { type PgBossClient, type PgBossClientFactory } from "./client.
|
|
3
|
+
import { type PgBossClient, type PgBossClientFactory } from "./client.ts";
|
|
4
4
|
export interface AcquireClientOptions {
|
|
5
|
-
readonly
|
|
5
|
+
readonly clientCacheKey?: string | symbol | undefined;
|
|
6
|
+
readonly clientFactory?: PgBossClientFactory | undefined;
|
|
6
7
|
readonly constructor: ConstructorOptions;
|
|
7
|
-
readonly developmentCacheKey?: string | symbol;
|
|
8
8
|
}
|
|
9
9
|
export interface AcquiredClient {
|
|
10
|
-
readonly client: PgBossClient;
|
|
11
10
|
readonly cacheKey?: string | symbol;
|
|
11
|
+
readonly client: PgBossClient;
|
|
12
12
|
readonly reused: boolean;
|
|
13
13
|
}
|
|
14
|
-
export declare const acquireClient: (options: AcquireClientOptions) => Effect.Effect<AcquiredClient, import("
|
|
14
|
+
export declare const acquireClient: (options: AcquireClientOptions) => Effect.Effect<AcquiredClient, import("#error.ts").PgBossError>;
|
|
15
15
|
export declare const releaseClient: (acquired: AcquiredClient, stopOptions?: StopOptions) => Effect.Effect<void>;
|
|
16
16
|
//# sourceMappingURL=lifecycle.d.ts.map
|
|
@@ -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;AAE/D,OAAO,
|
|
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;AAE/D,OAAO,EAAwB,KAAK,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAuBhG,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,GAAI,SAAS,oBAAoB,KAAG,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE,OAAO,WAAW,EAAE,WAAW,CA6CxH,CAAC;AAEJ,eAAO,MAAM,aAAa,GAAI,UAAU,cAAc,EAAE,cAAc,WAAW,KAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAoB7C,CAAC"}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
-
import { toPgBossError } from "
|
|
3
|
-
import { defaultClientFactory
|
|
2
|
+
import { toPgBossError } from "#error.ts";
|
|
3
|
+
import { defaultClientFactory } from "./client.js";
|
|
4
4
|
const CacheKey = Symbol.for("@shivaedev/effect-pg-boss/client-cache");
|
|
5
|
-
const
|
|
6
|
-
const clientCache =
|
|
7
|
-
|
|
5
|
+
const sharedCache = Reflect.get(globalThis, CacheKey);
|
|
6
|
+
const clientCache = sharedCache instanceof Map ? sharedCache : new Map();
|
|
7
|
+
Reflect.set(globalThis, CacheKey, clientCache);
|
|
8
|
+
const isCachedClient = (value) => typeof value === "object"
|
|
9
|
+
&& value !== null
|
|
10
|
+
&& Reflect.get(value, "client") instanceof Promise
|
|
11
|
+
&& typeof Reflect.get(value, "references") === "number";
|
|
12
|
+
const cachedClient = (key) => {
|
|
13
|
+
const entry = clientCache.get(key);
|
|
14
|
+
return isCachedClient(entry) ? entry : undefined;
|
|
15
|
+
};
|
|
8
16
|
const startClient = (options) => {
|
|
9
17
|
const client = (options.clientFactory ?? defaultClientFactory)(options.constructor);
|
|
10
18
|
return client.start().then(() => client, async (error) => {
|
|
@@ -18,17 +26,16 @@ const startClient = (options) => {
|
|
|
18
26
|
});
|
|
19
27
|
};
|
|
20
28
|
export const acquireClient = (options) => Effect.tryPromise({
|
|
29
|
+
catch: (error) => toPgBossError("start", error),
|
|
21
30
|
try: async () => {
|
|
22
|
-
const cacheKey =
|
|
23
|
-
? undefined
|
|
24
|
-
: options.developmentCacheKey;
|
|
31
|
+
const cacheKey = options.clientCacheKey;
|
|
25
32
|
if (cacheKey === undefined) {
|
|
26
33
|
return {
|
|
27
34
|
client: await startClient(options),
|
|
28
35
|
reused: false,
|
|
29
36
|
};
|
|
30
37
|
}
|
|
31
|
-
const existing =
|
|
38
|
+
const existing = cachedClient(cacheKey);
|
|
32
39
|
if (existing !== undefined) {
|
|
33
40
|
existing.references += 1;
|
|
34
41
|
try {
|
|
@@ -56,28 +63,30 @@ export const acquireClient = (options) => Effect.tryPromise({
|
|
|
56
63
|
};
|
|
57
64
|
}
|
|
58
65
|
catch (error) {
|
|
59
|
-
if (clientCache.get(cacheKey) === entry)
|
|
66
|
+
if (clientCache.get(cacheKey) === entry) {
|
|
60
67
|
clientCache.delete(cacheKey);
|
|
68
|
+
}
|
|
61
69
|
throw error;
|
|
62
70
|
}
|
|
63
71
|
},
|
|
64
|
-
catch: (error) => toPgBossError("start", error),
|
|
65
72
|
});
|
|
66
73
|
export const releaseClient = (acquired, stopOptions) => Effect.tryPromise({
|
|
74
|
+
catch: (error) => toPgBossError("stop", error),
|
|
67
75
|
try: async () => {
|
|
68
76
|
if (acquired.cacheKey === undefined) {
|
|
69
77
|
await acquired.client.stop(stopOptions);
|
|
70
78
|
return;
|
|
71
79
|
}
|
|
72
|
-
const entry =
|
|
73
|
-
if (entry === undefined)
|
|
80
|
+
const entry = cachedClient(acquired.cacheKey);
|
|
81
|
+
if (entry === undefined) {
|
|
74
82
|
return;
|
|
83
|
+
}
|
|
75
84
|
entry.references -= 1;
|
|
76
|
-
if (entry.references > 0)
|
|
85
|
+
if (entry.references > 0) {
|
|
77
86
|
return;
|
|
87
|
+
}
|
|
78
88
|
clientCache.delete(acquired.cacheKey);
|
|
79
89
|
await acquired.client.stop(stopOptions);
|
|
80
90
|
},
|
|
81
|
-
catch: (error) => toPgBossError("stop", error),
|
|
82
91
|
}).pipe(Effect.catch((error) => Effect.logError(error)));
|
|
83
92
|
//# sourceMappingURL=lifecycle.js.map
|
|
@@ -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,aAAa,EAAE,MAAM,
|
|
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,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAA+C,MAAM,aAAa,CAAC;AAOhG,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,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;AAE/C,MAAM,cAAc,GAAG,CAAC,KAAc,EAAyB,EAAE,CAChE,OAAO,KAAK,KAAK,QAAQ;OACtB,KAAK,KAAK,IAAI;OACd,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,YAAY,OAAO;OAC/C,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,YAAY,CAAC,KAAK,QAAQ,CAAC;AAEzD,MAAM,YAAY,GAAG,CAA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AE,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,7 @@
|
|
|
1
|
-
import { Effect } from "effect";
|
|
2
|
-
import { type JobRegistration } from "
|
|
3
|
-
import type { PgBossClient } from "./client.
|
|
1
|
+
import { type Context, Effect } from "effect";
|
|
2
|
+
import { type JobRegistration } from "#definition.ts";
|
|
3
|
+
import type { PgBossClient } from "./client.ts";
|
|
4
|
+
export declare const registrationName: (registration: JobRegistration) => string;
|
|
4
5
|
export declare const registrationNames: (registrations: readonly JobRegistration[]) => readonly string[];
|
|
5
|
-
export declare const registerJobs: <R>(client: PgBossClient, registrations: readonly JobRegistration[], context:
|
|
6
|
+
export declare const registerJobs: <R>(client: PgBossClient, registrations: readonly JobRegistration[], context: Context.Context<R>, replaceWorkers: boolean) => Effect.Effect<void, import("#error.ts").PgBossError>;
|
|
6
7
|
//# sourceMappingURL=register.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../src/internal/register.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAoB,MAAM,QAAQ,CAAC;
|
|
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,KAAK,eAAe,EAAsD,MAAM,gBAAgB,CAAC;AAG1G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAYhD,eAAO,MAAM,gBAAgB,GAAI,cAAc,eAAe,KAAG,MAQhE,CAAC;AAqEF,eAAO,MAAM,iBAAiB,GAAI,eAAe,SAAS,eAAe,EAAE,KAAG,SAAS,MAAM,EAM5F,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,CAAC,EAC7B,QAAQ,YAAY,EACpB,eAAe,SAAS,eAAe,EAAE,EACzC,SAAS,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAC3B,gBAAgB,OAAO,KACrB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,WAAW,EAAE,WAAW,CAcnD,CAAC"}
|
|
@@ -1,12 +1,26 @@
|
|
|
1
1
|
import { Effect, Redacted, Schema } from "effect";
|
|
2
|
-
import { jobContext
|
|
3
|
-
import { PgBossPayloadError, toPgBossError } from "
|
|
4
|
-
import { deadLetterQueueName } from "
|
|
2
|
+
import { jobContext } from "#definition.ts";
|
|
3
|
+
import { PgBossPayloadError, toPgBossError } from "#error.ts";
|
|
4
|
+
import { deadLetterQueueName } from "#health.ts";
|
|
5
5
|
const queueOptions = (options) => ({
|
|
6
6
|
retryBackoff: true,
|
|
7
7
|
retryLimit: 3,
|
|
8
8
|
...options,
|
|
9
9
|
});
|
|
10
|
+
const isQueueWorker = (registration) => registration._tag === "QueueWorker";
|
|
11
|
+
const isScheduledWorker = (registration) => registration._tag === "ScheduledWorker";
|
|
12
|
+
export const registrationName = (registration) => {
|
|
13
|
+
if (isQueueWorker(registration)) {
|
|
14
|
+
return registration.queue.name;
|
|
15
|
+
}
|
|
16
|
+
if (isScheduledWorker(registration)) {
|
|
17
|
+
return registration.schedule.name;
|
|
18
|
+
}
|
|
19
|
+
throw new TypeError(`Unknown pg-boss registration: ${registration._tag}`);
|
|
20
|
+
};
|
|
21
|
+
function workerContext(context) {
|
|
22
|
+
return context;
|
|
23
|
+
}
|
|
10
24
|
const runQueueWorker = (worker, job, context) => Effect.runPromise(Schema.decodeUnknownEffect(worker.queue.schema)(job.data).pipe(Effect.mapError((error) => new PgBossPayloadError({
|
|
11
25
|
direction: "decode",
|
|
12
26
|
original: Redacted.make(error),
|
|
@@ -15,23 +29,26 @@ const runQueueWorker = (worker, job, context) => Effect.runPromise(Schema.decode
|
|
|
15
29
|
const registerQueue = async (client, worker, context, replaceWorker) => {
|
|
16
30
|
const name = worker.queue.name;
|
|
17
31
|
const deadLetter = deadLetterQueueName(name);
|
|
18
|
-
if (replaceWorker)
|
|
32
|
+
if (replaceWorker) {
|
|
19
33
|
await client.offWork(name);
|
|
34
|
+
}
|
|
20
35
|
await client.createQueue(deadLetter);
|
|
21
36
|
await client.createQueue(name, {
|
|
22
37
|
...queueOptions(worker.queue.queueOptions),
|
|
23
38
|
deadLetter,
|
|
24
39
|
});
|
|
25
40
|
await client.work(name, worker.queue.workerOptions, async (jobs) => {
|
|
26
|
-
for (const job of jobs)
|
|
41
|
+
for (const job of jobs) {
|
|
27
42
|
await runQueueWorker(worker, job, context);
|
|
43
|
+
}
|
|
28
44
|
});
|
|
29
45
|
};
|
|
30
46
|
const registerSchedule = async (client, worker, context, replaceWorker) => {
|
|
31
47
|
const { schedule } = worker;
|
|
32
48
|
const deadLetter = deadLetterQueueName(schedule.name);
|
|
33
|
-
if (replaceWorker)
|
|
49
|
+
if (replaceWorker) {
|
|
34
50
|
await client.offWork(schedule.name);
|
|
51
|
+
}
|
|
35
52
|
await client.createQueue(deadLetter);
|
|
36
53
|
await client.createQueue(schedule.name, {
|
|
37
54
|
...queueOptions(schedule.queueOptions),
|
|
@@ -47,26 +64,25 @@ const registerSchedule = async (client, worker, context, replaceWorker) => {
|
|
|
47
64
|
await client.schedule(schedule.name, schedule.cron, null, schedule.scheduleOptions);
|
|
48
65
|
};
|
|
49
66
|
export const registrationNames = (registrations) => {
|
|
50
|
-
const names = registrations.map(
|
|
51
|
-
? registration.queue.name
|
|
52
|
-
: registration.schedule.name);
|
|
67
|
+
const names = registrations.map(registrationName);
|
|
53
68
|
if (new Set(names).size !== names.length) {
|
|
54
69
|
throw new TypeError("pg-boss job names must be unique");
|
|
55
70
|
}
|
|
56
71
|
return names;
|
|
57
72
|
};
|
|
58
73
|
export const registerJobs = (client, registrations, context, replaceWorkers) => Effect.tryPromise({
|
|
74
|
+
catch: (error) => toPgBossError("register", error),
|
|
59
75
|
try: async () => {
|
|
60
76
|
registrationNames(registrations);
|
|
77
|
+
const provided = workerContext(context);
|
|
61
78
|
for (const registration of registrations) {
|
|
62
|
-
if (registration
|
|
63
|
-
await registerQueue(client, registration,
|
|
79
|
+
if (isQueueWorker(registration)) {
|
|
80
|
+
await registerQueue(client, registration, provided, replaceWorkers);
|
|
64
81
|
}
|
|
65
|
-
else {
|
|
66
|
-
await registerSchedule(client, registration,
|
|
82
|
+
else if (isScheduledWorker(registration)) {
|
|
83
|
+
await registerSchedule(client, registration, provided, replaceWorkers);
|
|
67
84
|
}
|
|
68
85
|
}
|
|
69
86
|
},
|
|
70
|
-
catch: (error) => toPgBossError("register", error),
|
|
71
87
|
});
|
|
72
88
|
//# sourceMappingURL=register.js.map
|