@nwire/queue 0.10.1 → 0.11.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/README.md +5 -11
- package/dist/queue-worker.d.ts +4 -4
- package/dist/queue-worker.js +2 -1
- package/package.json +9 -8
package/README.md
CHANGED
|
@@ -21,14 +21,12 @@ import { httpKoa } from "@nwire/koa";
|
|
|
21
21
|
import { queueInMemory } from "@nwire/queue";
|
|
22
22
|
|
|
23
23
|
const app = createApp({ appName: "svc" });
|
|
24
|
-
app.wire(queue("emails.send"), async (input) => {
|
|
24
|
+
app.wire(queue("emails.send"), async (input) => {
|
|
25
|
+
/* send mail */
|
|
26
|
+
});
|
|
25
27
|
|
|
26
28
|
const q = queueInMemory();
|
|
27
|
-
await endpoint("svc", { port: 3000 })
|
|
28
|
-
.use(httpKoa())
|
|
29
|
-
.use(q)
|
|
30
|
-
.mount(app)
|
|
31
|
-
.run();
|
|
29
|
+
await endpoint("svc", { port: 3000 }).use(httpKoa()).use(q).mount(app).run();
|
|
32
30
|
|
|
33
31
|
await q.enqueue("emails.send", { userId: "u-1" });
|
|
34
32
|
// queue subscriber dispatches the wire's handler.
|
|
@@ -40,11 +38,7 @@ For embedding in tests or building custom adapters, the underlying
|
|
|
40
38
|
`QueueTransport` interface ships unchanged:
|
|
41
39
|
|
|
42
40
|
```ts
|
|
43
|
-
import {
|
|
44
|
-
InMemoryQueueTransport,
|
|
45
|
-
createQueueWorker,
|
|
46
|
-
type QueueTransport,
|
|
47
|
-
} from "@nwire/queue";
|
|
41
|
+
import { InMemoryQueueTransport, createQueueWorker, type QueueTransport } from "@nwire/queue";
|
|
48
42
|
|
|
49
43
|
const transport = new InMemoryQueueTransport();
|
|
50
44
|
const worker = createQueueWorker(app, transport, {
|
package/dist/queue-worker.d.ts
CHANGED
|
@@ -24,10 +24,11 @@
|
|
|
24
24
|
* Wire-mode invariance: domain handlers are the same in HTTP and queue wires.
|
|
25
25
|
* The framework decides where dispatch happens; the handler is unchanged.
|
|
26
26
|
*/
|
|
27
|
-
import type
|
|
27
|
+
import type { App as NwireApp } from "@nwire/app";
|
|
28
|
+
import { type ActionDefinition } from "@nwire/forge";
|
|
28
29
|
import type { QueueTransport } from "./queue-transport.js";
|
|
29
|
-
type App =
|
|
30
|
-
type ActionDefinition
|
|
30
|
+
type App = NwireApp;
|
|
31
|
+
export type { ActionDefinition };
|
|
31
32
|
export interface QueueSubscription {
|
|
32
33
|
/** Queue name to subscribe to. Convention: `<domain>.<verb-noun>`. */
|
|
33
34
|
readonly queue: string;
|
|
@@ -84,4 +85,3 @@ export interface QueueWorker {
|
|
|
84
85
|
}>;
|
|
85
86
|
}
|
|
86
87
|
export declare function createQueueWorker(app: App, transport: QueueTransport, options: CreateQueueWorkerOptions): QueueWorker;
|
|
87
|
-
export {};
|
package/dist/queue-worker.js
CHANGED
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
* Wire-mode invariance: domain handlers are the same in HTTP and queue wires.
|
|
25
25
|
* The framework decides where dispatch happens; the handler is unchanged.
|
|
26
26
|
*/
|
|
27
|
+
import { forgeDispatcher } from "@nwire/forge";
|
|
27
28
|
/**
|
|
28
29
|
* Build a `QueueSubscription` with a chainable `.from(source)` method.
|
|
29
30
|
* Equivalent to writing the object literal by hand but adds the fluent
|
|
@@ -66,7 +67,7 @@ export function createQueueWorker(app, transport, options) {
|
|
|
66
67
|
// Combine worker-stop + per-job signals so the handler
|
|
67
68
|
// sees an abort if EITHER source fires.
|
|
68
69
|
const combined = combineSignals(workerController.signal, jobSignal);
|
|
69
|
-
await app.dispatch(subscription.action, msg.input, msg.envelope, {
|
|
70
|
+
await forgeDispatcher(app).dispatch(subscription.action, msg.input, msg.envelope, {
|
|
70
71
|
signal: combined,
|
|
71
72
|
});
|
|
72
73
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nwire/queue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "Nwire — queue transport contract + InMemory default + createQueueWorker. Production adapters land as @nwire/bullmq, @nwire/queue-sqs, @nwire/queue-pgboss.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bus",
|
|
@@ -28,19 +28,20 @@
|
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@nwire/container": "0.
|
|
32
|
-
"@nwire/endpoint": "0.
|
|
33
|
-
"@nwire/
|
|
34
|
-
"@nwire/
|
|
35
|
-
"@nwire/
|
|
36
|
-
"@nwire/
|
|
31
|
+
"@nwire/container": "0.11.1",
|
|
32
|
+
"@nwire/endpoint": "0.11.1",
|
|
33
|
+
"@nwire/envelope": "0.11.1",
|
|
34
|
+
"@nwire/forge": "0.11.1",
|
|
35
|
+
"@nwire/logger": "0.11.1",
|
|
36
|
+
"@nwire/wires": "0.11.1",
|
|
37
|
+
"@nwire/app": "0.11.1"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
40
|
"@types/node": "^22.19.9",
|
|
40
41
|
"typescript": "^5.9.3",
|
|
41
42
|
"vitest": "^4.0.18",
|
|
42
43
|
"zod": "^4.0.0",
|
|
43
|
-
"@nwire/messages": "0.
|
|
44
|
+
"@nwire/messages": "0.11.1"
|
|
44
45
|
},
|
|
45
46
|
"scripts": {
|
|
46
47
|
"build": "tsc && node ../../scripts/fix-dist-extensions.mjs dist",
|