Socket
Socket
Sign inDemoInstall

rsmq

Package Overview
Dependencies
27
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.3.2 to 0.3.3

4

CHANGELOG.md
# CHANGELOG for rsmq
0.3.2
* Added constructor option `client` to reuse existing redis clients
0.3.1

@@ -4,0 +8,0 @@

83

index.js

@@ -1,2 +0,2 @@

// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.6.3
/*

@@ -20,4 +20,6 @@ rsmq

(function() {
var RedisInst, RedisSMQ, crypto, eventEmitter, events, _,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
var EventEmitter, RedisInst, RedisSMQ, crypto, _,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

@@ -30,10 +32,10 @@ crypto = require("crypto");

events = require("events");
EventEmitter = require("events").EventEmitter;
eventEmitter = new events.EventEmitter();
RedisSMQ = (function(_super) {
__extends(RedisSMQ, _super);
RedisSMQ = (function() {
function RedisSMQ(options) {
var opts;
var opts, _ref, _ref1,
_this = this;
if (options == null) {

@@ -58,8 +60,28 @@ options = {};

port: 6379,
client: null,
ns: "rsmq"
}, options);
this.redisns = opts.ns + ":";
this.redis = RedisInst.createClient(opts.port, opts.host);
this.initScript();
if (((_ref = opts.client) != null ? (_ref1 = _ref.constructor) != null ? _ref1.name : void 0 : void 0) === "RedisClient") {
this.redis = opts.client;
} else {
this.redis = RedisInst.createClient(opts.port, opts.host);
}
this.connected = this.redis.connected || false;
this.redis.on("connect", function() {
_this.connected = true;
_this.emit("connect");
_this.initScript();
});
this.redis.on("error", function(err) {
if (err.message.indexOf("ECONNREFUSED")) {
_this.connected = false;
_this.emit("disconnect");
} else {
console.error("Redis ERROR", err);
_this.emit("error");
}
});
this._initErrors();
return;
}

@@ -70,7 +92,5 @@

_this = this;
mc = [["hmget", "" + this.redisns + qname + ":Q", "vt", "delay", "maxsize"], ["time"]];
this.redis.multi(mc).exec(function(err, resp) {
var ms, q, ts;
if (err) {

@@ -102,3 +122,2 @@ _this._handleError(cb, err);

var _this = this;
if (this._validate(options, ["qname", "id", "vt"], cb) === false) {

@@ -116,3 +135,3 @@ return;

}
changeMessageVisibility.on('changeMessageVisibility', function() {
changeMessageVisibility.on('scriptload:changeMessageVisibility', function() {
_this._changeMessageVisibility(options, q, cb);

@@ -125,6 +144,5 @@ });

var _this = this;
this.redis.evalsha(this.changeMessageVisibility_sha1, 3, "" + this.redisns + options.qname, options.id, q.ts + options.vt * 1000, function(err, resp) {
if (err) {
_handleError(cb, err);
_this._handleError(cb, err);
return;

@@ -139,3 +157,2 @@ }

_this = this;
options.vt = (_ref = options.vt) != null ? _ref : 30;

@@ -149,3 +166,2 @@ options.delay = (_ref1 = options.delay) != null ? _ref1 : 0;

var mc;
if (err) {

@@ -167,3 +183,3 @@ _this._handleError(cb, err);

if (err) {
_handleError(cb, err);
_this._handleError(cb, err);
return;

@@ -180,3 +196,2 @@ }

_this = this;
if (this._validate(options, ["qname", "id"], cb) === false) {

@@ -203,3 +218,2 @@ return;

_this = this;
if (this._validate(options, ["qname"], cb) === false) {

@@ -226,3 +240,2 @@ return;

_this = this;
if (this._validate(options, ["qname"], cb) === false) {

@@ -234,3 +247,2 @@ return;

var mc;
if (err) {

@@ -243,3 +255,2 @@ _this._handleError(cb, err);

var o;
if (err) {

@@ -272,3 +283,2 @@ _this._handleError(cb, err);

_this = this;
script_receiveMessage = 'local msg = redis.call("ZRANGEBYSCORE", KEYS[1], "-inf", KEYS[2], "LIMIT", "0", "1")\

@@ -299,7 +309,7 @@ if #msg == 0 then\

_this.receiveMessage_sha1 = resp;
eventEmitter.emit('receiveMessage', 'ready');
_this.emit('scriptload:receiveMessage');
});
this.redis.script("load", script_changeMessageVisibility, function(err, resp) {
_this.changeMessageVisibility_sha1 = resp;
eventEmitter.emit('changeMessageVisibility', 'ready');
_this.emit('scriptload:changeMessageVisibility');
});

@@ -310,3 +320,2 @@ };

var _this = this;
this.redis.smembers("" + this.redisns + "QUEUES", function(err, resp) {

@@ -323,3 +332,2 @@ if (err) {

var _this = this;
if (this._validate(options, ["qname"], cb) === false) {

@@ -330,3 +338,2 @@ return;

var _ref;
if (err) {

@@ -344,3 +351,3 @@ _this._handleError(cb, err);

}
eventEmitter.on('receiveMessage', function() {
_this.on('scriptload:receiveMessage', function() {
_this._receiveMessage(options, q, cb);

@@ -353,8 +360,6 @@ });

var _this = this;
this.redis.evalsha(this.receiveMessage_sha1, 3, "" + this.redisns + options.qname, q.ts, q.ts + options.vt * 1000, function(err, resp) {
var o;
if (err) {
_handleError(cb, err);
_this._handleError(cb, err);
return;

@@ -379,3 +384,2 @@ }

var _this = this;
if (this._validate(options, ["qname"], cb) === false) {

@@ -386,3 +390,2 @@ return;

var mc, _ref;
if (err) {

@@ -407,3 +410,3 @@ _this._handleError(cb, err);

if (err) {
_handleError(cb, err);
_this._handleError(cb, err);
return;

@@ -422,3 +425,2 @@ }

var _err, _ref;
if (data == null) {

@@ -439,3 +441,2 @@ data = {};

var key, msg, _ref;
this._ERRORS = {};

@@ -451,3 +452,2 @@ _ref = this.ERRORS;

var i, possible, text, _i;
text = "";

@@ -468,3 +468,2 @@ possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

var item, _i, _len;
for (_i = 0, _len = items.length; _i < _len; _i++) {

@@ -528,3 +527,3 @@ item = items[_i];

})();
})(EventEmitter);

@@ -531,0 +530,0 @@ module.exports = RedisSMQ;

{
"name": "rsmq",
"description": "A really simple message queue based on Redis",
"version": "0.3.2",
"version": "0.3.3",
"author": "P. Liess <smrchy+npm@gmail.com>",

@@ -6,0 +6,0 @@ "engines": {

@@ -53,2 +53,3 @@ # rsmq

* `port` (Number): *optional (Default: 6379)* The Redis port
* `client` (RedisClient): *optional* A existing redis client instance. `host` and `server` will be ignored.
* `ns` (String): *optional (Default: "rsmq")* The namespace prefix used for all keys created by **rsmq**

@@ -55,0 +56,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc