@c9up/bay 0.1.12 → 0.1.13
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 +66 -1
- package/dist/BayProvider.d.ts +24 -30
- package/dist/BayProvider.d.ts.map +1 -1
- package/dist/BayProvider.js +58 -9
- package/dist/BayProvider.js.map +1 -1
- package/dist/QueueManager.d.ts +7 -1
- package/dist/QueueManager.d.ts.map +1 -1
- package/dist/QueueManager.js +49 -5
- package/dist/QueueManager.js.map +1 -1
- package/dist/configure.d.ts +18 -0
- package/dist/configure.d.ts.map +1 -0
- package/dist/configure.js +31 -0
- package/dist/configure.js.map +1 -0
- package/dist/drivers/RedisDriver.d.ts +6 -0
- package/dist/drivers/RedisDriver.d.ts.map +1 -1
- package/dist/drivers/RedisDriver.js +49 -17
- package/dist/drivers/RedisDriver.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/nodeEnv.d.ts +16 -0
- package/dist/nodeEnv.d.ts.map +1 -0
- package/dist/nodeEnv.js +32 -0
- package/dist/nodeEnv.js.map +1 -0
- package/dist/services/main.d.ts +5 -0
- package/dist/services/main.d.ts.map +1 -1
- package/dist/services/main.js +7 -0
- package/dist/services/main.js.map +1 -1
- package/dist/stores.d.ts +41 -0
- package/dist/stores.d.ts.map +1 -0
- package/dist/stores.js +46 -0
- package/dist/stores.js.map +1 -0
- package/package.json +5 -1
- package/src/BayProvider.ts +84 -19
- package/src/QueueManager.ts +48 -5
- package/src/configure.ts +45 -0
- package/src/drivers/RedisDriver.ts +69 -22
- package/src/index.ts +1 -0
- package/src/nodeEnv.ts +30 -0
- package/src/services/main.ts +8 -0
- package/src/stores.ts +59 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RedisDriver.js","sourceRoot":"","sources":["../../src/drivers/RedisDriver.ts"],"names":[],"mappings":"AAAA;;;;;;;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ACV,CAAC;YACD,IAAI,UAAU,CAAC,MAAM,CAAC,IAAK,MAAyB,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,EAAE,CAAC;gBACpE,MAAM,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;gBAClD,OAAO;YACR,CAAC;QACF,CAAC;IACF,CAAC;IAED,KAAK,CAAC,MAAM;QACX,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QACpC,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAC3D,OAAO,IAAI;aACT,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;YACV,IAAI,CAAC;gBACJ,MAAM,MAAM,GAAY,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBACtC,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;YAC3C,CAAC;YAAC,MAAM,CAAC;gBACR,OAAO,IAAI,CAAC;YACb,CAAC;QACF,CAAC,CAAC;aACD,MAAM,CAAC,CAAC,CAAC,EAAY,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,IAAI;QACT,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QACpC,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;IACxC,CAAC;CACD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export type { RedisClient } from "./drivers/RedisDriver.js";
|
|
|
11
11
|
export { RedisDriver } from "./drivers/RedisDriver.js";
|
|
12
12
|
export type { Job, JobHandler, QueueDriver } from "./QueueManager.js";
|
|
13
13
|
export { QueueManager } from "./QueueManager.js";
|
|
14
|
+
export { type QueueStoreFactory, stores } from "./stores.js";
|
|
14
15
|
import type { BayProviderConfig } from "./BayProvider.js";
|
|
15
16
|
/**
|
|
16
17
|
* Author-time config helper for `config/queue.ts` — AdonisJS `defineConfig`
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,YAAY,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,YAAY,EAAE,GAAG,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,YAAY,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,YAAY,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,YAAY,EAAE,GAAG,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE1D;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,iBAAiB,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAEtE;AACD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
export { MemoryDriver } from "./drivers/MemoryDriver.js";
|
|
9
9
|
export { RedisDriver } from "./drivers/RedisDriver.js";
|
|
10
10
|
export { QueueManager } from "./QueueManager.js";
|
|
11
|
+
export { stores } from "./stores.js";
|
|
11
12
|
/**
|
|
12
13
|
* Author-time config helper for `config/queue.ts` — AdonisJS `defineConfig`
|
|
13
14
|
* parity. Identity at runtime; the generic preserves literal types for inference.
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAA0B,MAAM,EAAE,MAAM,aAAa,CAAC;AAI7D;;;GAGG;AACH,MAAM,UAAU,YAAY,CAA8B,MAAS;IAClE,OAAO,MAAM,CAAC;AACf,CAAC;AACD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading `NODE_ENV`, with the aliases people actually set.
|
|
3
|
+
*
|
|
4
|
+
* `NODE_ENV=prod` is ordinary in a Dockerfile or a platform dashboard. Read
|
|
5
|
+
* verbatim it answers "not production" — and here that decides whether a queue
|
|
6
|
+
* silently accepts a delivery guarantee weaker than the one it advertises.
|
|
7
|
+
*
|
|
8
|
+
* Duplicated rather than imported: bay depends on no other package in this
|
|
9
|
+
* workspace, and a safety decision that only holds when an optional peer is
|
|
10
|
+
* installed is not a decision.
|
|
11
|
+
*/
|
|
12
|
+
/** The canonical name for whatever `NODE_ENV` holds. */
|
|
13
|
+
export declare function normalizeNodeEnv(value: string | undefined): string;
|
|
14
|
+
/** Whether this process is running in production, under any spelling. */
|
|
15
|
+
export declare function inProduction(): boolean;
|
|
16
|
+
//# sourceMappingURL=nodeEnv.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodeEnv.d.ts","sourceRoot":"","sources":["../src/nodeEnv.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH,wDAAwD;AACxD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAOlE;AAED,yEAAyE;AACzE,wBAAgB,YAAY,IAAI,OAAO,CAEtC"}
|
package/dist/nodeEnv.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading `NODE_ENV`, with the aliases people actually set.
|
|
3
|
+
*
|
|
4
|
+
* `NODE_ENV=prod` is ordinary in a Dockerfile or a platform dashboard. Read
|
|
5
|
+
* verbatim it answers "not production" — and here that decides whether a queue
|
|
6
|
+
* silently accepts a delivery guarantee weaker than the one it advertises.
|
|
7
|
+
*
|
|
8
|
+
* Duplicated rather than imported: bay depends on no other package in this
|
|
9
|
+
* workspace, and a safety decision that only holds when an optional peer is
|
|
10
|
+
* installed is not a decision.
|
|
11
|
+
*/
|
|
12
|
+
const DEV_ENVS = ["dev", "develop", "development"];
|
|
13
|
+
const PROD_ENVS = ["prod", "production"];
|
|
14
|
+
const TEST_ENVS = ["test", "testing"];
|
|
15
|
+
/** The canonical name for whatever `NODE_ENV` holds. */
|
|
16
|
+
export function normalizeNodeEnv(value) {
|
|
17
|
+
if (!value || typeof value !== "string")
|
|
18
|
+
return "unknown";
|
|
19
|
+
const env = value.toLowerCase();
|
|
20
|
+
if (DEV_ENVS.includes(env))
|
|
21
|
+
return "development";
|
|
22
|
+
if (PROD_ENVS.includes(env))
|
|
23
|
+
return "production";
|
|
24
|
+
if (TEST_ENVS.includes(env))
|
|
25
|
+
return "test";
|
|
26
|
+
return env;
|
|
27
|
+
}
|
|
28
|
+
/** Whether this process is running in production, under any spelling. */
|
|
29
|
+
export function inProduction() {
|
|
30
|
+
return normalizeNodeEnv(process.env.NODE_ENV) === "production";
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=nodeEnv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodeEnv.js","sourceRoot":"","sources":["../src/nodeEnv.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,QAAQ,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;AACnD,MAAM,SAAS,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AACzC,MAAM,SAAS,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAEtC,wDAAwD;AACxD,MAAM,UAAU,gBAAgB,CAAC,KAAyB;IACzD,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC;IAC1D,MAAM,GAAG,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;IAChC,IAAI,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,aAAa,CAAC;IACjD,IAAI,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,YAAY,CAAC;IACjD,IAAI,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,MAAM,CAAC;IAC3C,OAAO,GAAG,CAAC;AACZ,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,YAAY;IAC3B,OAAO,gBAAgB,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,YAAY,CAAC;AAChE,CAAC"}
|
package/dist/services/main.d.ts
CHANGED
|
@@ -17,6 +17,11 @@ import type { QueueManager } from "../QueueManager.js";
|
|
|
17
17
|
export declare function setQueue(value: QueueManager): void;
|
|
18
18
|
/** @internal Read the singleton (or `undefined` pre-boot). */
|
|
19
19
|
export declare function getQueue(): QueueManager | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* @internal Release the singleton, so a shut-down application does not leave a
|
|
22
|
+
* dead queue reachable through `services/main`.
|
|
23
|
+
*/
|
|
24
|
+
export declare function clearQueue(): void;
|
|
20
25
|
declare const queue: QueueManager;
|
|
21
26
|
export default queue;
|
|
22
27
|
//# sourceMappingURL=main.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/services/main.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIvD,0EAA0E;AAC1E,wBAAgB,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAElD;AAED,8DAA8D;AAC9D,wBAAgB,QAAQ,IAAI,YAAY,GAAG,SAAS,CAEnD;AAED,QAAA,MAAM,KAAK,EAAE,YAoBX,CAAC;AAEH,eAAe,KAAK,CAAC"}
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/services/main.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIvD,0EAA0E;AAC1E,wBAAgB,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAElD;AAED,8DAA8D;AAC9D,wBAAgB,QAAQ,IAAI,YAAY,GAAG,SAAS,CAEnD;AAED;;;GAGG;AACH,wBAAgB,UAAU,IAAI,IAAI,CAEjC;AAED,QAAA,MAAM,KAAK,EAAE,YAoBX,CAAC;AAEH,eAAe,KAAK,CAAC"}
|
package/dist/services/main.js
CHANGED
|
@@ -21,6 +21,13 @@ export function setQueue(value) {
|
|
|
21
21
|
export function getQueue() {
|
|
22
22
|
return instance;
|
|
23
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* @internal Release the singleton, so a shut-down application does not leave a
|
|
26
|
+
* dead queue reachable through `services/main`.
|
|
27
|
+
*/
|
|
28
|
+
export function clearQueue() {
|
|
29
|
+
instance = undefined;
|
|
30
|
+
}
|
|
24
31
|
const queue = new Proxy({}, {
|
|
25
32
|
get(_target, prop) {
|
|
26
33
|
// A module loader inspects what it imports before anyone uses it: it reads
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/services/main.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,IAAI,QAAkC,CAAC;AAEvC,0EAA0E;AAC1E,MAAM,UAAU,QAAQ,CAAC,KAAmB;IAC3C,QAAQ,GAAG,KAAK,CAAC;AAClB,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,QAAQ;IACvB,OAAO,QAAQ,CAAC;AACjB,CAAC;AAED,MAAM,KAAK,GAAiB,IAAI,KAAK,CAAC,EAAkB,EAAE;IACzD,GAAG,CAAC,OAAO,EAAE,IAAI;QAChB,2EAA2E;QAC3E,0EAA0E;QAC1E,8DAA8D;QAC9D,0EAA0E;QAC1E,0EAA0E;QAC1E,wEAAwE;QACxE,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;YACjD,OAAO,SAAS,CAAC;QAClB,CAAC;QACD,IAAI,CAAC,QAAQ,EAAE,CAAC;YACf,MAAM,IAAI,KAAK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AU,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IACnE,CAAC;CACD,CAAC,CAAC;AAEH,eAAe,KAAK,CAAC"}
|
package/dist/stores.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The queue store factories a config file names — `{ default, stores }`.
|
|
3
|
+
*
|
|
4
|
+
* The shape AdonisJS gives a package with several backends and one selected:
|
|
5
|
+
* a `stores` namespace imported beside `defineConfig`, each entry that
|
|
6
|
+
* namespace's result, and the selection read from the environment. Bay had a
|
|
7
|
+
* single `driver: "memory"` and told everyone else to build the manager by
|
|
8
|
+
* hand, which meant Redis could not be reached from a config file at all.
|
|
9
|
+
*
|
|
10
|
+
* import { defineConfig, stores } from '@c9up/bay'
|
|
11
|
+
*
|
|
12
|
+
* export default defineConfig({
|
|
13
|
+
* default: env.get('QUEUE_STORE'),
|
|
14
|
+
* stores: {
|
|
15
|
+
* memory: stores.memory(),
|
|
16
|
+
* redis: stores.redis({ connection: 'main' }),
|
|
17
|
+
* },
|
|
18
|
+
* })
|
|
19
|
+
*
|
|
20
|
+
* Factories are lazy: only the store an application actually uses is built, so
|
|
21
|
+
* naming a Redis queue in a config that runs in memory opens no connection.
|
|
22
|
+
*/
|
|
23
|
+
import type { RedisClientSource } from "./drivers/RedisDriver.js";
|
|
24
|
+
import type { QueueDriver } from "./QueueManager.js";
|
|
25
|
+
/** A driver, built on first use. */
|
|
26
|
+
export type QueueStoreFactory = () => QueueDriver;
|
|
27
|
+
export declare const stores: {
|
|
28
|
+
/** In memory. Jobs do not survive a restart — for tests and dev. */
|
|
29
|
+
memory(): QueueStoreFactory;
|
|
30
|
+
/**
|
|
31
|
+
* Redis. `connection` takes an ioredis-shaped client, a function answering
|
|
32
|
+
* one, or the NAME of a `@c9up/quasar` connection — the last resolved at
|
|
33
|
+
* first use, without bay importing quasar, which stays an optional peer.
|
|
34
|
+
*/
|
|
35
|
+
redis(options: {
|
|
36
|
+
connection: RedisClientSource | string;
|
|
37
|
+
prefix?: string;
|
|
38
|
+
visibilityTimeoutMs?: number;
|
|
39
|
+
}): QueueStoreFactory;
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=stores.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stores.d.ts","sourceRoot":"","sources":["../src/stores.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,oCAAoC;AACpC,MAAM,MAAM,iBAAiB,GAAG,MAAM,WAAW,CAAC;AAElD,eAAO,MAAM,MAAM;IAClB,oEAAoE;cAC1D,iBAAiB;IAI3B;;;;OAIG;mBACY;QACd,UAAU,EAAE,iBAAiB,GAAG,MAAM,CAAC;QACvC,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,mBAAmB,CAAC,EAAE,MAAM,CAAC;KAC7B,GAAG,iBAAiB;CAWrB,CAAC"}
|
package/dist/stores.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The queue store factories a config file names — `{ default, stores }`.
|
|
3
|
+
*
|
|
4
|
+
* The shape AdonisJS gives a package with several backends and one selected:
|
|
5
|
+
* a `stores` namespace imported beside `defineConfig`, each entry that
|
|
6
|
+
* namespace's result, and the selection read from the environment. Bay had a
|
|
7
|
+
* single `driver: "memory"` and told everyone else to build the manager by
|
|
8
|
+
* hand, which meant Redis could not be reached from a config file at all.
|
|
9
|
+
*
|
|
10
|
+
* import { defineConfig, stores } from '@c9up/bay'
|
|
11
|
+
*
|
|
12
|
+
* export default defineConfig({
|
|
13
|
+
* default: env.get('QUEUE_STORE'),
|
|
14
|
+
* stores: {
|
|
15
|
+
* memory: stores.memory(),
|
|
16
|
+
* redis: stores.redis({ connection: 'main' }),
|
|
17
|
+
* },
|
|
18
|
+
* })
|
|
19
|
+
*
|
|
20
|
+
* Factories are lazy: only the store an application actually uses is built, so
|
|
21
|
+
* naming a Redis queue in a config that runs in memory opens no connection.
|
|
22
|
+
*/
|
|
23
|
+
import { MemoryDriver } from "./drivers/MemoryDriver.js";
|
|
24
|
+
import { RedisDriver } from "./drivers/RedisDriver.js";
|
|
25
|
+
import { quasarConnection } from "./quasar.js";
|
|
26
|
+
export const stores = {
|
|
27
|
+
/** In memory. Jobs do not survive a restart — for tests and dev. */
|
|
28
|
+
memory() {
|
|
29
|
+
return () => new MemoryDriver();
|
|
30
|
+
},
|
|
31
|
+
/**
|
|
32
|
+
* Redis. `connection` takes an ioredis-shaped client, a function answering
|
|
33
|
+
* one, or the NAME of a `@c9up/quasar` connection — the last resolved at
|
|
34
|
+
* first use, without bay importing quasar, which stays an optional peer.
|
|
35
|
+
*/
|
|
36
|
+
redis(options) {
|
|
37
|
+
const source = typeof options.connection === "string"
|
|
38
|
+
? quasarConnection(options.connection)
|
|
39
|
+
: options.connection;
|
|
40
|
+
return () => new RedisDriver(source, {
|
|
41
|
+
prefix: options.prefix,
|
|
42
|
+
visibilityTimeoutMs: options.visibilityTimeoutMs,
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=stores.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stores.js","sourceRoot":"","sources":["../src/stores.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAK/C,MAAM,CAAC,MAAM,MAAM,GAAG;IACrB,oEAAoE;IACpE,MAAM;QACL,OAAO,GAAG,EAAE,CAAC,IAAI,YAAY,EAAE,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,OAIL;QACA,MAAM,MAAM,GACX,OAAO,OAAO,CAAC,UAAU,KAAK,QAAQ;YACrC,CAAC,CAAC,gBAAgB,CAAC,OAAO,CAAC,UAAU,CAAC;YACtC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC;QACvB,OAAO,GAAG,EAAE,CACX,IAAI,WAAW,CAAC,MAAM,EAAE;YACvB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,mBAAmB,EAAE,OAAO,CAAC,mBAAmB;SAChD,CAAC,CAAC;IACL,CAAC;CACD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c9up/bay",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"description": "Queue — pluggable job-queue contract with memory + Redis drivers for the Ream framework",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -15,6 +15,10 @@
|
|
|
15
15
|
"types": "./dist/BayProvider.d.ts",
|
|
16
16
|
"import": "./dist/BayProvider.js"
|
|
17
17
|
},
|
|
18
|
+
"./configure": {
|
|
19
|
+
"types": "./dist/configure.d.ts",
|
|
20
|
+
"import": "./dist/configure.js"
|
|
21
|
+
},
|
|
18
22
|
"./services/main": {
|
|
19
23
|
"types": "./dist/services/main.d.ts",
|
|
20
24
|
"import": "./dist/services/main.js"
|
package/src/BayProvider.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { MemoryDriver } from "./drivers/MemoryDriver.js";
|
|
2
|
+
import type { QueueDriver } from "./QueueManager.js";
|
|
2
3
|
import { QueueManager } from "./QueueManager.js";
|
|
3
|
-
import { setQueue } from "./services/main.js";
|
|
4
|
+
import { clearQueue, getQueue, setQueue } from "./services/main.js";
|
|
5
|
+
import type { QueueStoreFactory } from "./stores.js";
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* Slim, duck-typed host context — bay stays publishable without
|
|
@@ -22,14 +24,21 @@ export interface BayAppContext {
|
|
|
22
24
|
|
|
23
25
|
export interface BayProviderConfig {
|
|
24
26
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
*
|
|
32
|
-
*
|
|
27
|
+
* Which named store to use — a key of {@link stores}. Read from the
|
|
28
|
+
* environment in the generated config, so a deployment picks its queue
|
|
29
|
+
* backend without editing a file.
|
|
30
|
+
*/
|
|
31
|
+
default?: string;
|
|
32
|
+
/**
|
|
33
|
+
* The queue stores this application can use, by name. Each is a factory
|
|
34
|
+
* from `stores.*`, built only when it is the one selected.
|
|
35
|
+
*/
|
|
36
|
+
stores?: Record<string, QueueStoreFactory>;
|
|
37
|
+
/**
|
|
38
|
+
* The single-store form, kept for configs written against it: only
|
|
39
|
+
* `"memory"` was ever accepted. Prefer `default` + `stores`, which is how a
|
|
40
|
+
* pluggable backend is configured everywhere else and what lets the
|
|
41
|
+
* environment choose.
|
|
33
42
|
*/
|
|
34
43
|
driver?: "memory";
|
|
35
44
|
}
|
|
@@ -56,31 +65,87 @@ export interface BayProviderConfig {
|
|
|
56
65
|
* queue.register('send-email', new SendEmailJob())
|
|
57
66
|
* await queue.dispatch('send-email', { to: 'user@example.com' })
|
|
58
67
|
*/
|
|
68
|
+
/**
|
|
69
|
+
* The driver the config asks for.
|
|
70
|
+
*
|
|
71
|
+
* `default` + `stores` first — the form an environment variable can steer. The
|
|
72
|
+
* `driver` key is the single-store form kept for configs written against it.
|
|
73
|
+
* Naming a store that does not exist throws rather than falling back to memory:
|
|
74
|
+
* an application that meant to queue in Redis and silently got an in-process
|
|
75
|
+
* queue would only find out when a restart dropped every pending job.
|
|
76
|
+
*/
|
|
77
|
+
function buildDriver(config: BayProviderConfig | undefined): QueueDriver {
|
|
78
|
+
const stores = config?.stores;
|
|
79
|
+
const name = config?.default;
|
|
80
|
+
|
|
81
|
+
if (stores && name !== undefined) {
|
|
82
|
+
const selected = stores[name];
|
|
83
|
+
if (!selected) {
|
|
84
|
+
const known = Object.keys(stores);
|
|
85
|
+
throw new Error(
|
|
86
|
+
`[bay] config.queue names the store '${name}', which is not in \`stores\`. ` +
|
|
87
|
+
(known.length > 0
|
|
88
|
+
? `Declared: ${known.join(", ")}.`
|
|
89
|
+
: "`stores` is empty — declare one with stores.memory() or stores.redis()."),
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
return selected();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (stores && name === undefined) {
|
|
96
|
+
throw new Error(
|
|
97
|
+
"[bay] config.queue declares `stores` but no `default` naming which one to use. " +
|
|
98
|
+
`Set default to one of: ${Object.keys(stores).join(", ")}.`,
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const driverName = config?.driver ?? "memory";
|
|
103
|
+
if (driverName !== "memory") {
|
|
104
|
+
throw new Error(
|
|
105
|
+
`[bay] Unsupported driver '${driverName}' — name it under \`stores\` instead: ` +
|
|
106
|
+
"stores: { redis: stores.redis({ connection: 'main' }) }.",
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
return new MemoryDriver();
|
|
110
|
+
}
|
|
111
|
+
|
|
59
112
|
export default class BayProvider {
|
|
60
113
|
constructor(protected app: BayAppContext) {}
|
|
61
114
|
|
|
62
115
|
register(): void {
|
|
63
116
|
this.app.container.singleton(QueueManager, () => {
|
|
64
117
|
const config = this.app.config.get<BayProviderConfig>("queue");
|
|
65
|
-
|
|
66
|
-
if (driverName !== "memory") {
|
|
67
|
-
throw new Error(
|
|
68
|
-
`[bay] Unsupported driver '${driverName}' for default provider — ` +
|
|
69
|
-
"wire QueueManager yourself in start/queue.ts for non-memory drivers.",
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
return new QueueManager(new MemoryDriver());
|
|
118
|
+
return new QueueManager(buildDriver(config));
|
|
73
119
|
});
|
|
74
120
|
this.app.container.singleton("queue", () =>
|
|
75
121
|
this.app.container.resolve<QueueManager>(QueueManager),
|
|
76
122
|
);
|
|
77
123
|
}
|
|
78
124
|
|
|
125
|
+
/** The queue THIS provider booted — not whatever the module singleton holds. */
|
|
126
|
+
#queue: QueueManager | undefined;
|
|
127
|
+
|
|
79
128
|
async boot(): Promise<void> {
|
|
80
129
|
// Populate the `@c9up/bay/services/main` singleton so apps can
|
|
81
130
|
// `import queue from '@c9up/bay/services/main'` from anywhere.
|
|
82
|
-
|
|
131
|
+
this.#queue = await this.app.container.resolve<QueueManager>(QueueManager);
|
|
132
|
+
setQueue(this.#queue);
|
|
83
133
|
}
|
|
84
134
|
|
|
85
|
-
|
|
135
|
+
/**
|
|
136
|
+
* Stop the worker the app started, and let the job in flight finish.
|
|
137
|
+
*
|
|
138
|
+
* A worker polls on a timer. Left running, it survives a dev reload, a test
|
|
139
|
+
* teardown and a SIGTERM — so the old process keeps pulling jobs the new
|
|
140
|
+
* one is also pulling, and the same job runs twice.
|
|
141
|
+
*/
|
|
142
|
+
async shutdown(): Promise<void> {
|
|
143
|
+
if (!this.#queue) return;
|
|
144
|
+
await this.#queue.stop();
|
|
145
|
+
// Two applications can share a process — parallel tests, a hot reload.
|
|
146
|
+
// The module singleton holds whichever booted last, so it is only ours
|
|
147
|
+
// to clear while it still points at the queue this provider booted.
|
|
148
|
+
if (getQueue() === this.#queue) clearQueue();
|
|
149
|
+
this.#queue = undefined;
|
|
150
|
+
}
|
|
86
151
|
}
|
package/src/QueueManager.ts
CHANGED
|
@@ -43,6 +43,10 @@ export class QueueManager {
|
|
|
43
43
|
#driver: QueueDriver;
|
|
44
44
|
#handlers: Map<string, JobHandler | (new () => JobHandler)> = new Map();
|
|
45
45
|
#running = false;
|
|
46
|
+
/** The running loop, so `stop()` can wait for it to finish. */
|
|
47
|
+
#loopPromise: Promise<void> | undefined;
|
|
48
|
+
/** Cuts the sleep between polls short. */
|
|
49
|
+
#wake: (() => void) | undefined;
|
|
46
50
|
#inflightPromise: Promise<boolean> | null = null;
|
|
47
51
|
|
|
48
52
|
constructor(driver: QueueDriver) {
|
|
@@ -138,20 +142,36 @@ export class QueueManager {
|
|
|
138
142
|
throw new Error("QueueManager is already running");
|
|
139
143
|
}
|
|
140
144
|
this.#running = true;
|
|
145
|
+
const loop = this.#loop(pollIntervalMs, recoverStaleMs);
|
|
146
|
+
this.#loopPromise = loop;
|
|
147
|
+
try {
|
|
148
|
+
await loop;
|
|
149
|
+
} finally {
|
|
150
|
+
this.#loopPromise = undefined;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* The polling loop itself.
|
|
156
|
+
*
|
|
157
|
+
* Between jobs it sleeps, and that sleep is CANCELLABLE: `stop()` wakes it
|
|
158
|
+
* rather than waiting out the interval. Without that, stopping returned
|
|
159
|
+
* while the loop was still pending — up to a full poll interval of a worker
|
|
160
|
+
* that was supposed to be gone, and a timer holding the process open.
|
|
161
|
+
*/
|
|
162
|
+
async #loop(pollIntervalMs: number, recoverStaleMs: number): Promise<void> {
|
|
141
163
|
await this.#tryRecoverStale();
|
|
142
164
|
let lastRecover = Date.now();
|
|
143
165
|
while (this.#running) {
|
|
144
166
|
try {
|
|
145
167
|
this.#inflightPromise = this.processOne();
|
|
146
168
|
const processed = await this.#inflightPromise;
|
|
147
|
-
if (!processed)
|
|
148
|
-
await new Promise((r) => setTimeout(r, pollIntervalMs));
|
|
149
|
-
}
|
|
169
|
+
if (!processed) await this.#sleep(pollIntervalMs);
|
|
150
170
|
} catch (err) {
|
|
151
171
|
process.stderr.write(
|
|
152
172
|
`QueueManager processOne error: ${err instanceof Error ? err.message : String(err)}\n`,
|
|
153
173
|
);
|
|
154
|
-
await
|
|
174
|
+
await this.#sleep(pollIntervalMs);
|
|
155
175
|
} finally {
|
|
156
176
|
this.#inflightPromise = null;
|
|
157
177
|
}
|
|
@@ -162,6 +182,21 @@ export class QueueManager {
|
|
|
162
182
|
}
|
|
163
183
|
}
|
|
164
184
|
|
|
185
|
+
/** Wait, unless `stop()` says otherwise first. */
|
|
186
|
+
#sleep(ms: number): Promise<void> {
|
|
187
|
+
return new Promise((resolve) => {
|
|
188
|
+
const timer = setTimeout(() => {
|
|
189
|
+
this.#wake = undefined;
|
|
190
|
+
resolve();
|
|
191
|
+
}, ms);
|
|
192
|
+
this.#wake = () => {
|
|
193
|
+
clearTimeout(timer);
|
|
194
|
+
this.#wake = undefined;
|
|
195
|
+
resolve();
|
|
196
|
+
};
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
|
|
165
200
|
/** recoverStale() wrapper that swallows driver errors — used by the work loop. */
|
|
166
201
|
async #tryRecoverStale(): Promise<void> {
|
|
167
202
|
try {
|
|
@@ -190,10 +225,18 @@ export class QueueManager {
|
|
|
190
225
|
}
|
|
191
226
|
}
|
|
192
227
|
|
|
193
|
-
/**
|
|
228
|
+
/**
|
|
229
|
+
* Stop the worker and wait for it to actually be gone.
|
|
230
|
+
*
|
|
231
|
+
* Awaits the LOOP, not just the job in flight: a stop that returns while
|
|
232
|
+
* the loop is still sleeping leaves a worker running past the teardown that
|
|
233
|
+
* asked it to stop.
|
|
234
|
+
*/
|
|
194
235
|
async stop(): Promise<void> {
|
|
195
236
|
this.#running = false;
|
|
237
|
+
this.#wake?.();
|
|
196
238
|
await this.drain();
|
|
239
|
+
if (this.#loopPromise) await this.#loopPromise.catch(() => {});
|
|
197
240
|
}
|
|
198
241
|
|
|
199
242
|
/** Get failed jobs. */
|
package/src/configure.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ream configure @c9up/bay` — wire the job queue in one command.
|
|
3
|
+
*
|
|
4
|
+
* The provider alone is not enough: it reads `config/queue.ts`, and a package
|
|
5
|
+
* registered without one falls back to a default that is rarely the one an
|
|
6
|
+
* application wants. Writing both together is what makes `ream add` mean
|
|
7
|
+
* installed AND working.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
interface Codemods {
|
|
11
|
+
addProvider(importPath: string): Promise<void>;
|
|
12
|
+
addEnvVars(vars: Record<string, string>): Promise<void>;
|
|
13
|
+
writeFile(
|
|
14
|
+
filePath: string,
|
|
15
|
+
content: string,
|
|
16
|
+
options?: { force?: boolean },
|
|
17
|
+
): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export async function configure(codemods: Codemods): Promise<void> {
|
|
21
|
+
// The config below reads these, so they are declared here. Writing the file
|
|
22
|
+
// without them leaves an application whose config asks the environment for
|
|
23
|
+
// something nothing ever put there.
|
|
24
|
+
await codemods.addEnvVars({
|
|
25
|
+
QUEUE_STORE: "memory",
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
await codemods.addProvider("@c9up/bay/provider");
|
|
29
|
+
await codemods.writeFile(
|
|
30
|
+
"config/queue.ts",
|
|
31
|
+
`import { defineConfig, stores } from '@c9up/bay'
|
|
32
|
+
import env from '#start/env'
|
|
33
|
+
|
|
34
|
+
export default defineConfig({
|
|
35
|
+
// Which store to run on. Memory forgets everything on restart, which is
|
|
36
|
+
// what a single process in development wants and nothing else does.
|
|
37
|
+
default: env.get('QUEUE_STORE', 'memory'),
|
|
38
|
+
|
|
39
|
+
stores: {
|
|
40
|
+
memory: stores.memory(),
|
|
41
|
+
redis: stores.redis({ connection: 'main' }),
|
|
42
|
+
},
|
|
43
|
+
})`,
|
|
44
|
+
);
|
|
45
|
+
}
|