@zintrust/queue-redis 0.4.36 → 0.4.39
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/BullMQRedisQueue.js +48 -38
- package/dist/build-manifest.json +8 -8
- package/package.json +2 -2
package/dist/BullMQRedisQueue.js
CHANGED
|
@@ -28,6 +28,53 @@ export const BullMQRedisQueue = (() => {
|
|
|
28
28
|
const queues = new Map();
|
|
29
29
|
let sharedConnection = null;
|
|
30
30
|
let lockProviderCache = null;
|
|
31
|
+
const isRedisProxyEnabled = () => {
|
|
32
|
+
return Env.USE_REDIS_PROXY === true || Env.get('REDIS_PROXY_URL', '').trim() !== '';
|
|
33
|
+
};
|
|
34
|
+
const assertProxyAndWorkersCompatibility = (isWorkersRuntime) => {
|
|
35
|
+
if (isRedisProxyEnabled() && shouldUseHttpProxyDriver() === false) {
|
|
36
|
+
throw ErrorFactory.createConfigError('BullMQ Redis driver does not support REDIS proxy transport directly. Enable QUEUE_HTTP_PROXY_ENABLED=true for queue proxy mode, or disable REDIS proxy mode for direct BullMQ access.');
|
|
37
|
+
}
|
|
38
|
+
if (isWorkersRuntime && Cloudflare.isCloudflareSocketsEnabled() === false) {
|
|
39
|
+
throw ErrorFactory.createConfigError('BullMQ Redis driver requires ENABLE_CLOUDFLARE_SOCKETS=true in Cloudflare Workers. To use HTTP queue proxy mode, set QUEUE_HTTP_PROXY_ENABLED=true and QUEUE_HTTP_PROXY_URL.');
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const resolveQueueRedisConfig = () => {
|
|
43
|
+
const workersHost = Cloudflare.getWorkersVar('WORKERS_REDIS_HOST');
|
|
44
|
+
const workersPortRaw = Cloudflare.getWorkersVar('WORKERS_REDIS_PORT');
|
|
45
|
+
const workersPassword = Cloudflare.getWorkersVar('WORKERS_REDIS_PASSWORD');
|
|
46
|
+
const workersDbRaw = Cloudflare.getWorkersVar('WORKERS_REDIS_QUEUE_DB');
|
|
47
|
+
return {
|
|
48
|
+
host: workersHost !== null && workersHost.trim() !== '' ? workersHost.trim() : Env.REDIS_HOST,
|
|
49
|
+
port: workersPortRaw !== null && Number.isFinite(Number.parseInt(workersPortRaw, 10))
|
|
50
|
+
? Number.parseInt(workersPortRaw, 10)
|
|
51
|
+
: Env.REDIS_PORT,
|
|
52
|
+
password: workersPassword !== null && workersPassword.trim() !== ''
|
|
53
|
+
? workersPassword
|
|
54
|
+
: Env.REDIS_PASSWORD,
|
|
55
|
+
database: workersDbRaw !== null && Number.isFinite(Number.parseInt(workersDbRaw, 10))
|
|
56
|
+
? Number.parseInt(workersDbRaw, 10)
|
|
57
|
+
: Env.getInt('REDIS_QUEUE_DB', 0),
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
const assertWorkersHostIsReachable = (isWorkersRuntime, redisConfig) => {
|
|
61
|
+
if (isWorkersRuntime &&
|
|
62
|
+
(redisConfig.host === 'localhost' || redisConfig.host === '127.0.0.1')) {
|
|
63
|
+
throw ErrorFactory.createConfigError('Redis host cannot be localhost in Cloudflare Workers. Use a public Redis host, or enable queue HTTP proxy mode with QUEUE_HTTP_PROXY_ENABLED=true and QUEUE_HTTP_PROXY_URL.');
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const createSharedBullMqConnection = () => {
|
|
67
|
+
const isWorkersRuntime = Cloudflare.getWorkersEnv() !== null;
|
|
68
|
+
assertProxyAndWorkersCompatibility(isWorkersRuntime);
|
|
69
|
+
const redisConfig = resolveQueueRedisConfig();
|
|
70
|
+
assertWorkersHostIsReachable(isWorkersRuntime, redisConfig);
|
|
71
|
+
return createRedisConnection({
|
|
72
|
+
host: redisConfig.host,
|
|
73
|
+
port: redisConfig.port,
|
|
74
|
+
password: redisConfig.password,
|
|
75
|
+
db: redisConfig.database,
|
|
76
|
+
}, 3, { subsystem: 'queue-bullmq' });
|
|
77
|
+
};
|
|
31
78
|
const getDefaultLockDriveName = () => {
|
|
32
79
|
const driver = queueConfig.default;
|
|
33
80
|
return driver.length > 0 ? driver : ZintrustLang.REDIS;
|
|
@@ -59,44 +106,7 @@ export const BullMQRedisQueue = (() => {
|
|
|
59
106
|
const getSharedConnection = () => {
|
|
60
107
|
if (sharedConnection)
|
|
61
108
|
return sharedConnection;
|
|
62
|
-
|
|
63
|
-
const redisProxyEnabled = Env.USE_REDIS_PROXY === true || Env.get('REDIS_PROXY_URL', '').trim() !== '';
|
|
64
|
-
if (redisProxyEnabled && shouldUseHttpProxyDriver() === false) {
|
|
65
|
-
throw ErrorFactory.createConfigError('BullMQ Redis driver does not support REDIS proxy transport directly. Enable QUEUE_HTTP_PROXY_ENABLED=true for queue proxy mode, or disable REDIS proxy mode for direct BullMQ access.');
|
|
66
|
-
}
|
|
67
|
-
if (isWorkersRuntime && Cloudflare.isCloudflareSocketsEnabled() === false) {
|
|
68
|
-
throw ErrorFactory.createConfigError('BullMQ Redis driver requires ENABLE_CLOUDFLARE_SOCKETS=true in Cloudflare Workers. To use HTTP queue proxy mode, set QUEUE_HTTP_PROXY_ENABLED=true and QUEUE_HTTP_PROXY_URL.');
|
|
69
|
-
}
|
|
70
|
-
const workersHost = Cloudflare.getWorkersVar('WORKERS_REDIS_HOST');
|
|
71
|
-
const workersPortRaw = Cloudflare.getWorkersVar('WORKERS_REDIS_PORT');
|
|
72
|
-
const workersPassword = Cloudflare.getWorkersVar('WORKERS_REDIS_PASSWORD');
|
|
73
|
-
const workersDbRaw = Cloudflare.getWorkersVar('WORKERS_REDIS_QUEUE_DB');
|
|
74
|
-
const resolvedHost = workersHost !== null && workersHost.trim() !== '' ? workersHost.trim() : Env.REDIS_HOST;
|
|
75
|
-
const resolvedPort = workersPortRaw !== null && Number.isFinite(Number.parseInt(workersPortRaw, 10))
|
|
76
|
-
? Number.parseInt(workersPortRaw, 10)
|
|
77
|
-
: Env.REDIS_PORT;
|
|
78
|
-
const resolvedPassword = workersPassword !== null && workersPassword.trim() !== ''
|
|
79
|
-
? workersPassword
|
|
80
|
-
: Env.REDIS_PASSWORD;
|
|
81
|
-
const resolvedDb = workersDbRaw !== null && Number.isFinite(Number.parseInt(workersDbRaw, 10))
|
|
82
|
-
? Number.parseInt(workersDbRaw, 10)
|
|
83
|
-
: Env.getInt('REDIS_QUEUE_DB', 0);
|
|
84
|
-
const redisConfig = {
|
|
85
|
-
host: resolvedHost,
|
|
86
|
-
port: resolvedPort,
|
|
87
|
-
password: resolvedPassword,
|
|
88
|
-
database: resolvedDb,
|
|
89
|
-
};
|
|
90
|
-
if (isWorkersRuntime &&
|
|
91
|
-
(redisConfig.host === 'localhost' || redisConfig.host === '127.0.0.1')) {
|
|
92
|
-
throw ErrorFactory.createConfigError('Redis host cannot be localhost in Cloudflare Workers. Use a public Redis host, or enable queue HTTP proxy mode with QUEUE_HTTP_PROXY_ENABLED=true and QUEUE_HTTP_PROXY_URL.');
|
|
93
|
-
}
|
|
94
|
-
sharedConnection = createRedisConnection({
|
|
95
|
-
host: redisConfig.host,
|
|
96
|
-
port: redisConfig.port,
|
|
97
|
-
password: redisConfig.password,
|
|
98
|
-
db: redisConfig.database,
|
|
99
|
-
}, 3, { subsystem: 'queue-bullmq' });
|
|
109
|
+
sharedConnection = createSharedBullMqConnection();
|
|
100
110
|
return sharedConnection; // sharedConnection is IoRedis (compatible with BullMQ)
|
|
101
111
|
};
|
|
102
112
|
const waitForRedisReady = async (client, timeoutMs) => {
|
package/dist/build-manifest.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zintrust/queue-redis",
|
|
3
|
-
"version": "0.4.
|
|
4
|
-
"buildDate": "2026-03-
|
|
3
|
+
"version": "0.4.39",
|
|
4
|
+
"buildDate": "2026-03-30T20:12:42.664Z",
|
|
5
5
|
"buildEnvironment": {
|
|
6
6
|
"node": "v22.22.1",
|
|
7
7
|
"platform": "darwin",
|
|
8
8
|
"arch": "arm64"
|
|
9
9
|
},
|
|
10
10
|
"git": {
|
|
11
|
-
"commit": "
|
|
11
|
+
"commit": "0d093bc6",
|
|
12
12
|
"branch": "release"
|
|
13
13
|
},
|
|
14
14
|
"package": {
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"sha256": "52fb0f688cd17cc7d8e8128e60df6f5eea4c803282382ac75550e6aacee7cbb0"
|
|
30
30
|
},
|
|
31
31
|
"BullMQRedisQueue.js": {
|
|
32
|
-
"size":
|
|
33
|
-
"sha256": "
|
|
32
|
+
"size": 21034,
|
|
33
|
+
"sha256": "4432bacf5e54fe24a8d7aec9f228db5f8c1ea827e9584709b922aecb126942da"
|
|
34
34
|
},
|
|
35
35
|
"HttpQueueDriver.d.ts": {
|
|
36
36
|
"size": 835,
|
|
@@ -65,8 +65,8 @@
|
|
|
65
65
|
"sha256": "dc8b2c28b2e288e048423067f90ffbe0389ac813086246a1c8fafeeeab5c142d"
|
|
66
66
|
},
|
|
67
67
|
"build-manifest.json": {
|
|
68
|
-
"size":
|
|
69
|
-
"sha256": "
|
|
68
|
+
"size": 2513,
|
|
69
|
+
"sha256": "91ec17322539b8ed460e0d916878c0ed23ba67537d3c68c08488e3776ac3e35b"
|
|
70
70
|
},
|
|
71
71
|
"index.d.ts": {
|
|
72
72
|
"size": 565,
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
},
|
|
75
75
|
"index.js": {
|
|
76
76
|
"size": 677,
|
|
77
|
-
"sha256": "
|
|
77
|
+
"sha256": "af7ad24e2f89f39773f97c4f7bd1998c8f1507eb48ab5a563bd3a6cf86a11ef3"
|
|
78
78
|
},
|
|
79
79
|
"register.d.ts": {
|
|
80
80
|
"size": 169,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zintrust/queue-redis",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.39",
|
|
4
4
|
"description": "Redis queue driver for ZinTrust.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"node": ">=20.0.0"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@zintrust/core": "^0.4.
|
|
26
|
+
"@zintrust/core": "^0.4.39"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@zintrust/core": "file:../../dist"
|