diff --git a/src/partition/announcementrefresher.js b/src/partition/announcementrefresher.js index e4aa7a33..4d404b8a 100644 --- a/src/partition/announcementrefresher.js +++ b/src/partition/announcementrefresher.js @@ -3,12 +3,12 @@ import uuid from 'uuid'; const LOGGER = require('@calzoneman/jsli')('announcementrefresher'); var SERVER; -const SERVER_ANNOUNCEMENTS = 'serverAnnouncements'; class AnnouncementRefresher { - constructor(pubClient, subClient) { + constructor(pubClient, subClient, channel) { this.pubClient = pubClient; this.subClient = subClient; + this.channel = channel; this.uuid = uuid.v4(); process.nextTick(this.init.bind(this)); } @@ -19,12 +19,13 @@ class AnnouncementRefresher { this.subClient.once('ready', () => { this.subClient.on('message', this.handleMessage.bind(this)); - this.subClient.subscribe(SERVER_ANNOUNCEMENTS); + this.subClient.subscribe(this.channel); }); } handleMessage(channel, message) { - if (channel !== SERVER_ANNOUNCEMENTS) { + if (channel !== this.channel) { + LOGGER.warn('Unexpected message from channel "%s"', channel); return; } @@ -49,7 +50,7 @@ class AnnouncementRefresher { data: data, partitionID: this.uuid }); - this.pubClient.publish(SERVER_ANNOUNCEMENTS, message); + this.pubClient.publish(this.channel, message); } } diff --git a/src/partition/partitionconfig.js b/src/partition/partitionconfig.js index e2e3523b..69d3ad94 100644 --- a/src/partition/partitionconfig.js +++ b/src/partition/partitionconfig.js @@ -18,6 +18,10 @@ class PartitionConfig { getPartitionMapKey() { return this.config.redis.partitionMapKey; } + + getAnnouncementChannel() { + return this.config.redis.announcementChannel || 'serverAnnouncements'; + } } export { PartitionConfig }; diff --git a/src/partition/partitionmodule.js b/src/partition/partitionmodule.js index 4811db69..10de9ef8 100644 --- a/src/partition/partitionmodule.js +++ b/src/partition/partitionmodule.js @@ -97,7 +97,8 @@ class PartitionModule { const provider = this.getRedisClientProvider(); this.announcementRefresher = new AnnouncementRefresher( provider.get(), - provider.get() + provider.get(), + this.partitionConfig.getAnnouncementChannel() ); }