Ejemplo n.º 1
0
 def __init__(self, config_file=None):
     self.config = ApiSiteConfig(read_yaml_config(config_file))
     self.api = API(
         self.config.create_backend(),
         self.config.create_auth())
     self.site = build_web_site({
         'health': HealthResource(),
         self.config.url_path_prefix: self.api.app.resource(),
     })
Ejemplo n.º 2
0
 def __init__(self, config_file=None):
     self.config = ApiSiteConfig(read_yaml_config(config_file))
     self.api = API(self.config.create_backend(), self.config.create_auth())
     self.site = build_web_site({
         'health':
         HealthResource(),
         self.config.url_path_prefix:
         self.api.app.resource(),
     })
Ejemplo n.º 3
0
 def test_build_web_site_with_overlapping_paths(self):
     resource_a = Resource()
     resource_b = Resource()
     site = build_web_site({
         'foo/a': resource_a,
         'foo/b': resource_b,
     })
     self.assertEqual(self.get_resource('foo/a', site), resource_a)
     self.assertEqual(self.get_resource('foo/b', site), resource_b)
     self.assertTrue(isinstance(site, LogFilterSite))
Ejemplo n.º 4
0
 def test_build_web_site_with_overlapping_paths(self):
     resource_a = Resource()
     resource_b = Resource()
     site = build_web_site({
         'foo/a': resource_a,
         'foo/b': resource_b,
     })
     self.assertEqual(self.get_resource('foo/a', site), resource_a)
     self.assertEqual(self.get_resource('foo/b', site), resource_b)
     self.assertTrue(isinstance(site, LogFilterSite))
Ejemplo n.º 5
0
    def setup_transport(self):
        config = self.get_static_config()
        self.endpoint = config.twisted_endpoint
        self.resource = NetcoreResource(self)

        self.factory = build_web_site({
            config.health_path: HttpRpcHealthResource(self),
            config.web_path: self.resource,
        })
        self.server = yield self.endpoint.listen(self.factory)
Ejemplo n.º 6
0
    def setup_worker(self):
        config = self.get_static_config()
        self._riak = yield TxRiakManager.from_config(config.riak_manager)
        redis = yield TxRedisManager.from_config(config.redis_manager)
        self.store = MessageStore(self._riak, redis)

        site = build_web_site({
            config.web_path: MessageStoreResource(self.store),
            config.health_path: httprpc.HttpRpcHealthResource(self),
        })
        self.addService(
            StreamServerEndpointService(config.twisted_endpoint, site))
Ejemplo n.º 7
0
    def setup_worker(self):
        config = self.get_static_config()
        riak = yield TxRiakManager.from_config(config.riak_manager)
        redis = yield TxRedisManager.from_config(config.redis_manager)
        self.store = MessageStore(riak, redis)

        site = build_web_site({
            config.web_path: MessageStoreResource(self.store),
            config.health_path: httprpc.HttpRpcHealthResource(self),
        })
        self.addService(
            StreamServerEndpointService(config.twisted_endpoint, site))
Ejemplo n.º 8
0
    def setup_transport(self):
        config = self.get_static_config()
        self.endpoint = config.twisted_endpoint
        self.resource = NetcoreResource(self)

        self.factory = build_web_site({
            config.health_path:
            HttpRpcHealthResource(self),
            config.web_path:
            self.resource,
        })
        self.server = yield self.endpoint.listen(self.factory)
Ejemplo n.º 9
0
 def setup_worker(self):
     config = self.get_static_config()
     self.redis_manager = yield TxRedisManager.from_config(
         config.redis_manager)
     tagpool = TagpoolManager(self.redis_manager)
     rpc = TagpoolApiServer(tagpool)
     addIntrospection(rpc)
     site = build_web_site({
         config.web_path: rpc,
         config.health_path: httprpc.HttpRpcHealthResource(self),
     })
     self.addService(
         StreamServerEndpointService(config.twisted_endpoint, site))
