jina.serve.runtimes.gateway.grpc package#

Module contents#

class jina.serve.runtimes.gateway.grpc.GRPCGatewayRuntime(args, **kwargs)[source]#

Bases: GatewayRuntime

Gateway Runtime for gRPC.

Initialize the runtime :type args: Namespace :param args: args from CLI :param kwargs: keyword args

async async_setup()[source]#

The async method to setup.

Create the gRPC server and expose the port for communication.

async async_teardown()[source]#

Close the connection pool

async async_cancel()[source]#

The async method to stop server.

async async_run_forever()[source]#

The async running of server.

async dry_run(empty, context)[source]#

Process the the call requested by having a dry run call to every Executor in the graph

Parameters:
  • empty – The service expects an empty protobuf message

  • context – grpc context

Return type:

StatusProto

Returns:

the response request

static activate(**kwargs)#

Activate the runtime, does not apply to these runtimes

Parameters:

kwargs – extra keyword arguments

static is_ready(ctrl_address, **kwargs)#

Check if status is ready.

Parameters:
  • ctrl_address (str) – the address where the control request needs to be sent

  • kwargs – extra keyword arguments

Return type:

bool

Returns:

True if status is ready else False.

run_forever()#

Running method to block the main thread.

Run the event loop until a Future is done.

teardown()#

Call async_teardown() and stop and close the event loop.

static wait_for_ready_or_shutdown(timeout, ready_or_shutdown_event, ctrl_address, **kwargs)#

Check if the runtime has successfully started

Parameters:
  • timeout (Optional[float]) – The time to wait before readiness or failure is determined

  • ctrl_address (str) – the address where the control message needs to be sent

  • ready_or_shutdown_event (Union[Event, Event]) – the multiprocessing event to detect if the process failed or is ready

  • kwargs – extra keyword arguments

Returns:

True if is ready or it needs to be shutdown