コード例 #1
0
    async def route_req(self, table_name: str, key: K, web: Web,
                        request: Request) -> Response:
        """Route request to worker having key in table.

        Arguments:
            table_name: Name of the table.
            key: The key that we want.
            web: The currently sued web driver,
            request: The web request currently being served.
        """
        app = self.app
        try:
            dest_url: URL = app.router.key_store(table_name, key)
        except KeyError:
            raise ServiceUnavailable()
        dest_ident = (host, port) = self._urlident(dest_url)
        if dest_ident == self._urlident(app.conf.canonical_url):
            raise SameNode()
        routed_url = request.url.with_host(host).with_port(int(port))
        async with app.http_client.get(routed_url) as response:
            return web.text(
                await response.text(),
                content_type=response.content_type,
                status=response.status,
            )
コード例 #2
0
ファイル: router.py プロジェクト: zhouyuking/faust
 async def route_req(self, table_name: str, key: K, web: Web,
                     request: Request) -> Response:
     app = self.app
     dest_url: URL = app.router.key_store(table_name, key)
     dest_ident = (host, port) = self._urlident(dest_url)
     if dest_ident == self._urlident(app.conf.canonical_url):
         raise SameNode()
     routed_url = request.url.with_host(host).with_port(int(port))
     async with app.http_client.get(routed_url) as response:
         return web.text(await response.text(),
                         content_type=response.content_type)
コード例 #3
0
ファイル: router.py プロジェクト: taybin/faust
 async def _route_req(self, dest_url: URL, web: Web, request: Request) -> Response:
     app = self.app
     dest_ident = (host, port) = self._urlident(dest_url)
     if dest_ident == self._urlident(app.conf.canonical_url):
         raise SameNode()
     routed_url = request.url.with_host(host).with_port(int(port))
     async with app.http_client.request(request.method, routed_url) as response:
         return web.text(
             await response.text(),
             content_type=response.content_type,
             status=response.status,
         )
コード例 #4
0
ファイル: blueprints.py プロジェクト: smaxtec/faust
 def _apply_static_route(self, web: Web, route: FutureStaticRoute,
                         url_prefix: Optional[str]) -> None:
     uri = self._url_with_prefix(route.uri, url_prefix)
     web.add_static(uri, route.file_or_directory)
コード例 #5
0
ファイル: blueprints.py プロジェクト: wuttem/faust
 def _apply_static_route(self, web: Web, route: FutureStaticRoute,
                         url_prefix: Optional[str]) -> None:
     uri = url_prefix + route.uri if url_prefix else route.uri
     web.add_static(uri, route.file_or_directory)