jina.serve.runtimes.gateway.request_handling module#

class jina.serve.runtimes.gateway.request_handling.GatewayRequestHandler(metrics_registry=None, meter=None, runtime_name=None, logger=None)[source]#

Bases: MonitoringRequestMixin

Class that handles the requests arriving to the gateway and the result extracted from the requests future.

Parameters:
  • metrics_registry (Optional[CollectorRegistry]) – optional metrics registry for prometheus used if we need to expose metrics from the executor or from the data request handler

  • runtime_name (Optional[str]) – optional runtime_name that will be registered during monitoring

handle_request(graph, connection_pool)[source]#

Function that handles the requests arriving to the gateway. This will be passed to the streamer.

Parameters:
  • graph (TopologyGraph) – The TopologyGraph of the Flow.

  • connection_pool (GrpcConnectionPool) – The connection pool to be used to send messages to specific nodes of the graph

Return type:

Callable[[Request], Tuple[Future, Optional[Future]]]

Returns:

Return a Function that given a Request will return a Future from where to extract the response

handle_result()[source]#

Function that handles the result when extracted from the request future

Return type:

Callable[[Request], Request]

Returns:

Return a Function that returns a request to be returned to the client