nodecaf-redis
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -8,2 +8,7 @@ # Nodecaf Redis Changelog | ||
## [v0.0.3] - 2021-07-14 | ||
### Fixed | ||
- bug running `SUBSCRIBE` even when failed to connect | ||
## [v0.0.2] - 2021-07-14 | ||
@@ -19,1 +24,2 @@ | ||
[v0.0.2]: https://gitlab.com/nodecaf/redis/-/tags/v0.0.2 | ||
[v0.0.3]: https://gitlab.com/nodecaf/redis/-/tags/v0.0.3 |
@@ -6,11 +6,13 @@ | ||
return new Promise( (done, fail) => { | ||
const end = () => fail(new Error('Redis connection aborted')); | ||
client.once('error', fail); | ||
const end = err => { | ||
fail(err || new Error('Redis connection aborted')); | ||
}; | ||
client.once('error', end); | ||
client.once('end', end); | ||
client.once('connect', () => { | ||
client.off('error', fail); | ||
client.once('ready', () => { | ||
client.off('error', end); | ||
client.off('end', end); | ||
done(); | ||
}); | ||
}) | ||
}); | ||
} | ||
@@ -21,11 +23,12 @@ | ||
let promises = []; | ||
const promises = []; | ||
conf['retry_strategy'] = () => new Error('Redis connection failed'); | ||
let client = redis.createClient(conf); | ||
const client = redis.createClient(conf); | ||
promises.push(initClient(client)); | ||
let subClient; | ||
if(subChannel && onMessage){ | ||
var subClient = redis.createClient(conf); | ||
subClient = redis.createClient(conf); | ||
promises.push(initClient(subClient)); | ||
@@ -35,3 +38,2 @@ | ||
subClient.on('message', onMessage); | ||
subClient.subscribe(subChannel); | ||
} | ||
@@ -46,3 +48,5 @@ | ||
subChannel && onMessage && subClient.subscribe(subChannel); | ||
return client; | ||
} |
{ | ||
"name": "nodecaf-redis", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "A conveninent interface around node redis to work within a nodecaf app.", | ||
@@ -5,0 +5,0 @@ "main": "lib/main.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8726
57