@zintrust/zedgi 3.0.1 → 3.0.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/README.md +9 -0
- package/dist/ZedgiMonitorDriver.d.ts +1 -0
- package/dist/ZedgiMonitorDriver.js +1 -0
- package/dist/ZedgiRuntime.js +21 -0
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,6 +31,10 @@ ZEDGI_REDIS_HEADER=
|
|
|
31
31
|
ZEDGI_QUEUE_HEADER=
|
|
32
32
|
ZEDGI_MYSQL_HEADER=
|
|
33
33
|
ZEDGI_POSTGRES_HEADER=
|
|
34
|
+
|
|
35
|
+
# Optional Redis credential profile for queues. Falls back to ZEDGI_REDIS_PROFILE.
|
|
36
|
+
ZEDGI_QUEUE_PROFILE=
|
|
37
|
+
ZEDGI_REDIS_PROFILE=
|
|
34
38
|
```
|
|
35
39
|
|
|
36
40
|
## Drivers
|
|
@@ -68,6 +72,11 @@ can be used for producers, monitoring, and consumers. When `QUEUE_CONNECTION` an
|
|
|
68
72
|
to `queue-zedgi` to keep workers, monitors, and producers on the same Zedgi-backed
|
|
69
73
|
Redis target.
|
|
70
74
|
|
|
75
|
+
When `ZEDGI_QUEUE_PROFILE` is set, the queue driver uses that named Redis
|
|
76
|
+
credential profile. ZinTrust registers the profile with the configured Redis DB
|
|
77
|
+
(`REDIS_QUEUE_DB` or `WORKERS_REDIS_QUEUE_DB`) so BullMQ keys are read from the
|
|
78
|
+
intended logical database.
|
|
79
|
+
|
|
71
80
|
## Registration
|
|
72
81
|
|
|
73
82
|
The package registers:
|
package/dist/ZedgiRuntime.js
CHANGED
|
@@ -112,6 +112,15 @@ const redisCredentialFromConfig = (config, fallbackHeaderKey) => {
|
|
|
112
112
|
credential['header'] = header;
|
|
113
113
|
return credential;
|
|
114
114
|
};
|
|
115
|
+
const resolveCredentialProfile = (config) => {
|
|
116
|
+
if (config === null || typeof config !== 'object')
|
|
117
|
+
return undefined;
|
|
118
|
+
const profile = config.profile;
|
|
119
|
+
if (typeof profile !== 'string')
|
|
120
|
+
return undefined;
|
|
121
|
+
const normalized = profile.trim();
|
|
122
|
+
return normalized === '' ? undefined : normalized;
|
|
123
|
+
};
|
|
115
124
|
const sqlCredentialFromConfig = (config, fallbackHeaderKey) => {
|
|
116
125
|
const credential = {};
|
|
117
126
|
if (hasText(config.username))
|
|
@@ -144,10 +153,22 @@ export const ZedgiRuntime = Object.freeze({
|
|
|
144
153
|
client = undefined;
|
|
145
154
|
},
|
|
146
155
|
redis(config = {}) {
|
|
156
|
+
const explicitProfile = resolveCredentialProfile(config);
|
|
157
|
+
if (explicitProfile !== undefined) {
|
|
158
|
+
const credential = redisCredentialFromConfig(config, 'ZEDGI_REDIS_HEADER');
|
|
159
|
+
registerProfile('redis', explicitProfile, credential);
|
|
160
|
+
return ensureClient().redis(explicitProfile);
|
|
161
|
+
}
|
|
147
162
|
const credential = memoizeCredential('redis', 'redis', redisCredentialFromConfig(config, 'ZEDGI_REDIS_HEADER'), redisCredentials);
|
|
148
163
|
return ensureClient().redis(getProfileName(credential));
|
|
149
164
|
},
|
|
150
165
|
queue(name, config = {}) {
|
|
166
|
+
const explicitProfile = resolveCredentialProfile(config);
|
|
167
|
+
if (explicitProfile !== undefined) {
|
|
168
|
+
const credential = redisCredentialFromConfig(config, 'ZEDGI_QUEUE_HEADER');
|
|
169
|
+
registerProfile('redis', explicitProfile, credential);
|
|
170
|
+
return ensureClient().queue(name, explicitProfile);
|
|
171
|
+
}
|
|
151
172
|
const credential = memoizeCredential('redis', 'redis', redisCredentialFromConfig(config, 'ZEDGI_QUEUE_HEADER'), redisCredentials);
|
|
152
173
|
return ensureClient().queue(name, getProfileName(credential));
|
|
153
174
|
},
|
package/dist/types.d.ts
CHANGED