jina.clients.base.helper module#
- class jina.clients.base.helper.AioHttpClientlet(url, logger, **kwargs)[source]#
Bases:
abc.ABC
aiohttp session manager
HTTP Client to be used with the streamer
- Parameters
url (
str
) – url to send http/websocket request tologger (
JinaLogger
) – jina loggerkwargs – kwargs which will be forwarded to the aiohttp.Session instance. Used to pass headers to requests
- abstract async send_message(**kwargs)[source]#
Send message to Gateway :param kwargs: kwargs which will be forwarded to the aiohttp.Session.post method. Used to pass headers to requests
- class jina.clients.base.helper.HTTPClientlet(url, logger, **kwargs)[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 tologger (
JinaLogger
) – jina loggerkwargs – kwargs which will be forwarded to the aiohttp.Session instance. Used to pass headers to requests
- async send_message(request)[source]#
Sends a POST request to the server
- Parameters
request (
Request
) – request as dict- Returns
send post message
- async close(*args, **kwargs)#
Close ClientSession
- Parameters
args – positional args
kwargs – keyword args
- async start()#
Create ClientSession and enter context
- Returns
self
- class jina.clients.base.helper.WsResponseIter(websocket)[source]#
Bases:
object
Iterates over all the responses that come in over the websocket connection. In contrast to the iterator built into AioHTTP, this also records the message that was sent at closing-time.
- 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
kwargs – kwargs which will be forwarded to the aiohttp.Session instance. Used to pass headers to requests
- 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_dry_run()[source]#
Query the dry_run endpoint from Gateway
- Returns
send dry_run 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 DataRequest
- ..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
- async recv_dry_run()[source]#
Receive dry run response in bytes from server
- ..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
- property close_message#
- Returns
the close message (reason) of the ws closing response
- property close_code#
- Returns
the close code of the ws closing response
- async close(*args, **kwargs)#
Close ClientSession
- Parameters
args – positional args
kwargs – keyword args
- async start()#
Create ClientSession and enter context
- Returns
self