@pikku/queue-pg-boss 0.12.10 → 0.12.12
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/dist/pg-boss-queue-service.d.ts +1 -1
- package/package.json +19 -11
- package/CHANGELOG.md +0 -409
- package/run-tests.sh +0 -56
- package/src/index.ts +0 -19
- package/src/pg-boss-queue-service.test.ts +0 -83
- package/src/pg-boss-queue-service.ts +0 -113
- package/src/pg-boss-queue-worker.test.ts +0 -93
- package/src/pg-boss-queue-worker.ts +0 -231
- package/src/pg-boss-scheduler-service.ts +0 -192
- package/src/pg-boss-service-factory.ts +0 -85
- package/src/utils.ts +0 -87
- package/tsconfig.json +0 -17
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PgBoss, Request as PgBossRequest } from 'pg-boss';
|
|
2
2
|
import type { QueueJob, QueueService } from '@pikku/core/queue';
|
|
3
3
|
import type { JobOptions } from '@pikku/core/queue';
|
|
4
|
-
export declare const mapPikkuJobToPgBoss: (options?: JobOptions) => PgBossRequest[
|
|
4
|
+
export declare const mapPikkuJobToPgBoss: (options?: JobOptions) => PgBossRequest['options'];
|
|
5
5
|
/**
|
|
6
6
|
* pg-boss/PostgreSQL queue service implementation
|
|
7
7
|
* Supports job results, retries, and PostgreSQL-based queuing
|
package/package.json
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pikku/queue-pg-boss",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.12",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/pikkujs/pikku.git",
|
|
7
|
+
"directory": "packages/services/queue-pg-boss"
|
|
8
|
+
},
|
|
4
9
|
"description": "pg-boss queue, worker and scheduler services for Pikku, backed by Postgres",
|
|
5
10
|
"author": "yasser.fadl@gmail.com",
|
|
6
11
|
"license": "MIT",
|
|
@@ -11,20 +16,23 @@
|
|
|
11
16
|
"tsc": "tsc",
|
|
12
17
|
"test": "bash run-tests.sh",
|
|
13
18
|
"ncu": "npx npm-check-updates",
|
|
14
|
-
"build": "tsc -b",
|
|
19
|
+
"build": "bun run clean && tsc -b",
|
|
15
20
|
"release": "npm run build && npm test",
|
|
16
|
-
"prepublishOnly": "
|
|
21
|
+
"prepublishOnly": "bun run build",
|
|
22
|
+
"clean": "rm -rf dist tsconfig.tsbuildinfo"
|
|
17
23
|
},
|
|
18
24
|
"peerDependencies": {
|
|
19
|
-
"@pikku/core": "^0.12.
|
|
25
|
+
"@pikku/core": "^0.12.144"
|
|
20
26
|
},
|
|
21
27
|
"dependencies": {
|
|
22
|
-
"pg-boss": "^12.
|
|
23
|
-
},
|
|
24
|
-
"devDependencies": {
|
|
25
|
-
"typescript": "^6.0.3"
|
|
28
|
+
"pg-boss": "^12.38.0"
|
|
26
29
|
},
|
|
27
30
|
"exports": {
|
|
28
|
-
".": "./dist/index.js"
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
+
".": "./dist/index.js",
|
|
32
|
+
"./package.json": "./package.json"
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"dist",
|
|
36
|
+
"!dist/**/*.tsbuildinfo"
|
|
37
|
+
]
|
|
38
|
+
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,409 +0,0 @@
|
|
|
1
|
-
## 0.12.10
|
|
2
|
-
|
|
3
|
-
### Patch Changes
|
|
4
|
-
|
|
5
|
-
- 266e3bc: One door per name: `@pikku/core/ecosystem/*` and the package root are gone
|
|
6
|
-
|
|
7
|
-
`@pikku/core` published every module twice. `ecosystem/http` re-exported
|
|
8
|
-
`./http`, `ecosystem/services` re-exported `./services`, and a name was
|
|
9
|
-
reachable through either — so every addition had to be made in two places, and a
|
|
10
|
-
consumer's import said nothing about what it actually used. The package root was
|
|
11
|
-
the same problem at a larger scale: a single barrel of 206 names that no bundler
|
|
12
|
-
could take apart, and the one specifier that revealed nothing at all.
|
|
13
|
-
|
|
14
|
-
Both are deleted. Every name now lives on the subpath that owns it, and every
|
|
15
|
-
import carries that subpath — `@pikku/core/http`, `@pikku/core/services`,
|
|
16
|
-
`@pikku/core/errors`, `@pikku/core/types`.
|
|
17
|
-
|
|
18
|
-
Deleting the facades meant the raw subpaths had to become a superset of them,
|
|
19
|
-
which they were not: the facade tree had accumulated 25 names with no raw home
|
|
20
|
-
and about 26 more filed under a different area than the module they came from.
|
|
21
|
-
Those names moved to the area that owns them, and three areas were published as
|
|
22
|
-
new entry points rather than left on a root that is going away — `./types` (the
|
|
23
|
-
shared type surface, the largest single destination), `./state` and
|
|
24
|
-
`./classification`.
|
|
25
|
-
|
|
26
|
-
`./classification` is one door onto one subject: what a value is and how it must
|
|
27
|
-
be handled. Its three halves would each have been an entry point — the brands
|
|
28
|
-
and manifest types, the stored-form helpers (`hashToken`, `unsafeAsSealed` and
|
|
29
|
-
friends), and `SecretValue` — split by whether a name happens to be a type or a
|
|
30
|
-
value, which is the same defect as the facades. The duration and versioned-id
|
|
31
|
-
helpers went to `./utils`, which already published, and `PikkuRequest` went to
|
|
32
|
-
`./function`: it is the transport-agnostic request base, not an HTTP one — HTTP
|
|
33
|
-
has `PikkuHTTPAbstractRequest`, and the only thing outside core that extends
|
|
34
|
-
`PikkuRequest` is Azure's timer request.
|
|
35
|
-
|
|
36
|
-
`./types` inherited the root barrel's habit before it inherited its contents, so
|
|
37
|
-
the names with an owner elsewhere were moved off it. The middleware types and the
|
|
38
|
-
five middleware factories — `pikkuMiddleware`, `pikkuMiddlewareFactory`,
|
|
39
|
-
`pikkuChannelMiddleware`, `pikkuChannelMiddlewareFactory` and
|
|
40
|
-
`pikkuAgentMiddleware`, runtime values on a types entry point — are now
|
|
41
|
-
`@pikku/core/middleware`; the function meta types are `@pikku/core/function`;
|
|
42
|
-
`SerializedError` is `@pikku/core/errors`; and the generic TypeScript helpers
|
|
43
|
-
(`MakeRequired`, `PickRequired`, `PickOptional`, `RequireAtLeastOne`,
|
|
44
|
-
`JSONPrimitive`, `JSONValue`) are `@pikku/core/utils`. What is left on `./types`
|
|
45
|
-
is the vocabulary the wirings share, which no single module owns.
|
|
46
|
-
|
|
47
|
-
`pikku` was itself a root barrel — `export * from '@pikku/core'` — and
|
|
48
|
-
now exports only the services it bundles.
|
|
49
|
-
|
|
50
|
-
One module survives at the old specifier, and only for the bootstrap:
|
|
51
|
-
`packages/cli` is generated by the _published_ CLI pinned in its `build.sh`, and
|
|
52
|
-
that CLI still writes a bare `@pikku/core` into the files it generates for the
|
|
53
|
-
CLI itself. `bootstrap-compat/root.ts` carries the eight types it names, a test
|
|
54
|
-
in core fails if that list grows, and it goes when the pin moves to a CLI
|
|
55
|
-
released from this branch. The adapter names the pinned CLI reaches for —
|
|
56
|
-
`pikkuState` and `CreateWireServices` — are rewritten to `@pikku/core/state` and
|
|
57
|
-
`@pikku/core/types` by the same `build.sh` patch pass, so no second shim is
|
|
58
|
-
needed for them.
|
|
59
|
-
|
|
60
|
-
A guard test keeps the root shut: it parses imports and rejects a bare
|
|
61
|
-
`@pikku/core` rather than grepping for it, because several tests hold a user's
|
|
62
|
-
file as a template literal, where `import … from '@pikku/core'` is fixture text
|
|
63
|
-
rather than an import this repo makes.
|
|
64
|
-
|
|
65
|
-
An agent scaffold a project generated under an older CLI is refreshed rather
|
|
66
|
-
than left to fail: `pikku all` already deleted one importing an entry point
|
|
67
|
-
`@pikku/core` no longer publishes, and the `#pikku` hub joins that list.
|
|
68
|
-
Without it a project that scaffolds the agent endpoint but
|
|
69
|
-
declares no agents keeps the old file forever — the generator that would rewrite
|
|
70
|
-
it only runs when agents exist, and the file being present is what stops it
|
|
71
|
-
being regenerated as missing.
|
|
72
|
-
|
|
73
|
-
`pikku new addon` also wrote a tsconfig `paths` map naming only the deleted hub.
|
|
74
|
-
An addon's `imports` map points into `dist`, so `paths` is what resolves
|
|
75
|
-
`#pikku/<leaf>` for the addon's own source build — it now names the two leaf
|
|
76
|
-
patterns, in both the addon and its test harness.
|
|
77
|
-
|
|
78
|
-
- 6eef0a0: Bump every dependency to its latest compatible minor/patch across the monorepo.
|
|
79
|
-
- Updated dependencies [7722ceb]
|
|
80
|
-
- Updated dependencies [375c1ff]
|
|
81
|
-
- Updated dependencies [02a70cd]
|
|
82
|
-
- Updated dependencies [aeef159]
|
|
83
|
-
- Updated dependencies [a281de6]
|
|
84
|
-
- Updated dependencies [266e3bc]
|
|
85
|
-
- Updated dependencies [02a70cd]
|
|
86
|
-
- Updated dependencies [786dae5]
|
|
87
|
-
- Updated dependencies [6eef0a0]
|
|
88
|
-
- Updated dependencies [3561d67]
|
|
89
|
-
- Updated dependencies [a91c433]
|
|
90
|
-
- Updated dependencies [02a70cd]
|
|
91
|
-
- Updated dependencies [9537f74]
|
|
92
|
-
- Updated dependencies [2b57ca8]
|
|
93
|
-
- Updated dependencies [266e3bc]
|
|
94
|
-
- Updated dependencies [9fce0f1]
|
|
95
|
-
- Updated dependencies [83683a0]
|
|
96
|
-
- Updated dependencies [456c88b]
|
|
97
|
-
- Updated dependencies [456c88b]
|
|
98
|
-
- Updated dependencies [c127273]
|
|
99
|
-
- @pikku/core@0.12.85
|
|
100
|
-
|
|
101
|
-
## 0.12.9
|
|
102
|
-
|
|
103
|
-
### Patch Changes
|
|
104
|
-
|
|
105
|
-
- 6794681: Publish the ecosystem surface as per-area sub-barrels under `@pikku/core/ecosystem/*`, and point generated code, the CLI, the inspector and the runtime adapters at them.
|
|
106
|
-
|
|
107
|
-
348 names that only generated code, the toolchain or a runtime adapter ever imports now have a second home on `@pikku/core/ecosystem/<area>` — one sub-barrel per area, matching how core already publishes its entrypoints, so no single barrel grows without bound and a consumer only pulls in the area it uses.
|
|
108
|
-
|
|
109
|
-
This step is additive: every name is still exported from the entrypoint it was published from before, so nothing downstream breaks. Removing them from the app-facing barrels is a later change, and needs a release carrying `./ecosystem/*` first.
|
|
110
|
-
|
|
111
|
-
- Updated dependencies [7406bfe]
|
|
112
|
-
- Updated dependencies [6794681]
|
|
113
|
-
- @pikku/core@0.12.84
|
|
114
|
-
|
|
115
|
-
## 0.12.8
|
|
116
|
-
|
|
117
|
-
### Patch Changes
|
|
118
|
-
|
|
119
|
-
- 6847338: Stop one slow job from holding an entire queue (head-of-line blocking).
|
|
120
|
-
|
|
121
|
-
The worker mapped pikku's parallelism to pg-boss `batchSize`, whose handler
|
|
122
|
-
receives the whole fetched batch and only fetches again once that handler
|
|
123
|
-
resolves. Because the handler `Promise.all`s the batch, a single long-running
|
|
124
|
-
job blocked every sibling in its batch _and_ stalled the next fetch — so on a
|
|
125
|
-
shared queue one slow job could freeze the worker and starve everything behind
|
|
126
|
-
it (observed with workflow-orchestrator jobs, where a long step pinned all 10
|
|
127
|
-
slots for tens of minutes).
|
|
128
|
-
|
|
129
|
-
Parallelism now maps to pg-boss `localConcurrency` with `batchSize: 1`: N
|
|
130
|
-
independent workers each fetch and process a single job and refill the instant
|
|
131
|
-
they finish, so a slow job never holds up the others. Same effective
|
|
132
|
-
concurrency, no head-of-line blocking.
|
|
133
|
-
|
|
134
|
-
- e3d4454: Add job groups, so one shared queue can stay fair without splitting into one
|
|
135
|
-
queue per producer.
|
|
136
|
-
|
|
137
|
-
A job may now carry `group: { id, tier }`, and a worker may cap how many jobs
|
|
138
|
-
of any one group run at once via `groupConcurrency`. On pg-boss this maps to
|
|
139
|
-
`localGroupConcurrency`, which excludes at-capacity groups from the fetch query
|
|
140
|
-
itself, so a capped group costs nothing rather than being fetched and restored.
|
|
141
|
-
BullMQ declares it unsupported (groups are a BullMQ Pro feature) — being
|
|
142
|
-
push-based, it can simply use a queue per group at no polling cost.
|
|
143
|
-
|
|
144
|
-
Workflow services accept a `queueStrategy`. The default `'per-workflow'` is
|
|
145
|
-
unchanged: every workflow gets its own `wf-orchestrator-*` / `wf-step-*` queue,
|
|
146
|
-
which is also what lets serverless providers deploy one unit per workflow. The
|
|
147
|
-
new `'shared-groups'` routes every workflow through the shared
|
|
148
|
-
orchestrator/step-worker queues and isolates them by group instead, so a
|
|
149
|
-
monolith runs one set of pollers rather than one per workflow — on a
|
|
150
|
-
pull-based backend with dozens of workflows that is the difference between
|
|
151
|
-
hundreds of poll loops and twenty. It is for single-process runtimes only; a
|
|
152
|
-
per-unit serverless deploy still needs the per-workflow queues to route to its
|
|
153
|
-
units.
|
|
154
|
-
|
|
155
|
-
- Updated dependencies [24252b8]
|
|
156
|
-
- Updated dependencies [e3d4454]
|
|
157
|
-
- @pikku/core@0.12.69
|
|
158
|
-
|
|
159
|
-
## 0.12.7
|
|
160
|
-
|
|
161
|
-
### Patch Changes
|
|
162
|
-
|
|
163
|
-
- 6c30861: fix workflow step retry backoff firing immediately
|
|
164
|
-
- `@pikku/queue-pg-boss`: `backoff: 'exponential'` mapped to `retryBackoff: true` without a base `retryDelay`; pg-boss computes exponential backoff as `retry_delay * 2^n` with a queue default of 0, so every retry fired immediately. Exponential backoff now gets a 1s base delay, and sub-second fixed delays round up to 1s instead of flooring to 0 (= immediate).
|
|
165
|
-
- `@pikku/core`: a duration-string `retryDelay` (e.g. `'15s'`) on a workflow step was silently dropped (only numbers were honored) and fell back to exponential. It now resolves to a fixed backoff via `getDurationInMilliseconds`.
|
|
166
|
-
|
|
167
|
-
- Updated dependencies [6c30861]
|
|
168
|
-
- @pikku/core@0.12.56
|
|
169
|
-
|
|
170
|
-
## 0.12.6
|
|
171
|
-
|
|
172
|
-
### Patch Changes
|
|
173
|
-
|
|
174
|
-
- 41ce2cb: Upgrade to TypeScript 6 and raise the minimum Node.js version to 22.
|
|
175
|
-
|
|
176
|
-
All packages now build against `typescript@^6.0.3` and declare `engines.node >= 22`. Internal tooling (`ts-json-schema-generator`, `zod-to-ts`) was bumped to TypeScript 6-compatible releases.
|
|
177
|
-
|
|
178
|
-
- Updated dependencies [41ce2cb]
|
|
179
|
-
- @pikku/core@0.12.44
|
|
180
|
-
|
|
181
|
-
## 0.12.5
|
|
182
|
-
|
|
183
|
-
### Patch Changes
|
|
184
|
-
|
|
185
|
-
- 05aba57: fix(scheduler): prune orphaned recurring-task schedules on start
|
|
186
|
-
|
|
187
|
-
When a scheduled task is removed from code, its pg-boss schedule row survived and
|
|
188
|
-
kept producing jobs into a queue with no registered worker — the jobs piled up as
|
|
189
|
-
'created' forever and could flood the queue (thousands of stuck jobs). `start()`
|
|
190
|
-
now drops any `pikku-recurring-scheduled-task_*` schedule and queue that is no
|
|
191
|
-
longer registered, so task removals self-heal on the next boot.
|
|
192
|
-
|
|
193
|
-
- Updated dependencies [a8022e5]
|
|
194
|
-
- @pikku/core@0.12.43
|
|
195
|
-
|
|
196
|
-
## 0.12.4
|
|
197
|
-
|
|
198
|
-
### Patch Changes
|
|
199
|
-
|
|
200
|
-
- 92cd5b1: feat(workflow): workflow-owned step retries + stable invocationId
|
|
201
|
-
|
|
202
|
-
The workflow — not the queue — now owns step retry policy, and each step
|
|
203
|
-
invocation gets a stable idempotency key.
|
|
204
|
-
- **Default `retries: 5` with exponential backoff.** A step with no `retries`
|
|
205
|
-
previously inherited the queue's bare default (e.g. pg-boss `retry_limit 2`,
|
|
206
|
-
no backoff) so retries fired instantly and couldn't outlast a transient
|
|
207
|
-
outage. Retries now default to 5 with backoff, resolved at the workflow layer.
|
|
208
|
-
- **`retries: 0` is honored.** Dispatch previously passed `undefined` options
|
|
209
|
-
for `retries: 0`, letting the queue re-run a non-idempotent step up to its own
|
|
210
|
-
default. The resolved policy now always sets `attempts` (`retries: 0` →
|
|
211
|
-
`attempts: 1`), so the queue never second-guesses the workflow. The persisted
|
|
212
|
-
step retries and the dispatched `attempts` are resolved together so
|
|
213
|
-
"retries exhausted" and "no more redeliveries" are the same event.
|
|
214
|
-
- **`workflowStep.invocationId`** — a deterministic, dependency-free
|
|
215
|
-
`uuidv5(runId:stepName)` handed to every step. Unlike `stepId` (minted per
|
|
216
|
-
attempt), it is identical across retries, so a step can dedupe on it
|
|
217
|
-
(`ON CONFLICT (invocationId)`, Stripe idempotency keys, etc.).
|
|
218
|
-
- **queue-bullmq**: `mapPikkuJobToBull` now maps `backoff` (previously dropped,
|
|
219
|
-
so a step's backoff silently never applied on Redis), and `registerQueues`
|
|
220
|
-
throws a clear error when no logger is available (matching queue-pg-boss).
|
|
221
|
-
- **Dispatch failures are recoverable, not fatal.** A step is now marked
|
|
222
|
-
`scheduled` only _after_ it is successfully handed to its transport (queue or
|
|
223
|
-
scheduler) — a failed hand-off leaves it `pending` so a replay re-dispatches
|
|
224
|
-
it, instead of stranding it in `scheduled` (replay would pause forever on a
|
|
225
|
-
job that was never enqueued). A transport outage (e.g. pg-boss momentarily
|
|
226
|
-
down) is surfaced as a new `WorkflowDispatchException`, which the orchestrator
|
|
227
|
-
treats as transient: the run is left running and the orchestrator job is
|
|
228
|
-
rethrown for redelivery (it replays idempotently from the snapshot) rather
|
|
229
|
-
than the whole run being marked `failed`. The orchestrator job now also
|
|
230
|
-
carries its own retry policy, so this holds even when the orchestrator queue
|
|
231
|
-
is configured `retry_limit 0`. A genuine step error still fails the run.
|
|
232
|
-
- **Same step name can be invoked multiple times in one run.** Step rows are now
|
|
233
|
-
keyed per _invocation_: the Nth reach of a step name in a replay resolves to a
|
|
234
|
-
physical key (`name` for the first, `name#N` for repeats), so a literal
|
|
235
|
-
duplicate name no longer clobbers the earlier step's state. The first reach
|
|
236
|
-
keeps the bare name, so existing rows, graph-node matching and `invocationId`s
|
|
237
|
-
are unchanged. Ordinals are derived deterministically from DSL execution order
|
|
238
|
-
and reset each replay.
|
|
239
|
-
- **Step provenance (`fromStepName`) + graph cycles.** Every step now records
|
|
240
|
-
the predecessor it was scheduled from (`fromStepName`; entry steps have none),
|
|
241
|
-
persisted on the step row across all stores (in-memory, kysely, redis,
|
|
242
|
-
mongodb, cloudflare DO) and carried in the queued payload. The DSL wire
|
|
243
|
-
exposes the derived `fromInvocationId` (`uuidv5(runId:fromStepName)`) so
|
|
244
|
-
consumers get the stable predecessor key without a second persisted id —
|
|
245
|
-
`fromStepName` is the source of truth (it is replay-deterministic; `stepId`,
|
|
246
|
-
minted per row, is not). This makes the walked path reconstructable even when
|
|
247
|
-
a node is reached more than once: in `a → b → a → c` the second `a` is a
|
|
248
|
-
distinct ordinal instance (`a#1`) whose `fromStepName` is `b`.
|
|
249
|
-
The graph runner now supports **cycles**: a forward edge into an
|
|
250
|
-
already-started node still collapses to a single run (joins/diamonds are
|
|
251
|
-
unchanged), but a _back-edge_ — one whose target can reach its source — fires
|
|
252
|
-
a fresh ordinal instance, so a node can loop back to itself. Termination is
|
|
253
|
-
the graph's responsibility (branch routing must converge); the engine enforces
|
|
254
|
-
no visit cap.
|
|
255
|
-
|
|
256
|
-
- Updated dependencies [92cd5b1]
|
|
257
|
-
- @pikku/core@0.12.38
|
|
258
|
-
|
|
259
|
-
## 0.12.0
|
|
260
|
-
|
|
261
|
-
## 0.12.3
|
|
262
|
-
|
|
263
|
-
### Patch Changes
|
|
264
|
-
|
|
265
|
-
- 8b9b2e9: Accept optional logger parameter in `registerQueues()` instead of reaching into pikku state directly. Falls back to `getSingletonServices()` for backwards compatibility.
|
|
266
|
-
- 8b9b2e9: Fix child workflow completion in queued execution mode. When a sub-workflow completes, the parent step is now marked as succeeded and the parent orchestrator resumes automatically via `onChildWorkflowCompleted`. Adds `parentStepId` to `WorkflowRunWire` to track the parent step without querying. Retains advisory locks in PgKyselyWorkflowService for concurrency safety. Fixes pgboss `registerQueues` to accept an optional logger parameter.
|
|
267
|
-
- Updated dependencies [e412b4d]
|
|
268
|
-
- Updated dependencies [53dc8c8]
|
|
269
|
-
- Updated dependencies [0a1cc51]
|
|
270
|
-
- Updated dependencies [0a1cc51]
|
|
271
|
-
- Updated dependencies [0a1cc51]
|
|
272
|
-
- Updated dependencies [0a1cc51]
|
|
273
|
-
- Updated dependencies [0a1cc51]
|
|
274
|
-
- Updated dependencies [0a1cc51]
|
|
275
|
-
- Updated dependencies [0a1cc51]
|
|
276
|
-
- Updated dependencies [0a1cc51]
|
|
277
|
-
- Updated dependencies [0a1cc51]
|
|
278
|
-
- Updated dependencies [8b9b2e9]
|
|
279
|
-
- Updated dependencies [8b9b2e9]
|
|
280
|
-
- Updated dependencies [b973d44]
|
|
281
|
-
- Updated dependencies [8b9b2e9]
|
|
282
|
-
- Updated dependencies [8b9b2e9]
|
|
283
|
-
- @pikku/core@0.12.9
|
|
284
|
-
|
|
285
|
-
## 0.12.2
|
|
286
|
-
|
|
287
|
-
### Patch Changes
|
|
288
|
-
|
|
289
|
-
- 3e04565: chore: update dependencies to latest minor/patch versions
|
|
290
|
-
- Updated dependencies [cc4c9e9]
|
|
291
|
-
- Updated dependencies [3e04565]
|
|
292
|
-
- @pikku/core@0.12.2
|
|
293
|
-
|
|
294
|
-
## 0.12.1
|
|
295
|
-
|
|
296
|
-
### Patch Changes
|
|
297
|
-
|
|
298
|
-
- 62a8725: Fix pg-boss queue initialisation: create the queue before registering a worker to avoid a race condition on first startup. Also sanitise scheduler names to meet pg-boss naming constraints.
|
|
299
|
-
- Updated dependencies [62a8725]
|
|
300
|
-
- Updated dependencies [a3bdb0d]
|
|
301
|
-
- Updated dependencies [e0349ff]
|
|
302
|
-
- Updated dependencies [62a8725]
|
|
303
|
-
- Updated dependencies [e04531f]
|
|
304
|
-
- Updated dependencies [62a8725]
|
|
305
|
-
- Updated dependencies [a83efb8]
|
|
306
|
-
- Updated dependencies [8eed717]
|
|
307
|
-
- Updated dependencies [62a8725]
|
|
308
|
-
- Updated dependencies [62a8725]
|
|
309
|
-
- Updated dependencies [62a8725]
|
|
310
|
-
- @pikku/core@0.12.1
|
|
311
|
-
|
|
312
|
-
### New Features
|
|
313
|
-
|
|
314
|
-
- `setServices()`, `start()`, `stop()` lifecycle methods on scheduler and queue workers
|
|
315
|
-
|
|
316
|
-
## 0.11.0
|
|
317
|
-
|
|
318
|
-
## 0.11.2
|
|
319
|
-
|
|
320
|
-
### Patch Changes
|
|
321
|
-
|
|
322
|
-
- db9c7bf: Simplify CreateWireServices type signature for custom Config compatibility
|
|
323
|
-
- Updated dependencies [db9c7bf]
|
|
324
|
-
- @pikku/core@0.11.2
|
|
325
|
-
|
|
326
|
-
### Fixes
|
|
327
|
-
|
|
328
|
-
- ddd87eaf: Simplify CreateWireServices type signature for custom Config compatibility
|
|
329
|
-
|
|
330
|
-
## 0.11.1
|
|
331
|
-
|
|
332
|
-
### Patch Changes
|
|
333
|
-
|
|
334
|
-
- 4b811db: chore: updating all dependencies
|
|
335
|
-
- 06e1a31: breaking: change session services to wire services
|
|
336
|
-
- Updated dependencies [4b811db]
|
|
337
|
-
- Updated dependencies [e12a00c]
|
|
338
|
-
- Updated dependencies [4579434]
|
|
339
|
-
- Updated dependencies [28aeb7f]
|
|
340
|
-
- Updated dependencies [ce902b1]
|
|
341
|
-
- Updated dependencies [06e1a31]
|
|
342
|
-
- @pikku/core@0.11.1
|
|
343
|
-
|
|
344
|
-
### Minor Changes
|
|
345
|
-
|
|
346
|
-
- Add scheduler service implementation
|
|
347
|
-
- Add service factory for queue and scheduler creation
|
|
348
|
-
|
|
349
|
-
# @pikku/queue-pg-boss
|
|
350
|
-
|
|
351
|
-
## 0.10.0
|
|
352
|
-
|
|
353
|
-
This release includes significant improvements across the framework including tree-shaking support, middleware/permission factories, enhanced CLI functionality, improved TypeScript type safety, and comprehensive test strategies.
|
|
354
|
-
|
|
355
|
-
For complete details, see https://pikku.dev/changelogs/0_10_0.md
|
|
356
|
-
|
|
357
|
-
## 0.9.5-next.0
|
|
358
|
-
|
|
359
|
-
### Patch Changes
|
|
360
|
-
|
|
361
|
-
- Updated dependencies
|
|
362
|
-
- @pikku/core@0.9.12-next.0
|
|
363
|
-
|
|
364
|
-
## 0.9.4
|
|
365
|
-
|
|
366
|
-
### Patch Changes
|
|
367
|
-
|
|
368
|
-
- 3bb5824: fix: forcing release to see if dist is generated
|
|
369
|
-
- Updated dependencies [99c2b3a]
|
|
370
|
-
- @pikku/core@0.9.9
|
|
371
|
-
|
|
372
|
-
## 0.9.3
|
|
373
|
-
|
|
374
|
-
### Patch Changes
|
|
375
|
-
|
|
376
|
-
- c18800d: feat: adding queue and scheduledTask to interactions
|
|
377
|
-
- Updated dependencies [c18800d]
|
|
378
|
-
- @pikku/core@0.9.4
|
|
379
|
-
|
|
380
|
-
## 0.9.2
|
|
381
|
-
|
|
382
|
-
### Patch Changes
|
|
383
|
-
|
|
384
|
-
- a5905a9: chore: updating all dependencies
|
|
385
|
-
- Updated dependencies [1256238]
|
|
386
|
-
- Updated dependencies [6cf8efd]
|
|
387
|
-
- Updated dependencies [d3a9a09]
|
|
388
|
-
- Updated dependencies [840e078]
|
|
389
|
-
- Updated dependencies [667d23c]
|
|
390
|
-
- Updated dependencies [a5905a9]
|
|
391
|
-
- @pikku/core@0.9.2
|
|
392
|
-
|
|
393
|
-
## 0.9.1
|
|
394
|
-
|
|
395
|
-
### Patch Changes
|
|
396
|
-
|
|
397
|
-
- fdb1593: core: bumping everything with a patch to sync up the major release inconsistencies in dependencies
|
|
398
|
-
- Updated dependencies [fdb1593]
|
|
399
|
-
- @pikku/core@0.9.1
|
|
400
|
-
|
|
401
|
-
## 0.9.0
|
|
402
|
-
|
|
403
|
-
### Breaking Changes
|
|
404
|
-
|
|
405
|
-
- Normalized all transports to use "wirings" instead of events/routes/transports for consistency across the framework
|
|
406
|
-
|
|
407
|
-
## 0.8.0
|
|
408
|
-
|
|
409
|
-
- **PG Boss integration**: Postgres queue service implementation
|
package/run-tests.sh
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
4
|
-
cd "$script_dir"
|
|
5
|
-
|
|
6
|
-
# Enable nullglob to handle cases where no files match the pattern
|
|
7
|
-
shopt -s nullglob
|
|
8
|
-
|
|
9
|
-
# Initialize variables for options
|
|
10
|
-
watch_mode=false
|
|
11
|
-
coverage_mode=false
|
|
12
|
-
|
|
13
|
-
# Parse command-line options
|
|
14
|
-
while [[ $# -gt 0 ]]; do
|
|
15
|
-
case $1 in
|
|
16
|
-
--watch)
|
|
17
|
-
watch_mode=true
|
|
18
|
-
shift
|
|
19
|
-
;;
|
|
20
|
-
--coverage)
|
|
21
|
-
coverage_mode=true
|
|
22
|
-
shift
|
|
23
|
-
;;
|
|
24
|
-
*)
|
|
25
|
-
echo "Unknown option: $1"
|
|
26
|
-
exit 1
|
|
27
|
-
;;
|
|
28
|
-
esac
|
|
29
|
-
done
|
|
30
|
-
|
|
31
|
-
# Define the pattern to match your test files
|
|
32
|
-
pattern="src/*.test.ts"
|
|
33
|
-
|
|
34
|
-
# Expand the pattern into an array of files
|
|
35
|
-
files=($(find src -type f -name "*.test.ts"))
|
|
36
|
-
|
|
37
|
-
# Check if any files matched the pattern
|
|
38
|
-
if [ ${#files[@]} -eq 0 ]; then
|
|
39
|
-
echo "No test files found matching pattern: $pattern"
|
|
40
|
-
exit 0
|
|
41
|
-
fi
|
|
42
|
-
|
|
43
|
-
# Construct the node command
|
|
44
|
-
node_cmd=(node --import tsx --test)
|
|
45
|
-
|
|
46
|
-
# Append options based on flags
|
|
47
|
-
if [ "$watch_mode" = true ]; then
|
|
48
|
-
node_cmd+=(--watch)
|
|
49
|
-
fi
|
|
50
|
-
|
|
51
|
-
if [ "$coverage_mode" = true ]; then
|
|
52
|
-
node_cmd+=(--test-coverage-include="src/**/*.{ts,js}" --test-coverage-exclude="**/dist/**" --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=lcov.info)
|
|
53
|
-
fi
|
|
54
|
-
|
|
55
|
-
# Execute the node command with the expanded list of files
|
|
56
|
-
"${node_cmd[@]}" "${files[@]}"
|
package/src/index.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module @pikku/queue-pg-boss
|
|
3
|
-
*
|
|
4
|
-
* PostgreSQL queue service for Pikku using pg-boss
|
|
5
|
-
* Provides job results, retries, priorities, and PostgreSQL-based queuing
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
export { PgBossServiceFactory } from './pg-boss-service-factory.js'
|
|
9
|
-
export { PgBossQueueService } from './pg-boss-queue-service.js'
|
|
10
|
-
export { PgBossQueueWorkers } from './pg-boss-queue-worker.js'
|
|
11
|
-
export { PgBossSchedulerService } from './pg-boss-scheduler-service.js'
|
|
12
|
-
|
|
13
|
-
// Re-export core queue types for convenience
|
|
14
|
-
export type { QueueJob, QueueService } from '@pikku/core/queue'
|
|
15
|
-
export type {
|
|
16
|
-
PikkuWorkerConfig,
|
|
17
|
-
PikkuJobConfig,
|
|
18
|
-
JobOptions,
|
|
19
|
-
} from '@pikku/core/queue'
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { describe, test } from 'node:test'
|
|
2
|
-
import assert from 'node:assert/strict'
|
|
3
|
-
|
|
4
|
-
import { mapPikkuJobToPgBoss } from './pg-boss-queue-service.js'
|
|
5
|
-
|
|
6
|
-
// These guard the contract the workflow engine relies on: a step's resolved
|
|
7
|
-
// retry policy (attempts + backoff) must survive translation into pg-boss
|
|
8
|
-
// terms, so "workflow owns retries" actually reaches the queue.
|
|
9
|
-
describe('mapPikkuJobToPgBoss — retry mapping', () => {
|
|
10
|
-
test('attempts → retryLimit (attempts - 1)', () => {
|
|
11
|
-
// Default policy: 5 retries → 6 attempts → retryLimit 5.
|
|
12
|
-
assert.equal(mapPikkuJobToPgBoss({ attempts: 6 }).retryLimit, 5)
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
test('attempts: 1 (retries: 0) → retryLimit 0 (pg-boss never re-runs it)', () => {
|
|
16
|
-
assert.equal(mapPikkuJobToPgBoss({ attempts: 1 }).retryLimit, 0)
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
test("backoff 'exponential' → retryBackoff true + 1s base delay", () => {
|
|
20
|
-
const opts = mapPikkuJobToPgBoss({ attempts: 6, backoff: 'exponential' })
|
|
21
|
-
assert.equal(opts.retryBackoff, true)
|
|
22
|
-
// pg-boss multiplies retry_delay by 2^n and the queue default is 0 —
|
|
23
|
-
// without a base, "exponential" retries all fire immediately.
|
|
24
|
-
assert.equal(opts.retryDelay, 1)
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
test('sub-second fixed delay rounds up to 1s, not down to immediate', () => {
|
|
28
|
-
const opts = mapPikkuJobToPgBoss({
|
|
29
|
-
attempts: 4,
|
|
30
|
-
backoff: { type: 'fixed', delay: 300 },
|
|
31
|
-
})
|
|
32
|
-
assert.equal(opts.retryDelay, 1)
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
test('fixed backoff → retryBackoff false + retryDelay in seconds', () => {
|
|
36
|
-
const opts = mapPikkuJobToPgBoss({
|
|
37
|
-
attempts: 4,
|
|
38
|
-
backoff: { type: 'fixed', delay: 5000 },
|
|
39
|
-
})
|
|
40
|
-
assert.equal(opts.retryBackoff, false)
|
|
41
|
-
// pg-boss takes seconds; our delay is milliseconds.
|
|
42
|
-
assert.equal(opts.retryDelay, 5)
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
test('exponential object backoff → retryBackoff true + retryDelay in seconds', () => {
|
|
46
|
-
const opts = mapPikkuJobToPgBoss({
|
|
47
|
-
attempts: 4,
|
|
48
|
-
backoff: { type: 'exponential', delay: 2000 },
|
|
49
|
-
})
|
|
50
|
-
assert.equal(opts.retryBackoff, true)
|
|
51
|
-
assert.equal(opts.retryDelay, 2)
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
test('no options → no retry fields set', () => {
|
|
55
|
-
const opts = mapPikkuJobToPgBoss(undefined)
|
|
56
|
-
assert.equal(opts.retryLimit, undefined)
|
|
57
|
-
assert.equal(opts.retryBackoff, undefined)
|
|
58
|
-
})
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
describe('mapPikkuJobToPgBoss — group mapping', () => {
|
|
62
|
-
test('group id is forwarded so the worker can enforce a per-group limit', () => {
|
|
63
|
-
assert.deepEqual(
|
|
64
|
-
mapPikkuJobToPgBoss({ group: { id: 'deployWorkflow' } }).group,
|
|
65
|
-
{ id: 'deployWorkflow' }
|
|
66
|
-
)
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
test('tier is only set when provided', () => {
|
|
70
|
-
const opts = mapPikkuJobToPgBoss({
|
|
71
|
-
group: { id: 'deployWorkflow', tier: 'slow' },
|
|
72
|
-
})
|
|
73
|
-
assert.deepEqual(opts.group, { id: 'deployWorkflow', tier: 'slow' })
|
|
74
|
-
assert.equal(
|
|
75
|
-
'tier' in mapPikkuJobToPgBoss({ group: { id: 'a' } }).group!,
|
|
76
|
-
false
|
|
77
|
-
)
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
test('no group → no group field', () => {
|
|
81
|
-
assert.equal(mapPikkuJobToPgBoss({ attempts: 2 }).group, undefined)
|
|
82
|
-
})
|
|
83
|
-
})
|