當前位置: 首頁>>代碼示例>>Python>>正文


Python grpc.UnaryUnaryClientInterceptor方法代碼示例

本文整理匯總了Python中grpc.UnaryUnaryClientInterceptor方法的典型用法代碼示例。如果您正苦於以下問題:Python grpc.UnaryUnaryClientInterceptor方法的具體用法?Python grpc.UnaryUnaryClientInterceptor怎麽用?Python grpc.UnaryUnaryClientInterceptor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在grpc的用法示例。


在下文中一共展示了grpc.UnaryUnaryClientInterceptor方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: intercept_unary_unary

# 需要導入模塊: import grpc [as 別名]
# 或者: from grpc import UnaryUnaryClientInterceptor [as 別名]
def intercept_unary_unary(self, continuation, client_call_details, request):
        """Intercepts and appends custom metadata for Unary-Unary requests.

        Overrides abstract method defined in grpc.UnaryUnaryClientInterceptor.

        Args:
            continuation: a function to continue the request process.
            client_call_details: a grpc._interceptor._ClientCallDetails
                instance containing request metadata.
            request: a SearchGoogleAdsRequest or SearchGoogleAdsStreamRequest
                message class instance.

        Returns:
            A grpc.Call/grpc.Future instance representing a service response.
        """
        return self._intercept(continuation, client_call_details, request) 
開發者ID:googleads,項目名稱:google-ads-python,代碼行數:18,代碼來源:metadata_interceptor.py

示例2: intercept_unary_unary

# 需要導入模塊: import grpc [as 別名]
# 或者: from grpc import UnaryUnaryClientInterceptor [as 別名]
def intercept_unary_unary(self, continuation, client_call_details, request):
        """Intercepts and logs API interactions.

        Overrides abstract method defined in grpc.UnaryUnaryClientInterceptor.

        Args:
            continuation: a function to continue the request process.
            client_call_details: a grpc._interceptor._ClientCallDetails
                instance containing request metadata.
            request: a SearchGoogleAdsRequest or SearchGoogleAdsStreamRequest
                message class instance.

        Returns:
            A grpc.Call/grpc.Future instance representing a service response.
        """
        response = continuation(client_call_details, request)

        if self.logger.isEnabledFor(logging.WARNING):
            self._log_request(client_call_details, request, response)

        return response 
開發者ID:googleads,項目名稱:google-ads-python,代碼行數:23,代碼來源:logging_interceptor.py

示例3: intercept_unary_unary

# 需要導入模塊: import grpc [as 別名]
# 或者: from grpc import UnaryUnaryClientInterceptor [as 別名]
def intercept_unary_unary(self, continuation, client_call_details, request):
        """Intercepts and wraps exceptions in the rpc response.

        Overrides abstract method defined in grpc.UnaryUnaryClientInterceptor.

        Args:
            continuation: a function to continue the request process.
            client_call_details: a grpc._interceptor._ClientCallDetails
                instance containing request metadata.
            request: a SearchGoogleAdsRequest or SearchGoogleAdsStreamRequest
                message class instance.

        Returns:
            A grpc.Call instance representing a service response.

        Raises:
            GoogleAdsException: If the exception's trailing metadata
                indicates that it is a GoogleAdsException.
            RpcError: If the exception's trailing metadata is empty or is not
                indicative of a GoogleAdsException, or if the exception has a
                status code of INTERNAL or RESOURCE_EXHAUSTED.
        """
        response = continuation(client_call_details, request)
        exception = response.exception()

        if exception:
            self._handle_grpc_failure(response)
        else:
            return response 
開發者ID:googleads,項目名稱:google-ads-python,代碼行數:31,代碼來源:exception_interceptor.py

示例4: unary_unary

# 需要導入模塊: import grpc [as 別名]
# 或者: from grpc import UnaryUnaryClientInterceptor [as 別名]
def unary_unary(self,
                    method,
                    request_serializer=None,
                    response_deserializer=None):

        def callable_factory(method):
            return self._channel.unary_unary(method, request_serializer,
                                             response_deserializer)

        if isinstance(self._interceptor, grpc.UnaryUnaryClientInterceptor):
            return _InterceptingUnaryUnaryMultiCallable(
                method, callable_factory, self._interceptor)
        else:
            return callable_factory(method) 
開發者ID:amitsaha,項目名稱:python-grpc-demo,代碼行數:16,代碼來源:_interceptor.py

示例5: intercept_channel

# 需要導入模塊: import grpc [as 別名]
# 或者: from grpc import UnaryUnaryClientInterceptor [as 別名]
def intercept_channel(channel, *interceptors):
    for interceptor in reversed(list(interceptors)):
        if not isinstance(interceptor, grpc.UnaryUnaryClientInterceptor) and \
           not isinstance(interceptor, grpc.UnaryStreamClientInterceptor) and \
           not isinstance(interceptor, grpc.StreamUnaryClientInterceptor) and \
           not isinstance(interceptor, grpc.StreamStreamClientInterceptor):
            raise TypeError('interceptor must be '
                            'grpc.UnaryUnaryClientInterceptor or '
                            'grpc.UnaryStreamClientInterceptor or '
                            'grpc.StreamUnaryClientInterceptor or '
                            'grpc.StreamStreamClientInterceptor or ')
        channel = _InterceptingChannel(channel, interceptor)
    return channel 
開發者ID:amitsaha,項目名稱:python-grpc-demo,代碼行數:15,代碼來源:_interceptor.py


注:本文中的grpc.UnaryUnaryClientInterceptor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。