jina.clients.base.helper module

class jina.clients.base.helper.AioHttpClientlet(url, logger)[source]

Bases: abc.ABC

aiohttp session manager

HTTP Client to be used with the streamer

  • Parameters

    • url (str) – url to send http/websocket request to

    • logger (JinaLogger) – jina logger

  • abstract async send_message()[source]

    Send message to Gateway

  • abstract async recv_message()[source]

    Receive message from Gateway

  • async start()[source]

    Create ClientSession and enter context

    • Returns

      self

  • async close(\args, **kwargs*)[source]

    Close ClientSession

    • Parameters

      • args – positional args

      • kwargs – keyword args

class jina.clients.base.helper.HTTPClientlet(url, logger)[source]

Bases: jina.clients.base.helper.AioHttpClientlet

HTTP Client to be used with the streamer

HTTP Client to be used with the streamer

  • Parameters

    • url (str) – url to send http/websocket request to

    • logger (JinaLogger) – jina logger

  • async send_message(request)[source]

    Sends a POST request to the server

    • Parameters

      request (Request) – request as dict

      Returns

      send post message

  • async recv_message()[source]

    Receive message for HTTP (sleep)

    • Returns

      await sleep

class jina.clients.base.helper.WebsocketClientlet(\args, **kwargs*)[source]

Bases: jina.clients.base.helper.AioHttpClientlet

Websocket Client to be used with the streamer

HTTP Client to be used with the streamer

  • Parameters

    • url – url to send http/websocket request to

    • logger – jina logger

  • async send_message(request)[source]

    Send request in bytes to the server.

    • Parameters

      request (Request) – request object

      Returns

      send request as bytes awaitable

  • async send_eoi()[source]

    To confirm end of iteration, we send bytes(True) to the server.

    • Returns

      send bytes(True) awaitable

  • async recv_message()[source]

    Receive messages in bytes from server and convert to Response

    • ..note::

      aiohttp allows only one task which can receive concurrently. we need to make sure we don’t create multiple tasks with recv_message

    • Yield

      response objects received from server

      Return type

      Response