@zintrust/core 2.7.2 → 2.8.2
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/package.json +3 -3
- package/src/boot/registry/runtime.d.ts.map +1 -1
- package/src/boot/registry/runtime.js +4 -2
- package/src/cache/drivers/KVDriver.d.ts.map +1 -1
- package/src/cache/drivers/KVDriver.js +2 -3
- package/src/config/redis.d.ts.map +1 -1
- package/src/config/redis.js +3 -2
- package/src/health/RuntimeHealthProbes.js +2 -2
- package/src/index.js +3 -3
- package/src/observability/PrometheusMetrics.d.ts.map +1 -1
- package/src/observability/PrometheusMetrics.js +2 -3
- package/src/runtime/ProjectRuntime.d.ts.map +1 -1
- package/src/runtime/ProjectRuntime.js +17 -23
- package/src/tools/broadcast/Broadcast.d.ts.map +1 -1
- package/src/tools/broadcast/Broadcast.js +25 -24
- package/src/tools/queue/QueueRuntimeRegistration.d.ts.map +1 -1
- package/src/tools/queue/QueueRuntimeRegistration.js +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zintrust/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.2",
|
|
4
4
|
"description": "Production-grade TypeScript backend framework for JavaScript",
|
|
5
5
|
"homepage": "https://zintrust.com",
|
|
6
6
|
"repository": {
|
|
@@ -253,10 +253,10 @@
|
|
|
253
253
|
"axios": "^1.16.1"
|
|
254
254
|
},
|
|
255
255
|
"@actions/github": {
|
|
256
|
-
"undici": "^6.
|
|
256
|
+
"undici": "^6.27.0"
|
|
257
257
|
},
|
|
258
258
|
"@actions/http-client": {
|
|
259
|
-
"undici": "^6.
|
|
259
|
+
"undici": "^6.27.0"
|
|
260
260
|
},
|
|
261
261
|
"miniflare": {
|
|
262
262
|
"undici": "^7.28.0"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/boot/registry/runtime.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAQnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/boot/registry/runtime.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAQnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAiTvD,eAAO,MAAM,8BAA8B,GAAI,iBAAiB,gBAAgB,KAAG,IA6BlF,CAAC;AA8WF,KAAK,eAAe,GAAG;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,eAAe,EAAE,gBAAgB,CAAC;IAClC,SAAS,EAAE,MAAM,OAAO,CAAC;IACzB,SAAS,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACrC,CAAC;AAqIF,eAAO,MAAM,eAAe,GAC1B,QAAQ,eAAe,KACtB;IAAE,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAK5D,CAAC"}
|
|
@@ -19,7 +19,7 @@ import { registerDatabasesFromRuntimeConfig } from '../../orm/DatabaseRuntimeReg
|
|
|
19
19
|
import { registerMasterRoutes, tryImportOptional } from './registerRoute.js';
|
|
20
20
|
import { registerWorkerShutdownHook } from './worker.js';
|
|
21
21
|
import { StartupConfigFile, StartupConfigFileRegistry } from '../../runtime/StartupConfigFileRegistry.js';
|
|
22
|
-
import { SocketFeature } from '../../sockets/SocketRuntime.js';
|
|
22
|
+
import { SocketFeature, } from '../../sockets/SocketRuntime.js';
|
|
23
23
|
import { SocketRuntimeRegistry } from '../../sockets/SocketRuntimeRegistry.js';
|
|
24
24
|
import { registerBroadcastersFromRuntimeConfig } from '../../tools/broadcast/BroadcastRuntimeRegistration.js';
|
|
25
25
|
import { registerNotificationChannelsFromRuntimeConfig } from '../../tools/notification/NotificationRuntimeRegistration.js';
|
|
@@ -366,6 +366,7 @@ const initializeQueueMonitor = async (router) => {
|
|
|
366
366
|
Logger.info(`Queue Monitor enqueue endpoint at http://127.0.0.1:${appConfig.port}/test/enqueue`);
|
|
367
367
|
};
|
|
368
368
|
let runtimeQueueMonitor = null;
|
|
369
|
+
const QUEUE_REDIS_PACKAGE = '@zintrust/queue-redis';
|
|
369
370
|
const initializeWorkers = async (router) => {
|
|
370
371
|
const workers = await loadWorkersModule({ allowWhenDisabled: true });
|
|
371
372
|
if (workers?.WorkerInit !== undefined && typeof workers.registerWorkerRoutes === 'function') {
|
|
@@ -383,7 +384,8 @@ const resolveLocalQueueRedisEntry = () => {
|
|
|
383
384
|
};
|
|
384
385
|
const loadQueueHttpGatewayModule = async () => {
|
|
385
386
|
try {
|
|
386
|
-
return (await import(
|
|
387
|
+
return (await import(
|
|
388
|
+
/* @vite-ignore */ QUEUE_REDIS_PACKAGE));
|
|
387
389
|
}
|
|
388
390
|
catch {
|
|
389
391
|
const localEntry = resolveLocalQueueRedisEntry();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KVDriver.d.ts","sourceRoot":"","sources":["../../../../src/cache/drivers/KVDriver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"KVDriver.d.ts","sourceRoot":"","sources":["../../../../src/cache/drivers/KVDriver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AA0DtD;;GAEG;AACH,eAAO,MAAM,QAAQ;kBArDF,WAAW;EAuD5B,CAAC"}
|
|
@@ -9,8 +9,7 @@ import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
|
9
9
|
* Create a new KV driver instance
|
|
10
10
|
*/
|
|
11
11
|
const create = () => {
|
|
12
|
-
|
|
13
|
-
const kv = Cloudflare.getKVBinding('CACHE');
|
|
12
|
+
const kv = Cloudflare.getKVBinding();
|
|
14
13
|
return {
|
|
15
14
|
async get(key) {
|
|
16
15
|
if (kv === null)
|
|
@@ -20,7 +19,7 @@ const create = () => {
|
|
|
20
19
|
},
|
|
21
20
|
async set(key, value, ttl) {
|
|
22
21
|
if (kv === null) {
|
|
23
|
-
Logger.warn('KV binding
|
|
22
|
+
Logger.warn('Configured KV binding not found. Cache set ignored.');
|
|
24
23
|
return;
|
|
25
24
|
}
|
|
26
25
|
const options = {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redis.d.ts","sourceRoot":"","sources":["../../../src/config/redis.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAM/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGjD,MAAM,MAAM,WAAW,GAAG;IACxB,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACjE,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IAC1E,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACvC,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,kBAAk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AC;CAC5D,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,SAAS,0BAA0B,KAAG,MAYnE,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,SAAS,0BAA0B,KAAG,MAAM,GAAG,IAW1E,CAAC;AAuDF,eAAO,MAAM,YAAY,GAAU,CAAC,GAAG,WAAW,EAAE,OAAO,OAAO,GAAG,SAAS,KAAG,OAAO,CAAC,CAAC,CA0BzF,CAAC"}
|
package/src/config/redis.js
CHANGED
|
@@ -22,7 +22,7 @@ export const buildRedisUrl = (config) => {
|
|
|
22
22
|
export const getRedisUrl = (config) => {
|
|
23
23
|
const fromEnv = Env.get('REDIS_URL', '');
|
|
24
24
|
const hasProcess = typeof process === 'object' && process !== null;
|
|
25
|
-
const fallback = hasProcess ? process.env?.['REDIS_URL'] ?? '' : '';
|
|
25
|
+
const fallback = hasProcess ? (process.env?.['REDIS_URL'] ?? '') : '';
|
|
26
26
|
const trimmed = fromEnv.trim();
|
|
27
27
|
const url = (trimmed.length > 0 ? fromEnv : String(fallback)).trim();
|
|
28
28
|
// If REDIS_URL exists, use it
|
|
@@ -30,6 +30,7 @@ export const getRedisUrl = (config) => {
|
|
|
30
30
|
return url;
|
|
31
31
|
return buildRedisUrl(config);
|
|
32
32
|
};
|
|
33
|
+
const QUEUE_REDIS_PACKAGE = '@zintrust/queue-redis';
|
|
33
34
|
const resolveLocalQueueRedisEntry = () => {
|
|
34
35
|
const cwd = typeof process !== 'undefined' && typeof process.cwd === 'function' ? process.cwd() : '';
|
|
35
36
|
if (cwd.trim() === '')
|
|
@@ -39,7 +40,7 @@ const resolveLocalQueueRedisEntry = () => {
|
|
|
39
40
|
};
|
|
40
41
|
const importQueueRedisModule = async () => {
|
|
41
42
|
try {
|
|
42
|
-
return (await import(
|
|
43
|
+
return (await import(/* @vite-ignore */ QUEUE_REDIS_PACKAGE));
|
|
43
44
|
}
|
|
44
45
|
catch {
|
|
45
46
|
const localEntry = resolveLocalQueueRedisEntry();
|
|
@@ -40,9 +40,9 @@ const pingKvCache = async (timeoutMs = 2000) => {
|
|
|
40
40
|
if (driver !== 'kv')
|
|
41
41
|
return null;
|
|
42
42
|
const start = Date.now();
|
|
43
|
-
const kv = Cloudflare.getKVBinding(
|
|
43
|
+
const kv = Cloudflare.getKVBinding();
|
|
44
44
|
if (kv === null) {
|
|
45
|
-
throw ErrorFactory.createConfigError('KV binding "CACHE" not found');
|
|
45
|
+
throw ErrorFactory.createConfigError('Configured KV binding "CACHE" not found');
|
|
46
46
|
}
|
|
47
47
|
const key = `__runtime_health__:kv:${Date.now()}`;
|
|
48
48
|
await withTimeout('runtime.cache.kv.ping', timeoutMs, async () => {
|
package/src/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @zintrust/core v2.
|
|
2
|
+
* @zintrust/core v2.8.2
|
|
3
3
|
*
|
|
4
4
|
* ZinTrust Framework - Production-Grade TypeScript Backend
|
|
5
5
|
* Built for performance, type safety, and exceptional developer experience
|
|
6
6
|
*
|
|
7
7
|
* Build Information:
|
|
8
|
-
* Built: 2026-06-
|
|
8
|
+
* Built: 2026-06-26T07:11:29.618Z
|
|
9
9
|
* Node: >=20.0.0
|
|
10
10
|
* License: MIT
|
|
11
11
|
*
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* Available at runtime for debugging and health checks
|
|
22
22
|
*/
|
|
23
23
|
export const ZINTRUST_VERSION = '0.1.41';
|
|
24
|
-
export const ZINTRUST_BUILD_DATE = '2026-06-
|
|
24
|
+
export const ZINTRUST_BUILD_DATE = '2026-06-26T07:11:29.573Z'; // Replaced during build
|
|
25
25
|
export { Application } from './boot/Application.js';
|
|
26
26
|
export { AwsSigV4 } from './common/index.js';
|
|
27
27
|
export { SignedRequest } from './security/SignedRequest.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrometheusMetrics.d.ts","sourceRoot":"","sources":["../../../src/observability/PrometheusMetrics.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"PrometheusMetrics.d.ts","sourceRoot":"","sources":["../../../src/observability/PrometheusMetrics.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA8GH,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,iBAAiB;sBACJ,OAAO,CAAC;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;8BAWtC,uBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC;0BAY3C,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;EAS/D,CAAC;AAEH,eAAe,iBAAiB,CAAC"}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { Env } from '../config/env.js';
|
|
7
7
|
let statePromise = null;
|
|
8
8
|
const DEFAULT_CONTENT_TYPE = 'text/plain; version=0.0.4; charset=utf-8';
|
|
9
|
+
const PROM_CLIENT_PACKAGE = 'prom-client';
|
|
9
10
|
const createNoopState = () => {
|
|
10
11
|
const noopCounter = { inc: () => undefined };
|
|
11
12
|
const noopHistogram = { observe: () => undefined };
|
|
@@ -28,9 +29,7 @@ async function ensureState() {
|
|
|
28
29
|
statePromise = (async () => {
|
|
29
30
|
let client;
|
|
30
31
|
try {
|
|
31
|
-
|
|
32
|
-
const promClientPkg = 'prom-client';
|
|
33
|
-
client = (await import(promClientPkg));
|
|
32
|
+
client = (await import(/* @vite-ignore */ PROM_CLIENT_PACKAGE));
|
|
34
33
|
}
|
|
35
34
|
catch {
|
|
36
35
|
// prom-client is intentionally optional at runtime.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProjectRuntime.d.ts","sourceRoot":"","sources":["../../../src/runtime/ProjectRuntime.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EAC1B,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"ProjectRuntime.d.ts","sourceRoot":"","sources":["../../../src/runtime/ProjectRuntime.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EAC1B,MAAM,gCAAgC,CAAC;AA6FxC,eAAO,MAAM,cAAc;aAChB,IAAI;iBAIA,oBAAoB,GAAG,SAAS;gBAIjC,OAAO,GAAG,oBAAoB;oCAIV,OAAO,GAAG,oBAAoB,GAAG,SAAS;0BAM9C,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC;4BAgBvC,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC;0BAOjD,aAAa,CAAC,oBAAoB,CAAC;wBAIrC,oBAAoB,GAAG,SAAS;EAGpD,CAAC;AAEH,eAAe,cAAc,CAAC"}
|
|
@@ -16,6 +16,12 @@ const getNodeRuntimeCandidates = (projectRoot) => [
|
|
|
16
16
|
path.join(projectRoot, 'dist', 'src', 'zintrust.runtime.js'),
|
|
17
17
|
path.join(projectRoot, 'src', 'zintrust.runtime.js'),
|
|
18
18
|
];
|
|
19
|
+
const WORKER_RUNTIME_CANDIDATES = [
|
|
20
|
+
'@/zintrust.runtime.wg',
|
|
21
|
+
'@/zintrust.runtime',
|
|
22
|
+
'../zintrust.runtime.wg.js',
|
|
23
|
+
'../zintrust.runtime.js',
|
|
24
|
+
];
|
|
19
25
|
const mergeProjectRuntime = (current, next) => {
|
|
20
26
|
return Object.freeze({
|
|
21
27
|
...(current?.serviceManifest === undefined ? {} : { serviceManifest: current.serviceManifest }),
|
|
@@ -53,30 +59,18 @@ const tryImportNodeRuntimeCandidate = async (candidate) => {
|
|
|
53
59
|
}
|
|
54
60
|
};
|
|
55
61
|
const tryImportWorkerRuntimeLiteralCandidates = async () => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
// continue
|
|
67
|
-
}
|
|
68
|
-
try {
|
|
69
|
-
return cacheProjectRuntime((await import('../index.js' + 'zintrust.runtime.wg.js')));
|
|
70
|
-
}
|
|
71
|
-
catch {
|
|
72
|
-
// continue
|
|
73
|
-
}
|
|
74
|
-
try {
|
|
75
|
-
return cacheProjectRuntime((await import('../index.js' + 'zintrust.runtime.js')));
|
|
76
|
-
}
|
|
77
|
-
catch {
|
|
78
|
-
return undefined;
|
|
62
|
+
for (const candidate of WORKER_RUNTIME_CANDIDATES) {
|
|
63
|
+
try {
|
|
64
|
+
return cacheProjectRuntime(
|
|
65
|
+
// These files are generated in consuming projects and are legitimately absent
|
|
66
|
+
// when a browser bundle only imports unrelated helpers such as Logger.
|
|
67
|
+
(await import(/* @vite-ignore */ candidate)));
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
// continue
|
|
71
|
+
}
|
|
79
72
|
}
|
|
73
|
+
return undefined;
|
|
80
74
|
};
|
|
81
75
|
export const ProjectRuntime = Object.freeze({
|
|
82
76
|
clear() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Broadcast.d.ts","sourceRoot":"","sources":["../../../../src/tools/broadcast/Broadcast.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAE/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,KAAK,WAAW,GAAG,QAAQ,CAAC;IAC1B,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE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
-
import { delay } from '../../common/index.js';
|
|
3
2
|
import { InMemoryDriver } from './drivers/InMemory.js';
|
|
4
3
|
import { PusherDriver } from './drivers/Pusher.js';
|
|
5
4
|
import { RedisDriver } from './drivers/Redis.js';
|
|
6
5
|
import { RedisHttpsDriver } from './drivers/RedisHttps.js';
|
|
6
|
+
import { delay } from '../../common/index.js';
|
|
7
7
|
import broadcastConfig from '../../config/broadcast.js';
|
|
8
8
|
import { Env } from '../../config/env.js';
|
|
9
9
|
import { Logger } from '../../config/logger.js';
|
|
@@ -31,7 +31,8 @@ const resolveInternalPublishRetryConfig = () => ({
|
|
|
31
31
|
// exponential backoff + full jitter
|
|
32
32
|
const computeRetryDelayMs = (baseDelayMs, attempt) => {
|
|
33
33
|
const exponential = baseDelayMs * Math.pow(2, attempt - 1);
|
|
34
|
-
const
|
|
34
|
+
const num = Math.random(); // NOSONAR
|
|
35
|
+
const jitter = baseDelayMs === 0 ? 0 : Math.floor(num * baseDelayMs);
|
|
35
36
|
return exponential + jitter;
|
|
36
37
|
};
|
|
37
38
|
const pickFirstNonEmpty = (...values) => {
|
|
@@ -305,29 +306,29 @@ const attemptInternalPublishEndpoint = async (endpoint, secret, payload) => {
|
|
|
305
306
|
return { result: null, error, transient: true };
|
|
306
307
|
}
|
|
307
308
|
};
|
|
308
|
-
const requestInternalPublishEndpoint = async (endpoint, secret, payload) => {
|
|
309
|
-
const { maxAttempts, baseDelayMs } = resolveInternalPublishRetryConfig();
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
if (lastAttempt.transient !== true || attempt >= maxAttempts) {
|
|
318
|
-
break;
|
|
319
|
-
}
|
|
320
|
-
const delayMs = computeRetryDelayMs(baseDelayMs, attempt);
|
|
321
|
-
Logger.warn('Broadcast internal publish retrying transient failure.', {
|
|
322
|
-
endpoint,
|
|
323
|
-
attempt,
|
|
324
|
-
maxAttempts,
|
|
325
|
-
delayMs,
|
|
326
|
-
status: lastAttempt.status,
|
|
327
|
-
});
|
|
328
|
-
await delay(delayMs);
|
|
309
|
+
const requestInternalPublishEndpoint = async (endpoint, secret, payload, attempt = 1, retryConfig) => {
|
|
310
|
+
const { maxAttempts, baseDelayMs } = retryConfig ?? resolveInternalPublishRetryConfig();
|
|
311
|
+
const result = await attemptInternalPublishEndpoint(endpoint, secret, payload);
|
|
312
|
+
if (result.result !== null) {
|
|
313
|
+
return result;
|
|
314
|
+
}
|
|
315
|
+
// Non-transient failures (application 4xx, etc.) reached the origin; do not retry.
|
|
316
|
+
if (result.transient !== true || attempt >= maxAttempts) {
|
|
317
|
+
return result;
|
|
329
318
|
}
|
|
330
|
-
|
|
319
|
+
const delayMs = computeRetryDelayMs(baseDelayMs, attempt);
|
|
320
|
+
Logger.warn('Broadcast internal publish retrying transient failure.', {
|
|
321
|
+
endpoint,
|
|
322
|
+
attempt,
|
|
323
|
+
maxAttempts,
|
|
324
|
+
delayMs,
|
|
325
|
+
status: result.status,
|
|
326
|
+
});
|
|
327
|
+
await delay(delayMs);
|
|
328
|
+
return requestInternalPublishEndpoint(endpoint, secret, payload, attempt + 1, {
|
|
329
|
+
maxAttempts,
|
|
330
|
+
baseDelayMs,
|
|
331
|
+
});
|
|
331
332
|
};
|
|
332
333
|
const tryInternalPublishEndpoints = async (endpoints, secret, payload, index = 0, lastError) => {
|
|
333
334
|
const endpoint = endpoints[index];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueueRuntimeRegistration.d.ts","sourceRoot":"","sources":["../../../../src/tools/queue/QueueRuntimeRegistration.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"QueueRuntimeRegistration.d.ts","sourceRoot":"","sources":["../../../../src/tools/queue/QueueRuntimeRegistration.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAsFjD,wBAAsB,+BAA+B,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAyCxF"}
|
|
@@ -11,6 +11,7 @@ import { autoRegisterJobStateTrackerPersistenceFromEnv } from '../queue/JobState
|
|
|
11
11
|
import { QueueReliabilityOrchestrator } from '../queue/QueueReliabilityOrchestrator.js';
|
|
12
12
|
import { InMemoryQueue } from '../queue/drivers/InMemory.js';
|
|
13
13
|
import { Queue } from '../queue/Queue.js';
|
|
14
|
+
const QUEUE_REDIS_PACKAGE = '@zintrust/queue-redis';
|
|
14
15
|
/**
|
|
15
16
|
* Register queue drivers from runtime config.
|
|
16
17
|
*
|
|
@@ -21,7 +22,7 @@ import { Queue } from '../queue/Queue.js';
|
|
|
21
22
|
*/
|
|
22
23
|
const registerRedisDriverIfAvailable = async () => {
|
|
23
24
|
try {
|
|
24
|
-
const mod = (await import(
|
|
25
|
+
const mod = (await import(/* @vite-ignore */ QUEUE_REDIS_PACKAGE));
|
|
25
26
|
if (mod.RedisQueue !== undefined) {
|
|
26
27
|
Queue.register('redis', mod.RedisQueue);
|
|
27
28
|
return true;
|