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

@ -0,0 +1,27 @@
import logger from 'cytube-common/lib/logger';
import * as Switches from '../../switches';
class DualClusterClient {
constructor(authoritativeClient, altClient) {
this.authoritativeClient = authoritativeClient;
this.altClient = altClient;
}
getSocketConfig(channel) {
return this.authoritativeClient.getSocketConfig(channel).then(result => {
if (!Switches.isActive(Switches.DUAL_BACKEND)) {
return result;
}
return this.altClient.getSocketConfig(channel).then(altResult => {
result.alt = altResult.servers;
return result;
}).catch(error => {
logger.warn(`Error loading alt servers: ${error}`);
return result;
});
})
}
}
export { DualClusterClient };

View file

@ -1,3 +1,8 @@
import Promise from 'bluebird';
const ONE_SECOND = 1000;
const ERR_TIMEOUT = 'Timed out when retrieving server information';
class RedisClusterClient {
constructor(frontendPool) {
this.frontendPool = frontendPool;
@ -10,7 +15,7 @@ class RedisClusterClient {
}
return { servers: result };
});
}).timeout(ONE_SECOND, ERR_TIMEOUT);
}
}