Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copy redis pass to pubsub when host/port the same #7

Merged
merged 3 commits into from
Jul 31, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

# 1.0.7 - 2017-07-31

- apply config [opts] to pubsub settings #7

# 1.0.6 - 2017-06-16

- eslint 4 compat
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 1.0.{build}

environment:
nodejs_version: "4"
nodejs_version: "6"

# Install scripts. (runs after repo cloning)
install:
Expand Down
17 changes: 7 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ exports.load_redis_ini = function () {
if (!ps.host) ps.host = s.host;
if (!ps.port) ps.port = s.port;

if (!plugin.redisCfg.opts) plugin.redisCfg.opts = {};
if (plugin.redisCfg.opts === undefined) plugin.redisCfg.opts = {};
Object.keys(plugin.redisCfg.opts).forEach(opt => {
if (ps[opt] === undefined) ps[opt] = plugin.redisCfg.opts[opt];
});
};

exports.merge_redis_ini = function () {
Expand Down Expand Up @@ -79,7 +82,7 @@ exports.init_redis_shared = function (next, server) {
});
}
else {
var opts = plugin.redisCfg.opts;
let opts = JSON.parse(JSON.stringify(plugin.redisCfg.opts));
opts.host = plugin.redisCfg.server.host;
opts.port = plugin.redisCfg.server.port;
server.notes.redis = plugin.get_redis_client(opts, nextOnce);
Expand Down Expand Up @@ -184,10 +187,7 @@ exports.redis_subscribe_pattern = function (pattern, next) {
return next();
}

plugin.redis = require('redis').createClient({
host: plugin.redisCfg.pubsub.host,
port: plugin.redisCfg.pubsub.port,
})
plugin.redis = require('redis').createClient(plugin.redisCfg.pubsub)
.on('psubscribe', function (pattern2, count) {
plugin.logdebug(plugin, 'psubscribed to ' + pattern2);
next();
Expand All @@ -206,10 +206,7 @@ exports.redis_subscribe = function (connection, next) {
return next();
}

connection.notes.redis = require('redis').createClient({
host: plugin.redisCfg.pubsub.host,
port: plugin.redisCfg.pubsub.port,
})
connection.notes.redis = require('redis').createClient(plugin.redisCfg.pubsub)
.on('psubscribe', function (pattern, count) {
connection.logdebug(plugin, 'psubscribed to ' + pattern);
next();
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "haraka-plugin-redis",
"version": "1.0.6",
"version": "1.0.7",
"description": "Redis plugin for Haraka & other plugins to inherit from",
"main": "index.js",
"directories": {
"test": "test"
},
"dependencies": {
"redis": "^2.6.5"
"redis": "^2.7.1"
},
"devDependencies": {
"eslint": "*",
Expand Down