def test_start_all(self): """start_all should start all of the stored routers""" config = self.create_router_config() router = Router(self.api, config) yield router.save() yield Router.start_all_routers(self.api) router_worker = self.service.namedServices[router.id] self.assertEqual(router_worker.parent, self.service) router_worker_config = config['config'] for k, v in router_worker_config.items(): self.assertEqual(router_worker.config[k], v)
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.router_store = RouterStore(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) yield Router.start_all_routers(self) if self.config.rabbitmq_management_interface: self.rabbitmq_management_client = RabbitmqManagementClient( self.config.rabbitmq_management_interface, self.amqp_config['username'], self.amqp_config['password'])