MCPcopy
hub / github.com/OptimalBits/bull / isRedisReady

Function isRedisReady

lib/utils.js:16–43  ·  view source on GitHub ↗

* Waits for a redis client to be ready. * @param {Redis} redis client

(client)

Source from the content-addressed store, hash-verified

14 * @param {Redis} redis client
15 */
16function isRedisReady(client) {
17 return new Promise((resolve, reject) => {
18 if (client.status === 'ready') {
19 resolve();
20 } else {
21 function handleReady() {
22 client.removeListener('end', handleEnd);
23 client.removeListener('error', handleError);
24 resolve();
25 }
26
27 let lastError;
28 function handleError(err) {
29 lastError = err;
30 }
31
32 function handleEnd() {
33 client.removeListener('ready', handleReady);
34 client.removeListener('error', handleError);
35 reject(lastError);
36 }
37
38 client.once('ready', handleReady);
39 client.on('error', handleError);
40 client.once('end', handleEnd);
41 }
42 });
43}
44
45module.exports.errorObject = errorObject;
46module.exports.tryCatch = tryCatch;

Callers 1

test_connection.jsFile · 0.85

Calls 1

onMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…