예제 #1
0
 def SayHello(self, request, context):
     with self._lock:
         if request.name in self._greeted:
             rich_status = create_greet_limit_exceed_error_status(
                 request.name)
             context.abort_with_status(rpc_status.to_status(rich_status))
         else:
             self._greeted.add(request.name)
     return helloworld_pb2.HelloReply(message='Hello, %s!' % request.name)
예제 #2
0
 def SayHello(self, request, unused_context):
     return helloworld_pb2.HelloReply(message='Hello, %s!' % request.name)
예제 #3
0
 def SayHello(self, request, context):
     if self._should_suppress_compression():
         context.set_response_compression(grpc.Compression.NoCompression)
     return helloworld_pb2.HelloReply(message='Hello, %s!' % request.name)
예제 #4
0
 def SayHello(self, request, context):
     if random.random() < self._failure_rate:
         context.abort(grpc.StatusCode.UNAVAILABLE,
                       'Randomly injected failure.')
     return helloworld_pb2.HelloReply(message='Hello, %s!' % request.name)