Ejemplo n.º 10
0
    def setup_transport(self):
        config = self.get_static_config()
        self.request_dict = {}
        self.endpoint = config.twisted_endpoint
        self.resource = WeChatResource(self)
        self.factory = build_web_site({config.health_path: HttpRpcHealthResource(self), config.web_path: self.resource})

        self.redis = yield TxRedisManager.from_config(config.redis_manager)
        self.server = yield self.endpoint.listen(self.factory)

        if config.wechat_menu:
            # not yielding because this shouldn't block startup
            d = self.get_access_token()
            d.addCallback(self.create_wechat_menu, config.wechat_menu)
Ejemplo 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()
Ejemplo n.º 12
0
 def setup_worker(self):
     config = self.get_static_config()
     self.redis_manager = yield TxRedisManager.from_config(
         config.redis_manager)
     tagpool = TagpoolManager(self.redis_manager)
     rpc = TagpoolApiServer(tagpool)
     addIntrospection(rpc)
     site = build_web_site({
         config.web_path:
         rpc,
         config.health_path:
         httprpc.HttpRpcHealthResource(self),
     })
     self.addService(
         StreamServerEndpointService(config.twisted_endpoint, site))
Ejemplo n.º 13
0
    def setup_transport(self):
        config = self.get_static_config()
        self.request_dict = {}
        self.endpoint = config.twisted_endpoint
        self.resource = WeChatResource(self)
        self.factory = build_web_site({
            config.health_path:
            HttpRpcHealthResource(self),
            config.web_path:
            self.resource,
        })

        self.redis = yield TxRedisManager.from_config(config.redis_manager)
        self.server = yield self.endpoint.listen(self.factory)

        if config.wechat_menu:
            # not yielding because this shouldn't block startup
            d = self.get_access_token()
            d.addCallback(self.create_wechat_menu, config.wechat_menu)
Ejemplo n.º 14
0
    def setup_transport(self):
        """
        Transport specific setup - it sets up a connection.
        """
        self._requests = {}
        self._requests_deferreds = {}
        self.callLater = reactor.callLater

        config = self.get_static_config()
        self.endpoint = config.twisted_endpoint
        self.timeout = config.timeout

        r_prefix = "vumi.transports.mtn_rwanda:%s" % self.transport_name
        self.session_manager = yield SessionManager.from_redis_config(
            config.redis_manager, r_prefix,
            config.session_timeout_period)

        self.factory = build_web_site({
            config.health_path: HttpRpcHealthResource(self),
            config.web_path: MTNRwandaXMLRPCResource(self),
        })

        self.xmlrpc_server = yield self.endpoint.listen(self.factory)
Ejemplo n.º 15
0
    def setup_transport(self):
        """
        Transport specific setup - it sets up a connection.
        """
        self._requests = {}
        self._requests_deferreds = {}
        self.callLater = reactor.callLater

        config = self.get_static_config()
        self.endpoint = config.twisted_endpoint
        self.timeout = config.timeout

        r_prefix = "vumi.transports.mtn_rwanda:%s" % self.transport_name
        self.session_manager = yield SessionManager.from_redis_config(
            config.redis_manager, r_prefix, config.session_timeout_period)

        self.factory = build_web_site({
            config.health_path:
            HttpRpcHealthResource(self),
            config.web_path:
            MTNRwandaXMLRPCResource(self),
        })

        self.xmlrpc_server = yield self.endpoint.listen(self.factory)
Ejemplo n.º 16
0
 def test_build_web_site_with_custom_site_class(self):
     site = build_web_site({}, site_class=Site)
     self.assertTrue(isinstance(site, Site))
     self.assertFalse(isinstance(site, LogFilterSite))
Ejemplo n.º 17
0
 def test_build_web_site_with_custom_site_class(self):
     site = build_web_site({}, site_class=Site)
     self.assertTrue(isinstance(site, Site))
     self.assertFalse(isinstance(site, LogFilterSite))
Ejemplo n.º 18
0
 def start_web_resources(self, resources, port, site_class=None):
     resources = dict((path, resource) for resource, path in resources)
     site_factory = build_web_site(resources, site_class=site_class)
     return reactor.listenTCP(port, site_factory)
Ejemplo n.º 19
0
 def start_web_resources(self, resources, port, site_class=None):
     resources = dict((path, resource) for resource, path in resources)
     site_factory = build_web_site(resources, site_class=site_class)
     return reactor.listenTCP(port, site_factory)