activestack-gateway
Version:
Socket server for ActiveStack
34 lines (28 loc) • 1.09 kB
JavaScript
var RedisStore = require('socket.io/lib/stores/redis');
function RedisStoreFactory(){}; module.exports = RedisStoreFactory;
RedisStoreFactory.prototype.inject = function(properties){
this.properties = properties;
};
/**
*
* @returns {RedisStore}
*/
RedisStoreFactory.prototype.instance = function(){
if(!this.redisStore){
var redisOptions = {
host: this.properties['gateway.redis.host'],
port: this.properties['gateway.redis.port'],
max_attempts: this.properties['gateway.redis.max_attempts'],
enable_offline_queue: this.properties['gateway.redis.offline_queue'] == 'true'
};
this.redisStore = new RedisStore({
redisPub: redisOptions,
redisSub: redisOptions,
redisClient: redisOptions
});
this.redisStore.pub.auth(this.properties['gateway.redis.password']);
this.redisStore.sub.auth(this.properties['gateway.redis.password']);
this.redisStore.cmd.auth(this.properties['gateway.redis.password']);
}
return this.redisStore;
}