New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

redis-ccp-queue

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redis-ccp-queue - npm Package Compare versions

Comparing version

to
1.0.4

44

lib/index.js
'use strict';
const Redis = require('ioredis');
const debug = require('debug')('redis-ccp-queue');

@@ -34,8 +35,15 @@ // -----------------------------------

this.redis.brpop(this.queueKey, this.timeout, (err, replies) => {
if (err && this.shuttingDown) return;
let data = replies[ 1 ] || '';
if (data && typeof data === 'string' && data.length > 1 && data[ 0 ] == '{' && data[ data.length - 1 ] == '}') {
data = JSON.parse(data);
if (err) {
if (this.shuttingDown) {
return
} else {
callback(null);
}
} else {
let data = replies[1] || '';
if (data && typeof data === 'string' && data.length > 1 && data[0] == '{' && data[data.length - 1] == '}') {
data = JSON.parse(data);
}
callback(data);
}
callback(data);
});

@@ -54,3 +62,3 @@ };

this.shuttingDown = true;
console.log('shutting down');
debug('shutting down');
try {

@@ -104,5 +112,10 @@ this.redis.disconnect();

let self = this;
process
.once('SIGINT', this.queue.shutdown)
.once('SIGTERM', this.queue.shutdown);
.once('SIGINT', function () {
self.queue.shutdown()
})
.once('SIGTERM', function () {
self.queue.shutdown()
});

@@ -114,5 +127,14 @@ this.waitForNext(this);

self.queue.pop((data) => {
self.callback(data, function() {
self.done();
})
if (!self.queue.shuttingDown) {
if (data === null) {
self.done();
} else {
self.callback(data, function() {
self.done();
})
}
} else {
debug('exit');
process.exit(1);
}
});

@@ -119,0 +141,0 @@ }

{
"name": "redis-ccp-queue",
"version": "1.0.3",
"version": "1.0.4",
"description": "A simple and lightweight Competing Consumers Pattern Queue",

@@ -27,4 +27,5 @@ "license": "MIT",

"dependencies": {
"debug": "^2.2.0",
"ioredis": "^1.15.1"
}
}

@@ -191,2 +191,3 @@ # redis-ccp-queue

| -------------- | -------------- | -------- |
| 1.0.4 | 2016-03-03 | correct termination of consumer on SIGINT, SIGTERM |
| 1.0.3 | 2016-03-01 | changed .gitignore |

@@ -193,0 +194,0 @@ | 1.0.2 | 2016-03-01 | bug in dependencies |