Exemplo n.º 1
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)
Exemplo n.º 2
0
 def setup_backend(self, config):
     self.redis = RedisManager.from_config(config['redis_manager'])
     self.riak = RiakManager.from_config(config['riak_manager'])
     # this prefix is hard coded in VumiApi
     self.tagpool = TagpoolManager(
         self.redis.sub_manager('tagpool_store'))
     self.api = VumiApi(self.riak, self.redis)
Exemplo n.º 3
0
 def __init__(self, *args, **kwargs):
     super(TagPoolForm, self).__init__(*args, **kwargs)
     name_choices = [('', '---------')]
     api = VumiApi.from_config_sync(settings.VUMI_API_CONFIG)
     for pool_name in api.tpm.list_pools():
         name_choices.append((pool_name, pool_name))
     self.fields['name'] = forms.ChoiceField(choices=name_choices)
Exemplo 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)
Exemplo n.º 5
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)
Exemplo n.º 6
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)
Exemplo n.º 7
0
 def __init__(self, *args, **kwargs):
     super(TagPoolForm, self).__init__(*args, **kwargs)
     name_choices = [('', '---------')]
     api = VumiApi.from_config_sync(settings.VUMI_API_CONFIG)
     for pool_name in api.tpm.list_pools():
         name_choices.append((pool_name, pool_name))
     self.fields['name'] = forms.ChoiceField(choices=name_choices)
Exemplo n.º 8
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)
Exemplo n.º 9
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)
Exemplo n.º 10
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)
Exemplo n.º 11
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()
Exemplo n.º 12
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)
Exemplo n.º 13
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)
Exemplo n.º 14
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)
Exemplo n.º 15
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)
Exemplo n.º 16
0
 def startWorker(self):
     self.vumi_api = yield VumiApi.from_config_async(self.config)
     self.WORKER_QUEUE.put(self)
Exemplo n.º 17
0
def vumi_api():
    """Return a Vumi API instance."""
    return VumiApi.from_config_sync(settings.VUMI_API_CONFIG, connection)
Exemplo n.º 18
0
 def setup_sync_vumi_api(self):
     from django.conf import settings
     import go.base.amqp
     self._vumi_api = VumiApi.from_config_sync(settings.VUMI_API_CONFIG,
                                               go.base.amqp.connection)
Exemplo n.º 19
0
 def setup_sync_vumi_api(self):
     from django.conf import settings
     import go.base.amqp
     self._vumi_api = VumiApi.from_config_sync(
         settings.VUMI_API_CONFIG, go.base.amqp.connection)
Exemplo n.º 20
0
 def setup_middleware(self):
     yield super(GoStoringMiddleware, self).setup_middleware()
     self.vumi_api = yield VumiApi.from_config_async(self.config)
Exemplo n.º 21
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])
Exemplo n.º 22
0
 def startWorker(self):
     self.vumi_api = yield VumiApi.from_config_async(self.config)
     self.WORKER_QUEUE.put(self)
Exemplo n.º 23
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])
Exemplo n.º 24
0
 def setup_middleware(self):
     yield super(GoStoringMiddleware, self).setup_middleware()
     self.vumi_api = yield VumiApi.from_config_async(self.config)