@adalo/metrics 0.1.66 → 0.1.67
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/lib/redisUtils.d.ts +1 -1
- package/lib/redisUtils.d.ts.map +1 -1
- package/lib/redisUtils.js +10 -2
- package/lib/redisUtils.js.map +1 -1
- package/package.json +1 -1
- package/src/redisUtils.js +14 -7
package/lib/redisUtils.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export function createSetClientNameForIoredis(defaultAppName?: string | undefine
|
|
|
23
23
|
* Check if a Redis client is an ioredis instance
|
|
24
24
|
*
|
|
25
25
|
* @param {any} client - Redis client instance
|
|
26
|
-
* @returns {boolean} True if the client is ioredis
|
|
26
|
+
* @returns {boolean} True if the client is ioredis
|
|
27
27
|
*/
|
|
28
28
|
export function isIORedis(client: any): boolean;
|
|
29
29
|
//# sourceMappingURL=redisUtils.d.ts.map
|
package/lib/redisUtils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redisUtils.d.ts","sourceRoot":"","sources":["../src/redisUtils.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,6FAFsB,GAAG,QAAQ,MAAM,KAAK,IAAI,CAuB/C;AA4BD;;;;;GAKG;AACH,6FAFsB,GAAG,QAAQ,MAAM,KAAK,IAAI,CAsB/C;AApDD;;;;;GAKG;AACH,6FAFsB,GAAG,QAAQ,MAAM,KAAK,IAAI,CAoB/C;AA8BD;;;;;GAKG;AACH,kCAHW,GAAG,GACD,OAAO,
|
|
1
|
+
{"version":3,"file":"redisUtils.d.ts","sourceRoot":"","sources":["../src/redisUtils.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,6FAFsB,GAAG,QAAQ,MAAM,KAAK,IAAI,CAuB/C;AA4BD;;;;;GAKG;AACH,6FAFsB,GAAG,QAAQ,MAAM,KAAK,IAAI,CAsB/C;AApDD;;;;;GAKG;AACH,6FAFsB,GAAG,QAAQ,MAAM,KAAK,IAAI,CAoB/C;AA8BD;;;;;GAKG;AACH,kCAHW,GAAG,GACD,OAAO,CAiBnB"}
|
package/lib/redisUtils.js
CHANGED
|
@@ -73,10 +73,18 @@ const createSetClientNameForRedisV4 = (defaultAppName = 'undefined-app') => {
|
|
|
73
73
|
* Check if a Redis client is an ioredis instance
|
|
74
74
|
*
|
|
75
75
|
* @param {any} client - Redis client instance
|
|
76
|
-
* @returns {boolean} True if the client is ioredis
|
|
76
|
+
* @returns {boolean} True if the client is ioredis
|
|
77
77
|
*/
|
|
78
78
|
const isIORedis = client => {
|
|
79
|
-
|
|
79
|
+
const result = client && typeof client.sendCommand === 'function' && typeof client.disconnect === 'function' && client.options !== undefined;
|
|
80
|
+
console.log('[debug] isIORedis client.sendCommand:', client.sendCommand);
|
|
81
|
+
console.log('[debug] isIORedis client.sendCommand === \'function\':', typeof client.sendCommand === 'function');
|
|
82
|
+
console.log('[debug] isIORedis client.disconnect:', client.disconnect);
|
|
83
|
+
console.log('[debug] isIORedis client.disconnect === \'function\':', typeof client.disconnect === 'function');
|
|
84
|
+
console.log('[debug] isIORedis client.options:', client.options);
|
|
85
|
+
console.log('[debug] isIORedis client.options !== undefined:', client.options !== undefined);
|
|
86
|
+
console.log('[debug] isIORedis check:', result, 'constructor:', client?.constructor?.name);
|
|
87
|
+
return result;
|
|
80
88
|
};
|
|
81
89
|
module.exports = {
|
|
82
90
|
createSetClientNameForRedisV3,
|
package/lib/redisUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redisUtils.js","names":["createSetClientNameForRedisV3","defaultAppName","client","name","appName","process","env","METRICS_APP_NAME","dyno","BUILD_DYNO_PROCESS_TYPE","NODE_ENV","on","send_command","err","console","error","log","pid","createSetClientNameForIoredis","once","call","then","catch","createSetClientNameForRedisV4","sendCommand","isIORedis","
|
|
1
|
+
{"version":3,"file":"redisUtils.js","names":["createSetClientNameForRedisV3","defaultAppName","client","name","appName","process","env","METRICS_APP_NAME","dyno","BUILD_DYNO_PROCESS_TYPE","NODE_ENV","on","send_command","err","console","error","log","pid","createSetClientNameForIoredis","once","call","then","catch","createSetClientNameForRedisV4","sendCommand","isIORedis","result","disconnect","options","undefined","constructor","module","exports"],"sources":["../src/redisUtils.js"],"sourcesContent":["/**\n * Creates a configured setClientName function for node-redis v3.\n *\n * @param {string} [defaultAppName='undefined-app'] - Fallback app name if METRICS_APP_NAME is not set.\n * @returns {(client: any, name: string) => void}\n */\nconst createSetClientNameForRedisV3 = (defaultAppName = 'undefined-app') => {\n return (client, name) => {\n const appName = process.env.METRICS_APP_NAME || defaultAppName\n const dyno = process.env.BUILD_DYNO_PROCESS_TYPE || 'undefined-dyno'\n\n if (process.env.NODE_ENV !== 'test') {\n client.on('connect', () => {\n client.send_command(\n 'CLIENT',\n ['SETNAME', `${appName}:${dyno}:${name}`],\n err => {\n if (err) {\n console.error(`Failed to set client name for ${name}:`, err)\n } else {\n console.log(`Connected to Redis for pid:${process.pid} (${name})`)\n }\n }\n )\n })\n }\n }\n}\n\n/**\n * Creates a function to set Redis client name for ioredis.\n *\n * @param {string} [defaultAppName='undefined-app']\n * @returns {(client: any, name: string) => void}\n */\nconst createSetClientNameForIoredis = (defaultAppName = 'undefined-app') => {\n return (client, name) => {\n const appName = process.env.METRICS_APP_NAME || defaultAppName\n const dyno = process.env.BUILD_DYNO_PROCESS_TYPE || 'undefined-dyno'\n\n if (process.env.NODE_ENV !== 'test') {\n client.once('connect', () => {\n client\n .call('CLIENT', ['SETNAME', `${appName}:${dyno}:${name}`])\n .then(() => {\n console.log(`Connected to Redis for pid:${process.pid} (${name})`)\n })\n .catch(err => {\n console.error(`Failed to set client name for ${name}:`, err)\n })\n })\n }\n }\n}\n\n/**\n * Creates a function to set Redis client name for node-redis v4.\n *\n * @param {string} [defaultAppName='undefined-app']\n * @returns {(client: any, name: string) => void}\n */\nconst createSetClientNameForRedisV4 = (defaultAppName = 'undefined-app') => {\n return (client, name) => {\n const appName = process.env.METRICS_APP_NAME || defaultAppName\n const dyno = process.env.BUILD_DYNO_PROCESS_TYPE || 'undefined-dyno'\n\n if (process.env.NODE_ENV !== 'test') {\n client.on('ready', async () => {\n try {\n await client.sendCommand([\n 'CLIENT',\n 'SETNAME',\n `${appName}:${dyno}:${name}`,\n ])\n console.log(`Connected to Redis for pid:${process.pid} (${name})`)\n } catch (err) {\n console.error(`Failed to set client name for ${name}:`, err)\n }\n })\n }\n }\n}\n\n/**\n * Check if a Redis client is an ioredis instance\n *\n * @param {any} client - Redis client instance\n * @returns {boolean} True if the client is ioredis\n */\nconst isIORedis = client => {\n const result =\n client &&\n typeof client.sendCommand === 'function' &&\n typeof client.disconnect === 'function' &&\n client.options !== undefined;\n console.log('[debug] isIORedis client.sendCommand:', client.sendCommand);\n console.log('[debug] isIORedis client.sendCommand === \\'function\\':', typeof client.sendCommand === 'function');\n console.log('[debug] isIORedis client.disconnect:', client.disconnect);\n console.log('[debug] isIORedis client.disconnect === \\'function\\':', typeof client.disconnect === 'function');\n console.log('[debug] isIORedis client.options:', client.options);\n console.log('[debug] isIORedis client.options !== undefined:', client.options !== undefined);\n\n console.log('[debug] isIORedis check:', result, 'constructor:', client?.constructor?.name);\n return result;\n};\n\nmodule.exports = {\n createSetClientNameForRedisV3,\n createSetClientNameForRedisV4,\n createSetClientNameForIoredis,\n isIORedis,\n}\n"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,6BAA6B,GAAGA,CAACC,cAAc,GAAG,eAAe,KAAK;EAC1E,OAAO,CAACC,MAAM,EAAEC,IAAI,KAAK;IACvB,MAAMC,OAAO,GAAGC,OAAO,CAACC,GAAG,CAACC,gBAAgB,IAAIN,cAAc;IAC9D,MAAMO,IAAI,GAAGH,OAAO,CAACC,GAAG,CAACG,uBAAuB,IAAI,gBAAgB;IAEpE,IAAIJ,OAAO,CAACC,GAAG,CAACI,QAAQ,KAAK,MAAM,EAAE;MACnCR,MAAM,CAACS,EAAE,CAAC,SAAS,E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,CAAC;EACtEb,OAAO,CAACE,GAAG,CAAC,uDAAuD,EAAE,OAAOd,MAAM,CAACyB,UAAU,KAAK,UAAU,CAAC;EAC7Gb,OAAO,CAACE,GAAG,CAAC,mCAAmC,EAAEd,MAAM,CAAC0B,OAAO,CAAC;EAChEd,OAAO,CAACE,GAAG,CAAC,iDAAiD,EAAEd,MAAM,CAAC0B,OAAO,KAAKC,SAAS,CAAC;EAE5Ff,OAAO,CAACE,GAAG,CAAC,0BAA0B,EAAEU,MAAM,EAAE,cAAc,EAAExB,MAAM,EAAE4B,WAAW,EAAE3B,IAAI,CAAC;EAC1F,OAAOuB,MAAM;AACf,CAAC;AAEDK,MAAM,CAACC,OAAO,GAAG;EACfhC,6BAA6B;EAC7BuB,6BAA6B;EAC7BL,6BAA6B;EAC7BO;AACF,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
package/src/redisUtils.js
CHANGED
|
@@ -85,17 +85,24 @@ const createSetClientNameForRedisV4 = (defaultAppName = 'undefined-app') => {
|
|
|
85
85
|
* Check if a Redis client is an ioredis instance
|
|
86
86
|
*
|
|
87
87
|
* @param {any} client - Redis client instance
|
|
88
|
-
* @returns {boolean} True if the client is ioredis
|
|
88
|
+
* @returns {boolean} True if the client is ioredis
|
|
89
89
|
*/
|
|
90
90
|
const isIORedis = client => {
|
|
91
|
-
|
|
91
|
+
const result =
|
|
92
92
|
client &&
|
|
93
|
-
typeof client.
|
|
93
|
+
typeof client.sendCommand === 'function' &&
|
|
94
94
|
typeof client.disconnect === 'function' &&
|
|
95
|
-
client.
|
|
96
|
-
|
|
97
|
-
)
|
|
98
|
-
|
|
95
|
+
client.options !== undefined;
|
|
96
|
+
console.log('[debug] isIORedis client.sendCommand:', client.sendCommand);
|
|
97
|
+
console.log('[debug] isIORedis client.sendCommand === \'function\':', typeof client.sendCommand === 'function');
|
|
98
|
+
console.log('[debug] isIORedis client.disconnect:', client.disconnect);
|
|
99
|
+
console.log('[debug] isIORedis client.disconnect === \'function\':', typeof client.disconnect === 'function');
|
|
100
|
+
console.log('[debug] isIORedis client.options:', client.options);
|
|
101
|
+
console.log('[debug] isIORedis client.options !== undefined:', client.options !== undefined);
|
|
102
|
+
|
|
103
|
+
console.log('[debug] isIORedis check:', result, 'constructor:', client?.constructor?.name);
|
|
104
|
+
return result;
|
|
105
|
+
};
|
|
99
106
|
|
|
100
107
|
module.exports = {
|
|
101
108
|
createSetClientNameForRedisV3,
|