CartoDB-SQL-API/batch/job_subscriber.js

18 lines
455 B
JavaScript
Raw Normal View History

'use strict';
2016-01-23 02:31:25 +08:00
function JobSubscriber(redis) {
this.channel = 'batch:hosts';
this.client = redis.createClient(global.settings.redis_port, global.settings.redis_host);
}
JobSubscriber.prototype.subscribe = function (onMessage) {
this.client.subscribe(this.channel);
this.client.on('message', onMessage);
};
JobSubscriber.prototype.unsubscribe = function () {
this.client.unsubscribe(this.channel);
};
module.exports = JobSubscriber;