Add DualClusterClient for live testing phase of backend/frontend split

This commit is contained in:
calzoneman 2016-04-23 19:53:18 -07:00
parent 295c2a41a8
commit b69bd82a72
6 changed files with 79 additions and 2 deletions

View file

@ -1,4 +1,6 @@
import { RedisClusterClient } from '../io/cluster/redisclusterclient';
import { DualClusterClient } from '../io/cluster/dualclusterclient';
import NullClusterClient from '../io/cluster/nullclusterclient';
import { FrontendPool } from 'cytube-common/lib/redis/frontendpool';
import RedisClientProvider from 'cytube-common/lib/redis/redisclientprovider';
import { loadFromToml } from 'cytube-common/lib/configuration/configloader';
@ -6,6 +8,9 @@ import path from 'path';
import { BackendConfiguration } from './backendconfiguration';
import logger from 'cytube-common/lib/logger';
import redisAdapter from 'socket.io-redis';
import LegacyConfig from '../config';
import IOConfiguration from '../configuration/ioconfig';
import * as Switches from '../switches';
const BACKEND_CONFIG_PATH = path.resolve(__dirname, '..', '..', 'backend.toml');
@ -67,7 +72,19 @@ class BackendModule {
this.redisClusterClient = new RedisClusterClient(this.getFrontendPool());
}
return this.redisClusterClient;
if (Switches.isActive(Switches.DUAL_BACKEND) && !this.nullClusterClient) {
this.nullClusterClient = new NullClusterClient(
IOConfiguration.fromOldConfig(LegacyConfig));
}
if (Switches.isActive(Switches.DUAL_BACKEND)) {
this.clusterClient = new DualClusterClient(this.nullClusterClient,
this.redisClusterClient);
} else {
this.clusterClient = this.redisClusterClient;
}
return this.clusterClient;
}
}