async def endpoint_discovery(self, empty, context) -> jina_pb2.EndpointsProto: """ Uses the connection pool to send a discover endpoint call to the workers :param empty: The service expects an empty protobuf message :param context: grpc context :returns: the response request """ response = jina_pb2.EndpointsProto() try: if self.uses_before_address: ( uses_before_response, _, ) = await self.connection_pool.send_discover_endpoint( deployment='uses_before', head=False) response.endpoints.extend(uses_before_response.endpoints) if self.uses_after_address: ( uses_after_response, _, ) = await self.connection_pool.send_discover_endpoint( deployment='uses_after', head=False) response.endpoints.extend(uses_after_response.endpoints) worker_response, _ = await self.connection_pool.send_discover_endpoint( deployment=self._deployment_name, head=False) response.endpoints.extend(worker_response.endpoints) except InternalNetworkError as err: # can't connect, Flow broken, interrupt the streaming through gRPC error mechanism return self._handle_internalnetworkerror(err=err, context=context, response=response) return response
async def task_wrapper(): for i in range(3): try: return await connection.send_discover_endpoint( timeout=timeout, ) except AioRpcError as e: # connection failures and cancelled requests should be retried # all other cases should not be retried and will be raised immediately # connection failures have the code grpc.StatusCode.UNAVAILABLE # cancelled requests have the code grpc.StatusCode.CANCELLED # requests usually gets cancelled when the server shuts down # retries for cancelled requests will hit another replica in K8s if (e.code() != grpc.StatusCode.UNAVAILABLE and e.code() != grpc.StatusCode.CANCELLED): raise elif e.code() == grpc.StatusCode.UNAVAILABLE and i == 2: self._logger.debug( f'GRPC call failed, retries exhausted') raise else: self._logger.debug( f'GRPC call failed with code {e.code()}, retry attempt {i + 1}/3' ) except AttributeError: # in gateway2gateway communication, gateway does not expose this endpoint. So just send empty list which corresponds to all endpoints valid from jina import __default_endpoint__ ep = jina_pb2.EndpointsProto() ep.endpoints.extend([__default_endpoint__]) return ep, None
def FromString(x: bytes): """ # noqa: DAR101 # noqa: DAR102 # noqa: DAR201 """ ep = jina_pb2.EndpointsProto() ep.ParseFromString(x) return ep
async def endpoint_discovery(self, empty, context) -> jina_pb2.EndpointsProto: """ Process the the call requested and return the list of Endpoints exposed by the Executor wrapped inside this Runtime :param empty: The service expects an empty protobuf message :param context: grpc context :returns: the response request """ endpointsProto = jina_pb2.EndpointsProto() endpointsProto.endpoints.extend( list(self._data_request_handler._executor.requests.keys()) ) return endpointsProto
async def task_wrapper(): for i in range(3): try: return await connection.send_discover_endpoint( timeout=timeout, ) except AioRpcError as e: self._handle_aiorpcerror(e=e, retry_i=i, dest_addr=connection.address) except AttributeError: # in gateway2gateway communication, gateway does not expose this endpoint. So just send empty list which corresponds to all endpoints valid from jina import __default_endpoint__ ep = jina_pb2.EndpointsProto() ep.endpoints.extend([__default_endpoint__]) return ep, None
async def endpoint_discovery(self, empty, context) -> jina_pb2.EndpointsProto: """ USes the connection pool to send a discover endpoint call to the workers :param empty: The service expects an empty protobuf message :param context: grpc context :returns: the response request """ response = jina_pb2.EndpointsProto() if self.uses_before_address: uses_before_response, _ = await self.connection_pool.send_discover_endpoint( deployment='uses_before', head=False) response.endpoints.extend(uses_before_response.endpoints) if self.uses_after_address: uses_after_response, _ = await self.connection_pool.send_discover_endpoint( deployment='uses_after', head=False) response.endpoints.extend(uses_after_response.endpoints) worker_response, _ = await self.connection_pool.send_discover_endpoint( deployment=self._deployment_name, head=False) response.endpoints.extend(worker_response.endpoints) return response