@hexok/queue 0.0.0-stage → 0.0.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/README.md +8 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/queue.d.ts +34 -0
- package/dist/queue.d.ts.map +1 -0
- package/dist/queue.js +12 -0
- package/dist/queue.js.map +1 -0
- package/package.json +43 -4
package/README.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @hexok/queue
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Queue port. Install with `npm i @hexok/queue`. A Redis Streams adapter is `@hexok/queue-redis`.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { Queue, type QueueHandler } from '@hexok/queue';
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
`publish` resolves a broker id. `subscribe` requires `consumerGroup`. A handler return of `'ack'`, `void`, or `'drop'` acknowledges. `'retry'` leaves the entry pending. A throw uses `onError`, which defaults to `'retry'`. There is no dead-letter stream. A Redis adapter can park a failed publish, a missing payload, or a decode failure when a quarantine sink is passed. A handler `'drop'` is not parked.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,KAAK,EACL,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,qBAAqB,GAC3B,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,KAAK,GAMN,MAAM,YAAY,CAAC"}
|
package/dist/queue.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export type QueueDisposition = 'ack' | 'retry' | 'drop';
|
|
2
|
+
export interface QueueMessage<T> {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
readonly topic: string;
|
|
5
|
+
readonly payload: T;
|
|
6
|
+
}
|
|
7
|
+
export type QueueHandler<T> = (message: QueueMessage<T>) => Promise<QueueDisposition | void>;
|
|
8
|
+
export type QueueStartFrom = 'earliest' | 'now' | {
|
|
9
|
+
readonly afterTimestampMs: number;
|
|
10
|
+
} | {
|
|
11
|
+
readonly afterStreamId: string;
|
|
12
|
+
};
|
|
13
|
+
export interface QueueSubscribeOptions<T> {
|
|
14
|
+
readonly consumerGroup: string;
|
|
15
|
+
readonly startFrom?: QueueStartFrom;
|
|
16
|
+
readonly onError?: QueueDisposition;
|
|
17
|
+
readonly handler: QueueHandler<T>;
|
|
18
|
+
}
|
|
19
|
+
declare const Queue_base: (abstract new () => {
|
|
20
|
+
readonly "__#private@#brand": true;
|
|
21
|
+
}) & {
|
|
22
|
+
readonly token: "Queue";
|
|
23
|
+
};
|
|
24
|
+
export declare abstract class Queue extends Queue_base {
|
|
25
|
+
abstract publish(topic: string, payload: unknown): Promise<string>;
|
|
26
|
+
abstract subscribe<T>(topic: string, options: QueueSubscribeOptions<T>): Promise<void>;
|
|
27
|
+
abstract unsubscribe(topic: string, options: {
|
|
28
|
+
readonly consumerGroup: string;
|
|
29
|
+
}): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
/** Returned value wins. `void` acknowledges. A throw uses `onError`, default `retry`. */
|
|
32
|
+
export declare function dispositionOf(returned: QueueDisposition | void, thrown: boolean, onError?: QueueDisposition): QueueDisposition;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=queue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../src/queue.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,g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B,aAAa,CAC3B,QAAQ,EAAE,gBAAgB,GAAG,IAAI,EACjC,MAAM,EAAE,OAAO,EACf,OAAO,GAAE,gBAA0B,GAClC,gBAAgB,CAIlB"}
|
package/dist/queue.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Port } from 'hexok';
|
|
2
|
+
export class Queue extends Port('Queue') {
|
|
3
|
+
}
|
|
4
|
+
/** Returned value wins. `void` acknowledges. A throw uses `onError`, default `retry`. */
|
|
5
|
+
export function dispositionOf(returned, thrown, onError = 'retry') {
|
|
6
|
+
if (thrown)
|
|
7
|
+
return onError;
|
|
8
|
+
if (returned === undefined)
|
|
9
|
+
return 'ack';
|
|
10
|
+
return returned;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=queue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.js","sourceRoot":"","sources":["../src/queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AA2B7B,MAAM,OAAgB,KAAM,SAAQ,IAAI,CAAC,OAAO,CAAC;CAUhD;AAED,yFAAyF;AACzF,MAAM,UAAU,aAAa,CAC3B,QAAiC,EACjC,MAAe,EACf,UAA4B,OAAO;IAEnC,IAAI,MAAM;QAAE,OAAO,OAAO,CAAC;IAC3B,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACzC,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hexok/queue",
|
|
3
|
-
"version": "0.0.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Queue port for hexok.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"keywords": [
|
|
9
|
+
"hexok",
|
|
10
|
+
"queue"
|
|
11
|
+
],
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/crobinson42/hexok.git",
|
|
15
|
+
"directory": "packages/queue"
|
|
16
|
+
},
|
|
17
|
+
"homepage": "https://crobinson42.github.io/hexok/",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/crobinson42/hexok/issues"
|
|
20
|
+
},
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"import": "./dist/index.js",
|
|
28
|
+
"default": "./dist/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./package.json": "./package.json"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"dist"
|
|
34
|
+
],
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "tsc -b",
|
|
37
|
+
"test": "vitest run",
|
|
38
|
+
"type-check": "tsc --noEmit -p tsconfig.check.json",
|
|
39
|
+
"lint": "biome check .",
|
|
40
|
+
"clean": "rm -rf dist *.tsbuildinfo"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"hexok": "^2.1.0"
|
|
44
|
+
}
|
|
45
|
+
}
|