jina.serve.runtimes.head package

Module contents

class jina.serve.runtimes.head.HeadRuntime(args, **kwargs)[source]

Bases: jina.serve.runtimes.asyncio.AsyncNewLoopRuntime, abc.ABC

Runtime is used in head pods. It responds to Gateway requests and sends to uses_before/uses_after and its workers

Initialize grpc server for the head runtime. :type args: Namespace :param args: args from CLI :param kwargs: keyword args

DEFAULT_POLLING = 1
async async_setup()[source]

Wait for the GRPC server to start

async async_run_forever()[source]

Block until the GRPC server is terminated

async async_cancel()[source]

Stop the GRPC server

async async_teardown()[source]

Close the connection pool

async process_single_data(request, context)[source]

Process the received requests and return the result as a new request

Parameters
  • request (DataRequest) – the data request to process

  • context – grpc context

Return type

DataRequest

Returns

the response request

async process_data(requests, context)[source]

Process the received data request and return the result as a new request

Parameters
  • requests (List[DataRequest]) – the data requests to process

  • context – grpc context

Return type

DataRequest

Returns

the response request

async process_control(request, *args)[source]

Process the received control request and return the input request

Parameters
  • request (ControlRequest) – the data request to process

  • args – additional arguments in the grpc call, ignored

Return type

ControlRequest

Returns

the input request

async endpoint_discovery(empty, context)[source]

Uses the connection pool to send a discover endpoint call to the workers

Parameters
  • empty – The service expects an empty protobuf message

  • context – grpc context

Return type

EndpointsProto

Returns

the response request