Add message bus for #677

This commit is contained in:
Calvin Montgomery 2017-08-15 18:23:03 -07:00
parent 9ee650461f
commit d16cfb7328
9 changed files with 207 additions and 5 deletions

View file

@ -22,6 +22,10 @@ class PartitionConfig {
getAnnouncementChannel() {
return this.config.redis.announcementChannel || 'serverAnnouncements';
}
getGlobalMessageBusChannel() {
return this.config.redis.globalMessageBusChannel || 'globalMessages';
}
}
export { PartitionConfig };

View file

@ -7,6 +7,7 @@ import LegacyConfig from '../config';
import path from 'path';
import { AnnouncementRefresher } from './announcementrefresher';
import { RedisPartitionMapReloader } from './redispartitionmapreloader';
import { RedisMessageBus } from '../pubsub/redis';
const PARTITION_CONFIG_PATH = path.resolve(__dirname, '..', '..', 'conf',
'partitions.toml');
@ -104,6 +105,19 @@ class PartitionModule {
return this.announcementRefresher;
}
getGlobalMessageBus() {
if (!this.globalMessageBus) {
const provider = this.getRedisClientProvider();
this.globalMessageBus = new RedisMessageBus(
provider.get(),
provider.get(),
this.partitionConfig.getGlobalMessageBusChannel()
);
}
return this.globalMessageBus;
}
}
export { PartitionModule };