removed reset

v1.18.x
Barış Soner Uşaklı 7 years ago
parent c9a415c469
commit d4db8c2d42

@ -17,22 +17,22 @@ function get() {
pubsub.publish = pubsub.emit.bind(pubsub);
} else if (nconf.get('singleHostCluster')) {
pubsub = new EventEmitter();
pubsub.publish = function (event, data) {
if (process.send) {
if (!process.send) {
pubsub.publish = pubsub.emit.bind(pubsub);
} else {
pubsub.publish = function (event, data) {
process.send({
action: 'pubsub',
event: event,
data: data,
});
} else {
pubsub.emit(event, data);
}
};
process.on('message', function (message) {
if (message && typeof message === 'object' && message.action === 'pubsub') {
pubsub.emit(message.event, message.data);
}
});
};
process.on('message', function (message) {
if (message && typeof message === 'object' && message.action === 'pubsub') {
pubsub.emit(message.event, message.data);
}
});
}
} else if (nconf.get('redis')) {
pubsub = require('./database/redis/pubsub');
} else if (nconf.get('mongo')) {
@ -42,7 +42,6 @@ function get() {
}
real = pubsub;
return pubsub;
}
@ -56,7 +55,4 @@ module.exports = {
removeAllListeners: function (event) {
get().removeAllListeners(event);
},
reset: function () {
real = null;
},
};

@ -25,7 +25,7 @@ nconf.defaults({
if (!nconf.get('isCluster')) {
nconf.set('isPrimary', 'true');
nconf.set('isCluster', 'false');
nconf.set('isCluster', 'true');
}
var dbType = nconf.get('database');

@ -7,21 +7,13 @@ var db = require('./mocks/databasemock');
var pubsub = require('../src/pubsub');
describe('pubsub', function () {
beforeEach(function () {
pubsub.reset();
});
afterEach(function () {
pubsub.reset();
});
it('should use singleHostCluster', function (done) {
var oldValue = nconf.get('singleHostCluster');
var isCluster = nconf.get('isCluster');
nconf.set('singleHostCluster', true);
nconf.set('isCluster', true);
pubsub.on('testEvent', function (message) {
assert.equal(message.foo, 1);
nconf.set('singleHostCluster', oldValue);
nconf.set('isCluster', isCluster);
pubsub.removeAllListeners('testEvent');
done();
});
@ -30,13 +22,10 @@ describe('pubsub', function () {
it('should use the current database\'s pubsub', function (done) {
var oldValue = nconf.get('singleHostCluster');
var isCluster = nconf.get('isCluster');
nconf.set('singleHostCluster', false);
nconf.set('isCluster', true);
pubsub.on('testEvent', function (message) {
assert.equal(message.foo, 1);
nconf.set('singleHostCluster', oldValue);
nconf.set('isCluster', isCluster);
pubsub.removeAllListeners('testEvent');
done();
});

Loading…
Cancel
Save