jina.clients package#

Subpackages#

Submodules#

Module contents#

Module wrapping the Client of Jina.

jina.clients.Client(*, asyncio: Optional[bool] = False, host: Optional[str] = '0.0.0.0', metrics: Optional[bool] = False, metrics_exporter_host: Optional[str] = None, metrics_exporter_port: Optional[int] = None, port: Optional[int] = None, protocol: Optional[str] = 'GRPC', proxy: Optional[bool] = False, tls: Optional[bool] = False, traces_exporter_host: Optional[str] = None, traces_exporter_port: Optional[int] = None, tracing: Optional[bool] = False, **kwargs) Union[AsyncWebSocketClient, WebSocketClient, AsyncGRPCClient, GRPCClient, HTTPClient, AsyncHTTPClient][source]#

Convenience function that returns client instance for given protocol.

EXAMPLE USAGE

from jina import Client
from docarray import Document

# select protocol from 'grpc', 'http', or 'websocket'; default is 'grpc'
# select asyncio True of False; default is False
# select host address to connect to
c = Client(
    protocol='grpc', asyncio=False, host='grpc://my.awesome.flow:1234'
)  # returns GRPCClient instance
c.post(on='/index', inputs=Document(text='hello!'))
Parameters:
  • asyncio – If set, then the input and output of this Client work in an asynchronous manner.

  • host – The host address of the runtime, by default it is 0.0.0.0. In the case of an external Executor (–external or external=True) this can be a list of hosts, separated by commas. Then, every resulting address will be considered as one replica of the Executor.

  • metrics – If set, the sdk implementation of the OpenTelemetry metrics will be available for default monitoring and custom measurements. Otherwise a no-op implementation will be provided.

  • metrics_exporter_host – If tracing is enabled, this hostname will be used to configure the metrics exporter agent.

  • metrics_exporter_port – If tracing is enabled, this port will be used to configure the metrics exporter agent.

  • port – The port of the Gateway, which the client should connect to.

  • protocol – Communication protocol between server and client.

  • proxy – If set, respect the http_proxy and https_proxy environment variables. otherwise, it will unset these proxy variables before start. gRPC seems to prefer no proxy

  • tls – If set, connect to gateway using tls encryption

  • traces_exporter_host – If tracing is enabled, this hostname will be used to configure the trace exporter agent.

  • traces_exporter_port – If tracing is enabled, this port will be used to configure the trace exporter agent.

  • tracing – If set, the sdk implementation of the OpenTelemetry tracer will be available and will be enabled for automatic tracing of requests and customer span creation. Otherwise a no-op implementation will be provided.

Return type:

Union[AsyncWebSocketClient, WebSocketClient, AsyncGRPCClient, GRPCClient, HTTPClient, AsyncHTTPClient]

Returns:

the new Client object