@zintrust/workers 0.4.48 → 0.4.50
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/WorkerFactory.js +17 -11
- package/dist/WorkerShutdownDurableObject.d.ts +12 -0
- package/dist/WorkerShutdownDurableObject.js +41 -0
- package/dist/build-manifest.json +38 -10
- package/dist/dashboard/workers-api.js +6 -0
- package/dist/ui/workers/index.html +202 -0
- package/dist/ui/workers/main.js +1952 -0
- package/dist/ui/workers/styles.css +1350 -0
- package/dist/ui/workers/zintrust.svg +30 -0
- package/package.json +3 -3
- package/src/WorkerFactory.ts +19 -11
- package/src/dashboard/workers-api.ts +10 -0
- package/src/types/queue-monitor.d.ts +3 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<svg width="120" height="120" viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<defs>
|
|
3
|
+
<linearGradient id="zt-g2d" x1="10" y1="50" x2="90" y2="50" gradientUnits="userSpaceOnUse">
|
|
4
|
+
<stop stop-color="#22c55e" />
|
|
5
|
+
<stop offset="1" stop-color="#38bdf8" />
|
|
6
|
+
</linearGradient>
|
|
7
|
+
</defs>
|
|
8
|
+
<circle cx="50" cy="50" r="34" stroke="rgba(255,255,255,0.16)" stroke-width="4" />
|
|
9
|
+
<ellipse cx="50" cy="50" rx="40" ry="18" stroke="url(#zt-g2d)" stroke-width="4" />
|
|
10
|
+
<ellipse cx="50" cy="50" rx="18" ry="40" stroke="url(#zt-g2d)" stroke-width="4" opacity="0.75" />
|
|
11
|
+
<circle cx="50" cy="50" r="6" fill="url(#zt-g2d)" />
|
|
12
|
+
<path
|
|
13
|
+
d="M40 52C35 52 32 49 32 44C32 39 35 36 40 36H48"
|
|
14
|
+
stroke="white"
|
|
15
|
+
stroke-width="6"
|
|
16
|
+
stroke-linecap="round"
|
|
17
|
+
/>
|
|
18
|
+
<path
|
|
19
|
+
d="M60 48C65 48 68 51 68 56C68 61 65 64 60 64H52"
|
|
20
|
+
stroke="white"
|
|
21
|
+
stroke-width="6"
|
|
22
|
+
stroke-linecap="round"
|
|
23
|
+
/>
|
|
24
|
+
<path
|
|
25
|
+
d="M44 50H56"
|
|
26
|
+
stroke="rgba(255,255,255,0.22)"
|
|
27
|
+
stroke-width="6"
|
|
28
|
+
stroke-linecap="round"
|
|
29
|
+
/>
|
|
30
|
+
</svg>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zintrust/workers",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.50",
|
|
4
4
|
"description": "Worker orchestration and background job management for ZinTrust.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"node": ">=20.0.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@zintrust/core": "
|
|
43
|
+
"@zintrust/core": ">=0.4.0 <0.5.0",
|
|
44
44
|
"@zintrust/queue-monitor": "*",
|
|
45
45
|
"@zintrust/queue-redis": "*"
|
|
46
46
|
},
|
|
@@ -73,4 +73,4 @@
|
|
|
73
73
|
"prom-client": "^15.1.3",
|
|
74
74
|
"simple-statistics": "^7.8.9"
|
|
75
75
|
}
|
|
76
|
-
}
|
|
76
|
+
}
|
package/src/WorkerFactory.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
Cloudflare,
|
|
10
10
|
createRedisConnection,
|
|
11
11
|
databaseConfig,
|
|
12
|
+
DatabaseConnectionRegistry,
|
|
12
13
|
Env,
|
|
13
14
|
ErrorFactory,
|
|
14
15
|
generateUuid,
|
|
@@ -108,7 +109,7 @@ const resolveRuntimeBridgeUrl = (specifier: string): string | null => {
|
|
|
108
109
|
const filePath = path.join(dir, `${safeName}.bridge.mjs`);
|
|
109
110
|
const exportLines = Object.keys(bridgeModule)
|
|
110
111
|
.filter((key) => key !== 'default' && isValidBridgeExportName(key))
|
|
111
|
-
.sort()
|
|
112
|
+
.sort((a, b) => a.localeCompare(b))
|
|
112
113
|
.map((key) => `export const ${key} = bridge[${JSON.stringify(key)}];`);
|
|
113
114
|
|
|
114
115
|
const code = [
|
|
@@ -2226,20 +2227,27 @@ const resolvePersistenceConfig = (
|
|
|
2226
2227
|
};
|
|
2227
2228
|
|
|
2228
2229
|
const resolveDbClientFromEnv = async (connectionName = 'default'): Promise<IDatabase> => {
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2230
|
+
// Eagerly populate the registry when the requested connection is not yet
|
|
2231
|
+
// registered. On both the Cloudflare Workers runtime and Node, the registry
|
|
2232
|
+
// may be empty when called from the workers-persistence path because
|
|
2233
|
+
// registerDatabasesFromRuntimeConfig has not yet run for this connection. The
|
|
2234
|
+
// old pattern of connecting first (which always fails) then registering as a
|
|
2235
|
+
// fallback produced spurious [DEBUG] noise on every fresh start.
|
|
2236
|
+
if (DatabaseConnectionRegistry.get(connectionName) === undefined) {
|
|
2237
|
+
try {
|
|
2238
|
+
registerDatabasesFromRuntimeConfig(databaseConfig);
|
|
2239
|
+
} catch (registrationError) {
|
|
2240
|
+
Logger.warn(
|
|
2241
|
+
`[WorkerPersistence] Runtime database registration failed for connection '${connectionName}'`,
|
|
2242
|
+
registrationError
|
|
2243
|
+
);
|
|
2244
|
+
}
|
|
2236
2245
|
}
|
|
2237
2246
|
|
|
2238
2247
|
try {
|
|
2239
|
-
|
|
2240
|
-
return await connect();
|
|
2248
|
+
return await useEnsureDbConnected(undefined, connectionName);
|
|
2241
2249
|
} catch (error) {
|
|
2242
|
-
Logger.error('Worker persistence failed
|
|
2250
|
+
Logger.error('Worker persistence failed to resolve database connection', error);
|
|
2243
2251
|
throw ErrorFactory.createConfigError(
|
|
2244
2252
|
`Worker persistence requires a database client. Register connection '${connectionName}' or pass infrastructure.persistence.client.`
|
|
2245
2253
|
);
|
|
@@ -591,6 +591,16 @@ async function getRedisQueueData(): Promise<QueueData> {
|
|
|
591
591
|
}
|
|
592
592
|
|
|
593
593
|
const monitor = QueueMonitor.create({
|
|
594
|
+
knownQueues: async () => {
|
|
595
|
+
const records = await WorkerFactory.listPersistedRecords();
|
|
596
|
+
return Array.from(
|
|
597
|
+
new Set(
|
|
598
|
+
records
|
|
599
|
+
.map((record) => record.queueName)
|
|
600
|
+
.filter((queueName) => typeof queueName === 'string')
|
|
601
|
+
)
|
|
602
|
+
).sort((left, right) => left.localeCompare(right));
|
|
603
|
+
},
|
|
594
604
|
redis: {
|
|
595
605
|
host: redisConfig.host || 'localhost',
|
|
596
606
|
port: redisConfig.port || 6379,
|
|
@@ -24,6 +24,9 @@ declare module '@zintrust/queue-monitor' {
|
|
|
24
24
|
autoRefresh?: boolean;
|
|
25
25
|
refreshIntervalMs?: number;
|
|
26
26
|
redis?: Record<string, unknown>;
|
|
27
|
+
knownQueues?:
|
|
28
|
+
| ReadonlyArray<string>
|
|
29
|
+
| (() => Promise<ReadonlyArray<string>> | ReadonlyArray<string>);
|
|
27
30
|
};
|
|
28
31
|
|
|
29
32
|
export type QueueMonitorApi = {
|