Python grpc.UnaryUnaryClientInterceptor() Examples
The following are 5
code examples of grpc.UnaryUnaryClientInterceptor().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
grpc
, or try the search function
.
Example #1
Source File: metadata_interceptor.py From google-ads-python with Apache License 2.0 | 6 votes |
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)
Example #2
Source File: logging_interceptor.py From google-ads-python with Apache License 2.0 | 6 votes |
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
Example #3
Source File: exception_interceptor.py From google-ads-python with Apache License 2.0 | 5 votes |
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
Example #4
Source File: _interceptor.py From python-grpc-demo with MIT License | 5 votes |
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)
Example #5
Source File: _interceptor.py From python-grpc-demo with MIT License | 5 votes |
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