mqemitter-redis
Advanced tools
Comparing version 0.3.0 to 1.0.0
'use strict' | ||
var redis = require('redis') | ||
var Redis = require('ioredis') | ||
var MQEmitter = require('mqemitter') | ||
@@ -8,2 +8,3 @@ var shortid = require('shortid') | ||
var LRU = require('lru-cache') | ||
var msgpack = require('msgpack-lite') | ||
@@ -18,4 +19,4 @@ function MQEmitterRedis (opts) { | ||
this.subConn = createConn(opts) | ||
this.pubConn = createConn(opts) | ||
this.subConn = new Redis(opts) | ||
this.pubConn = new Redis(opts) | ||
@@ -32,3 +33,3 @@ this._topics = {} | ||
function handler (sub, topic, payload) { | ||
var packet = JSON.parse(payload) | ||
var packet = msgpack.decode(payload) | ||
if (!that._cache.get(packet.id)) { | ||
@@ -40,7 +41,7 @@ that._emit(packet.msg) | ||
this.subConn.on('message', function (topic, message) { | ||
this.subConn.on('messageBuffer', function (topic, message) { | ||
handler(topic, topic, message) | ||
}) | ||
this.subConn.on('pmessage', function (sub, topic, message) { | ||
this.subConn.on('pmessageBuffer', function (sub, topic, message) { | ||
handler(sub, topic, message) | ||
@@ -54,18 +55,3 @@ }) | ||
function createConn (opts) { | ||
var conn = redis.createClient(opts.port || null, | ||
opts.host || null, | ||
opts.redis) | ||
if (opts.password !== undefined) { | ||
conn.auth(opts.password) | ||
} | ||
conn.select(opts.db || 0) | ||
conn.retry_backoff = 5 | ||
return conn | ||
} | ||
['emit', 'on', 'removeListener', 'close'].forEach(function (name) { | ||
;['emit', 'on', 'removeListener', 'close'].forEach(function (name) { | ||
MQEmitterRedis.prototype['_' + name] = MQEmitterRedis.prototype[name] | ||
@@ -135,7 +121,6 @@ }) | ||
this.pubConn.publish(msg.topic, JSON.stringify(packet), function () { | ||
if (done) { | ||
setImmediate(done) | ||
} | ||
}) | ||
this.pubConn.publish(msg.topic, msgpack.encode(packet)) | ||
if (done) { | ||
setImmediate(done) | ||
} | ||
} | ||
@@ -142,0 +127,0 @@ |
{ | ||
"name": "mqemitter-redis", | ||
"version": "0.3.0", | ||
"version": "1.0.0", | ||
"description": "Redis-based MQEmitter", | ||
@@ -8,6 +8,7 @@ "main": "mqemitter-redis.js", | ||
"inherits": "^2.0.1", | ||
"mqemitter": "^0.4.0", | ||
"redis": "^0.12.1", | ||
"shortid": "^2.2.2", | ||
"lru-cache": "^2.6.4" | ||
"ioredis": "^1.13.2", | ||
"lru-cache": "^4.0.0", | ||
"mqemitter": "^1.0.0", | ||
"msgpack-lite": "^0.1.14", | ||
"shortid": "^2.2.2" | ||
}, | ||
@@ -17,5 +18,8 @@ "devDependencies": { | ||
"pre-commit": "^1.0.7", | ||
"standard": "^4.0.1", | ||
"standard": "^5.4.1", | ||
"tape": "^4.0.0" | ||
}, | ||
"optionalDependencies": { | ||
"hiredis": "^0.4.1" | ||
}, | ||
"scripts": { | ||
@@ -25,3 +29,6 @@ "lint": "standard", | ||
}, | ||
"pre-commit": ["lint", "test"], | ||
"pre-commit": [ | ||
"lint", | ||
"test" | ||
], | ||
"repository": { | ||
@@ -28,0 +35,0 @@ "type": "git", |
@@ -30,3 +30,3 @@ mqemitter-redis [![Build Status](https://travis-ci.org/mcollina/mqemitter-redis.png)](https://travis-ci.org/mcollina/mqemitter-redis) | ||
}) | ||
var msg = { | ||
var msg = { | ||
topic: 'hello world' | ||
@@ -33,0 +33,0 @@ payload: 'or any other fields' |
Sorry, the diff of this file is not supported yet
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
7639
7
139
+ Addedioredis@^1.13.2
+ Addedmsgpack-lite@^0.1.14
+ Addedbindings@1.5.0(transitive)
+ Addedbluebird@2.11.0(transitive)
+ Addeddebug@2.6.9(transitive)
+ Addeddouble-ended-queue@2.1.0-0(transitive)
+ Addedevent-lite@0.1.3(transitive)
+ Addedfastparallel@2.4.1(transitive)
+ Addedfile-uri-to-path@1.0.0(transitive)
+ Addedflexbuffer@0.0.6(transitive)
+ Addedhiredis@0.4.1(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedint64-buffer@0.1.10(transitive)
+ Addedioredis@1.15.1(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedlodash@3.10.1(transitive)
+ Addedlru-cache@4.1.5(transitive)
+ Addedmqemitter@1.0.0(transitive)
+ Addedms@2.0.0(transitive)
+ Addedmsgpack-lite@0.1.26(transitive)
+ Addednan@2.22.0(transitive)
+ Addedpseudomap@1.0.2(transitive)
+ Addedyallist@2.1.2(transitive)
- Removedredis@^0.12.1
- Removedfastparallel@1.7.2(transitive)
- Removedlru-cache@2.7.3(transitive)
- Removedmqemitter@0.4.0(transitive)
- Removedredis@0.12.1(transitive)
Updatedlru-cache@^4.0.0
Updatedmqemitter@^1.0.0