Add RedisClusterClient

This commit is contained in:
calzoneman 2016-01-28 19:51:59 -08:00
parent f8470fc8f6
commit 86abebf9bf
2 changed files with 26 additions and 4 deletions

View File

@ -0,0 +1,17 @@
class RedisClusterClient {
constructor(frontendPool) {
this.frontendPool = frontendPool;
}
getSocketConfig(channel) {
return this.frontendPool.getFrontends(channel).then(result => {
if (!Array.isArray(result)) {
result = [];
}
return { servers: result };
});
}
}
export { RedisClusterClient };

View File

@ -46,6 +46,8 @@ import LocalChannelIndex from './web/localchannelindex';
import IOConfiguration from './configuration/ioconfig';
import WebConfiguration from './configuration/webconfig';
import NullClusterClient from './io/cluster/nullclusterclient';
import { RedisClusterClient } from './io/cluster/redisclusterclient';
import { FrontendPool } from 'cytube-common/lib/redis/frontendpool';
import session from './session';
var Server = function () {
@ -64,10 +66,16 @@ var Server = function () {
self.db.init();
ChannelStore.init();
// redis init
const redis = require('redis');
Promise.promisifyAll(redis.RedisClient.prototype);
Promise.promisifyAll(redis.Multi.prototype);
// webserver init -----------------------------------------------------
const ioConfig = IOConfiguration.fromOldConfig(Config);
const webConfig = WebConfiguration.fromOldConfig(Config);
const clusterClient = new NullClusterClient(ioConfig);
const frontendPool = new FrontendPool(redis.createClient());
const clusterClient = new RedisClusterClient(frontendPool);
const channelIndex = new LocalChannelIndex();
self.express = express();
require("./web/webserver").init(self.express,
@ -140,9 +148,6 @@ var Server = function () {
return '127.0.0.1';
}
};
const redis = require('redis');
Promise.promisifyAll(redis.RedisClient.prototype);
Promise.promisifyAll(redis.Multi.prototype);
const backend = new IOBackend(listenerConfig, sioEmitter, redis.createClient());
// background tasks init ----------------------------------------------