def setup(self, redis=None, message_sender=None): if redis is None: redis = yield TxRedisManager.from_config(self.redis_config) if message_sender is None: message_sender = MessageSender('amqp-spec-0-8.xml', self.amqp_config) self.redis = redis self.message_sender = message_sender self.message_sender.setServiceParent(self.service) self.inbounds = InboundMessageStore(self.redis, self.config.inbound_message_ttl) self.outbounds = OutboundMessageStore(self.redis, self.config.outbound_message_ttl) self.message_rate = MessageRateStore(self.redis) self.plugins = [] for plugin_config in self.config.plugins: cls = load_class_by_string(plugin_config['type']) plugin = cls() yield plugin.start_plugin(plugin_config, self.config) self.plugins.append(plugin) yield Channel.start_all_channels(self.redis, self.config, self.service, self.plugins)
def setup(self, redis=None, message_sender=None): if redis is None: redis = yield TxRedisManager.from_config(self.redis_config) if message_sender is None: message_sender = MessageSender( 'amqp-spec-0-8.xml', self.amqp_config) self.redis = redis self.message_sender = message_sender self.message_sender.setServiceParent(self.service) self.inbounds = InboundMessageStore( self.redis, self.config.inbound_message_ttl) self.outbounds = OutboundMessageStore( self.redis, self.config.outbound_message_ttl) self.message_rate = MessageRateStore(self.redis) self.plugins = [] for plugin_config in self.config.plugins: cls = load_class_by_string(plugin_config['type']) plugin = cls() yield plugin.start_plugin(plugin_config, self.config) self.plugins.append(plugin) yield Channel.start_all_channels( self.redis, self.config, self.service, self.plugins)
def test_start_all_channels(self): yield Channel.start_all_channels(self.redis, self.config, self.service) channel1 = yield self.create_channel(self.service, self.redis) self.assertTrue(channel1.id in self.service.namedServices) yield channel1.stop() self.assertFalse(channel1.id in self.service.namedServices) yield Channel.start_all_channels(self.redis, self.config, self.service) self.assertTrue(channel1.id in self.service.namedServices) channel2 = yield self.create_channel(self.service, self.redis) self.assertTrue(channel2.id in self.service.namedServices) yield channel2.stop() self.assertFalse(channel2.id in self.service.namedServices) yield Channel.start_all_channels(self.redis, self.config, self.service) self.assertTrue(channel1.id in self.service.namedServices) self.assertTrue(channel2.id in self.service.namedServices)
def test_start_all_channels(self): yield Channel.start_all_channels( self.redis, self.config, self.service) channel1 = yield self.create_channel( self.service, self.redis) self.assertTrue(channel1.id in self.service.namedServices) yield channel1.stop() self.assertFalse(channel1.id in self.service.namedServices) yield Channel.start_all_channels( self.redis, self.config, self.service) self.assertTrue(channel1.id in self.service.namedServices) channel2 = yield self.create_channel( self.service, self.redis) self.assertTrue(channel2.id in self.service.namedServices) yield channel2.stop() self.assertFalse(channel2.id in self.service.namedServices) yield Channel.start_all_channels( self.redis, self.config, self.service) self.assertTrue(channel1.id in self.service.namedServices) self.assertTrue(channel2.id in self.service.namedServices)