Ejemplo n.º 1
0
 def setup_async_vumi_api(self):
     worker_helper = self.get_worker_helper()
     amqp_client = worker_helper.get_fake_amqp_client(worker_helper.broker)
     d = amqp_client.start_publisher(ApiCommandPublisher)
     d.addCallback(lambda cmd_publisher: VumiApi.from_config_async(
         self.mk_config({}), cmd_publisher))
     return d.addCallback(self.set_vumi_api)
Ejemplo n.º 2
0
 def startWorker(self):
     self.vumi_api = yield VumiApi.from_config_async(
         self.config, self._amqp_client)
     self._publishers = {}
     for conv_type in self.SUPPORTED_APPS:
         yield self.make_publisher(conv_type)
     self.WORKER_QUEUE.put(self)
Ejemplo n.º 3
0
 def setup_async_vumi_api(self):
     worker_helper = self.get_worker_helper()
     amqp_client = worker_helper.get_fake_amqp_client(worker_helper.broker)
     d = amqp_client.start_publisher(ApiCommandPublisher)
     d.addCallback(lambda cmd_publisher: VumiApi.from_config_async(
         self.mk_config({}), cmd_publisher))
     return d.addCallback(self.set_vumi_api)
Ejemplo n.º 4
0
 def startWorker(self):
     self.vumi_api = yield VumiApi.from_config_async(
         self.config, self._amqp_client)
     self._publishers = {}
     for conv_type in self.SUPPORTED_APPS:
         yield self.make_publisher(conv_type)
     self.WORKER_QUEUE.put(self)
Ejemplo n.º 5
0
 def setup_worker(self):
     self.vumi_api = yield VumiApi.from_config_async(self.config)
     config = self.get_static_config()
     self.webserver = self.start_web_resources([
         (AuthorizedResource(self, ConversationApiResource),
          config.web_path),
         (httprpc.HttpRpcHealthResource(self), config.health_path)
     ], config.web_port)
Ejemplo n.º 6
0
    def _go_setup_vumi_api(self, config):
        api_config = {
            'riak_manager': config.riak_manager,
            'redis_manager': config.redis_manager,
            }
        d = VumiApi.from_config_async(
            api_config, self.command_publisher, self.metric_publisher)

        def cb(vumi_api):
            self.vumi_api = vumi_api
            self.redis = vumi_api.redis
            self.manager = vumi_api.manager
        return d.addCallback(cb)
Ejemplo n.º 7
0
    def _go_setup_vumi_api(self, config):
        api_config = {
            'riak_manager': config.riak_manager,
            'redis_manager': config.redis_manager,
        }
        d = VumiApi.from_config_async(api_config, self.command_publisher,
                                      self.metric_publisher)

        def cb(vumi_api):
            self.vumi_api = vumi_api
            self.redis = vumi_api.redis
            self.manager = vumi_api.manager

        return d.addCallback(cb)
Ejemplo n.º 8
0
 def setup_worker(self):
     config = self.get_static_config()
     self.vumi_api = yield VumiApi.from_config_async({
         'redis_manager': config.redis_manager,
         'riak_manager': config.riak_manager,
     })
     self.realm = GoUserRealm(self._rpc_resource_for_user)
     site = build_web_site({
         config.web_path: GoUserAuthSessionWrapper(
             self.realm, self.vumi_api),
         config.health_path: httprpc.HttpRpcHealthResource(self),
     })
     self._web_service = StreamServerEndpointService(
         config.twisted_endpoint, site)
     self._web_service.startService()
Ejemplo n.º 9
0
    def setup_application(self):
        self.handlers = {}

        self.api_command_publisher = yield self.start_publisher(
            ApiCommandPublisher)
        self.vumi_api = yield VumiApi.from_config_async(
            self.config, self.api_command_publisher)
        self.account_config = {}

        for name, handler_class in self.handler_config.items():
            cls = load_class_by_string(handler_class)
            self.handlers[name] = cls(self, self.config.get(name, {}))
            yield self.handlers[name].setup_handler()

        self.api_event_consumer = yield self.consume(
            ApiEventPublisher.routing_key, self.consume_api_event,
            message_class=VumiApiEvent)
Ejemplo n.º 10
0
    def setup_application(self):
        self.handlers = {}

        self.api_command_publisher = yield self.start_publisher(
            ApiCommandPublisher)
        self.vumi_api = yield VumiApi.from_config_async(
            self.config, self.api_command_publisher)
        self.account_config = {}

        for name, handler_class in self.handler_config.items():
            cls = load_class_by_string(handler_class)
            self.handlers[name] = cls(self, self.config.get(name, {}))
            yield self.handlers[name].setup_handler()

        self.api_event_consumer = yield self.consume(
            ApiEventPublisher.routing_key,
            self.consume_api_event,
            message_class=VumiApiEvent)
Ejemplo n.º 11
0
    def setup_worker(self):
        yield self._go_setup_worker()
        config = self.get_static_config()

        self.vumi_api = yield VumiApi.from_config_async({
            'riak_manager': config.riak_manager,
            'redis_manager': config.redis_manager,
        })
        self.redis = self.vumi_api.redis

        self.command_publisher = yield self.start_publisher(
            ApiCommandPublisher)

        self._current_bucket = 0
        self._num_buckets = (
            config.metrics_interval // config.metrics_granularity)
        self._buckets = dict((i, []) for i in range(self._num_buckets))
        self._conversation_workers = {}

        self._looper = LoopingCall(self.metrics_loop_func)
        self._looper.start(config.metrics_granularity)
Ejemplo n.º 12
0
    def setup_worker(self):
        yield self._go_setup_worker()
        config = self.get_static_config()

        self.vumi_api = yield VumiApi.from_config_async({
            'riak_manager':
            config.riak_manager,
            'redis_manager':
            config.redis_manager,
        })
        self.redis = self.vumi_api.redis

        self.command_publisher = yield self.start_publisher(
            ApiCommandPublisher)

        self._current_bucket = 0
        self._num_buckets = (config.metrics_interval //
                             config.metrics_granularity)
        self._buckets = dict((i, []) for i in range(self._num_buckets))
        self._conversation_workers = {}

        self._looper = LoopingCall(self.metrics_loop_func)
        self._looper.start(config.metrics_granularity)
Ejemplo n.º 13
0
 def startWorker(self):
     self.vumi_api = yield VumiApi.from_config_async(self.config)
     self.WORKER_QUEUE.put(self)
Ejemplo n.º 14
0
 def setup_middleware(self):
     yield super(GoStoringMiddleware, self).setup_middleware()
     self.vumi_api = yield VumiApi.from_config_async(self.config)
Ejemplo n.º 15
0
    def setup_middleware(self):
        self.vumi_api = yield VumiApi.from_config_async(self.config)

        self.case_sensitive = self.config.get('case_sensitive', False)
        keywords = self.config.get('optout_keywords', [])
        self.optout_keywords = set([self.casing(word) for word in keywords])
Ejemplo n.º 16
0
    def setup_middleware(self):
        self.vumi_api = yield VumiApi.from_config_async(self.config)

        self.case_sensitive = self.config.get("case_sensitive", False)
        keywords = self.config.get("optout_keywords", [])
        self.optout_keywords = set([self.casing(word) for word in keywords])
Ejemplo n.º 17
0
 def setup_middleware(self):
     yield super(GoStoringMiddleware, self).setup_middleware()
     self.vumi_api = yield VumiApi.from_config_async(self.config)
Ejemplo n.º 18
0
 def startWorker(self):
     self.vumi_api = yield VumiApi.from_config_async(self.config)
     self.WORKER_QUEUE.put(self)