Comparing version 0.8.5 to 0.9.0
# CHANGELOG for rsmq | ||
## 0.9.0 | ||
* Added realtime option for Redis PUB/SUB when a new message is sent to RSMQ | ||
* Added tests for realtime | ||
* Added Travis tests for Node 10 | ||
* Updated dependencies (lodash and dev.async) | ||
## 0.8.4 | ||
@@ -4,0 +11,0 @@ |
17
index.js
@@ -10,3 +10,3 @@ // Generated by CoffeeScript 1.12.7 | ||
Copyright © 2013-2016 Patrick Liess, http://www.tcs.de | ||
Copyright © 2013-2018 Patrick Liess, http://www.tcs.de | ||
@@ -62,4 +62,6 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
client: null, | ||
ns: "rsmq" | ||
ns: "rsmq", | ||
realtime: false | ||
}, options); | ||
this.realtime = opts.realtime; | ||
this.redisns = opts.ns + ":"; | ||
@@ -418,3 +420,3 @@ if (((ref = opts.client) != null ? (ref1 = ref.constructor) != null ? ref1.name : void 0 : void 0) === "RedisClient") { | ||
return function(err, q) { | ||
var mc, ref; | ||
var key, mc, ref; | ||
if (err) { | ||
@@ -436,3 +438,7 @@ _this._handleError(cb, err); | ||
} | ||
mc = [["zadd", "" + _this.redisns + options.qname, q.ts + options.delay * 1000, q.uid], ["hset", "" + _this.redisns + options.qname + ":Q", q.uid, options.message], ["hincrby", "" + _this.redisns + options.qname + ":Q", "totalsent", 1]]; | ||
key = "" + _this.redisns + options.qname; | ||
mc = [["zadd", key, q.ts + options.delay * 1000, q.uid], ["hset", key + ":Q", q.uid, options.message], ["hincrby", key + ":Q", "totalsent", 1]]; | ||
if (_this.realtime) { | ||
mc.push(["zcard", key]); | ||
} | ||
_this.redis.multi(mc).exec(function(err, resp) { | ||
@@ -443,2 +449,5 @@ if (err) { | ||
} | ||
if (_this.realtime) { | ||
_this.redis.publish(_this.redisns + "rt:" + options.qname, resp[3]); | ||
} | ||
cb(null, q.uid); | ||
@@ -445,0 +454,0 @@ }); |
{ | ||
"name": "rsmq", | ||
"description": "A really simple message queue based on Redis", | ||
"version": "0.8.5", | ||
"version": "0.9.0", | ||
"license": "MIT", | ||
@@ -16,3 +16,3 @@ "author": "P. Liess <smrchy+npm@gmail.com>", | ||
"@types/redis": "^2.8.0", | ||
"lodash": "^4.17.4", | ||
"lodash": "^4.17.10", | ||
"redis": "^2.8.0" | ||
@@ -24,3 +24,3 @@ }, | ||
"devDependencies": { | ||
"async": "^2.5.0", | ||
"async": "^2.6.1", | ||
"coffee-script": "^1.12.7", | ||
@@ -27,0 +27,0 @@ "mocha": "^4.0.1", |
@@ -72,5 +72,6 @@ ![RSMQ: Redis Simple Message Queue for Node.js](https://img.webmart.de/rsmq_wide.png) | ||
* `port` (Number): *optional (Default: 6379)* The Redis port | ||
* `options` (Object): *optional (Default: {})* The Redis [https://github.com/NodeRedis/node_redis#options-object-properties](https://github.com/NodeRedis/node_redis#options-object-properties) `options` object. | ||
* `options` (Object): *optional (Default: {})* The [Redis options](https://github.com/NodeRedis/node_redis#options-object-properties) object. | ||
* `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 | ||
* `realtime` (Boolean): *optional (Default: false)* Enable realtime PUBLISH of new messages (see the [Realtime section](#realtime)) | ||
@@ -332,2 +333,16 @@ | ||
## Realtime | ||
When [initializing](#initialize) RSMQ you can enable the realtime PUBLISH for new messages. On every new message that gets sent to RSQM via `sendMessage` a Redis PUBLISH will be issued to `{{rsmq.ns}:rt:{qname}. | ||
Example for RSMQ with default settings: | ||
* The queue `testQueue` already contains 5 messages. | ||
* A new message is being sent to the queue `testQueue`. | ||
* The following Redis command will be issued: `PUBLISH rsmq:rt:testQueue 6` | ||
### How to use the realtime option | ||
Besides the PUBLISH when a new message is sent to RSMQ nothing else will happen. Your app could use the Redis SUBSCRIBE command to be notified of new messages and issue a `receiveMessage` then. However make sure not to listen with multiple workers for new messages with SUBSCRIBE to prevent multiple simultaneous `receiveMessage` calls. | ||
## Changes | ||
@@ -334,0 +349,0 @@ |
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
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
46775
850
371
0
Updatedlodash@^4.17.10