@ladjs/redis
Advanced tools
Comparing version 1.0.6 to 1.0.7
12
index.js
@@ -38,4 +38,12 @@ const IORedis = require('ioredis'); | ||
function Redis(config = {}, logger = console, monitor = false) { | ||
// eslint-disable-next-line max-params | ||
function Redis( | ||
config = {}, | ||
logger = console, | ||
monitor = false, | ||
maxListeners = 15, | ||
_bindEvents = true | ||
) { | ||
const client = new IORedis(config); | ||
client.setMaxListeners(maxListeners); | ||
// https://github.com/luin/ioredis#monitor | ||
@@ -63,3 +71,3 @@ if (monitor) { | ||
bindEvents(client, logger); | ||
if (_bindEvents) bindEvents(client, logger); | ||
return client; | ||
@@ -66,0 +74,0 @@ } |
{ | ||
"name": "@ladjs/redis", | ||
"description": "Redis for Lad", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"author": "Nick Baugh <niftylettuce@gmail.com> (http://niftylettuce.com/)", | ||
@@ -6,0 +6,0 @@ "ava": { |
@@ -27,21 +27,21 @@ const test = require('ava'); | ||
case 'redis connection established': | ||
t.true(true); | ||
t.pass(); | ||
break; | ||
case 'redis connection ready': | ||
t.true(true); | ||
t.pass(); | ||
break; | ||
case 'redis connection closed': | ||
t.true(true); | ||
t.pass(); | ||
break; | ||
case 'redis reconnecting': | ||
t.true(true); | ||
t.pass(); | ||
break; | ||
case 'redis connection ended': | ||
t.true(true); | ||
t.pass(); | ||
break; | ||
case 'redis node connected': | ||
t.true(true); | ||
t.pass(); | ||
break; | ||
case 'redis node disconnected': | ||
t.true(true); | ||
t.pass(); | ||
break; | ||
@@ -55,6 +55,6 @@ default: | ||
case 'node error': | ||
t.true(true); | ||
t.pass(); | ||
break; | ||
case 'error': | ||
t.true(true); | ||
t.pass(); | ||
break; | ||
@@ -87,27 +87,27 @@ default: | ||
case 'redis monitor instance created': | ||
t.true(true); | ||
t.pass(); | ||
break; | ||
case 'redis monitor': | ||
t.true(true); | ||
t.pass(); | ||
break; | ||
case 'redis connection established': | ||
t.true(true); | ||
t.pass(); | ||
break; | ||
case 'redis connection ready': | ||
t.true(true); | ||
t.pass(); | ||
break; | ||
case 'redis connection closed': | ||
t.true(true); | ||
t.pass(); | ||
break; | ||
case 'redis reconnecting': | ||
t.true(true); | ||
t.pass(); | ||
break; | ||
case 'redis connection ended': | ||
t.true(true); | ||
t.pass(); | ||
break; | ||
case 'redis node connected': | ||
t.true(true); | ||
t.pass(); | ||
break; | ||
case 'redis node disconnected': | ||
t.true(true); | ||
t.pass(); | ||
break; | ||
@@ -122,6 +122,6 @@ default: | ||
case 'node error': | ||
t.true(true); | ||
t.pass(); | ||
break; | ||
case 'error': | ||
t.true(true); | ||
t.pass(); | ||
break; | ||
@@ -153,3 +153,3 @@ default: | ||
// console.debug(args); | ||
if (args[1].status === '[empty]') t.true(true); | ||
if (args[1].status === '[empty]') t.pass(); | ||
}; | ||
@@ -167,3 +167,3 @@ | ||
logger.error = (message) => { | ||
if (message === 'error') t.true(true); | ||
if (message === 'error') t.pass(); | ||
}; | ||
@@ -180,1 +180,46 @@ | ||
}); | ||
test('creates Redis with logger and does not bind events', async (t) => { | ||
const { logger } = t.context; | ||
logger.debug = (message) => { | ||
switch (message) { | ||
case 'redis connection established': | ||
t.fail(); | ||
break; | ||
case 'redis connection ready': | ||
t.fail(); | ||
break; | ||
case 'redis connection closed': | ||
t.fail(); | ||
break; | ||
case 'redis reconnecting': | ||
t.fail(); | ||
break; | ||
case 'redis connection ended': | ||
t.fail(); | ||
break; | ||
case 'redis node connected': | ||
t.fail(); | ||
break; | ||
case 'redis node disconnected': | ||
t.fail(); | ||
break; | ||
default: | ||
} | ||
}; | ||
const redis = await new Redis({}, logger, undefined, undefined, false); | ||
t.is(typeof redis, 'object'); | ||
redis.monitor(); | ||
await delay(1000); | ||
redis.emit('reconnecting'); | ||
redis.emit('+node'); | ||
redis.emit('-node'); | ||
redis.emit('node error', 'node error'); | ||
t.throws(() => { | ||
redis.emit('error', 'error'); | ||
}); | ||
redis.disconnect(); | ||
await delay(1000); | ||
}); |
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
12049
263
0
0