Beispiel #1
0
 def Greet(self, request, context):
     file = ''
     self.write_file(name=request.name, message=request.message)
     with open(self.FILE_NAME, 'rb') as f:
         file = f.read()
     print(file)
     yield hello_pb2.HelloResponse(data=file)
Beispiel #2
0
 def SayHello(self, request, context):
     # response 是個 HelloResponse 形態的 message
     response = hello_pb2.HelloResponse()
     response.reply = f'Hello, {request.greeting}'
     return response
Beispiel #3
0
 def SayHello(self, request, context):
     return hello_pb2.HelloResponse(message='Hello gRPC, %s!' %
                                    request.name)
Beispiel #4
0
 def StreamGreeterResponseStream(self, request_iterator, context):
     for request in request_iterator:
         reply_msg = 'Hi, ' + request.message
         yield hello_pb2.HelloResponse(message=reply_msg)
Beispiel #5
0
 def Greeter(self, request, context):
     reply_msg = 'Hi, ' + request.message
     return hello_pb2.HelloResponse(message=reply_msg)
Beispiel #6
0
 def StreamGreeter(self, request_iterator, context):
     reply_msg = 'Hi, ' + ''.join(request.message
                                  for request in request_iterator)
     return hello_pb2.HelloResponse(message=reply_msg)
Beispiel #7
0
 def GreeterResponseStream(self, request, context):
     for msg in request.message:
         reply_msg = 'Hi, ' + msg
         yield hello_pb2.HelloResponse(message=reply_msg)
Beispiel #8
0
 def Hello(self, request, context):
     response = hello_pb2.HelloResponse()
     response.value = hello.hello(request.value)
     return response
Beispiel #9
0
 def SayHello(self, request, context):
     name = request.name
     time.sleep(1)
     return hello_pb2.HelloResponse(message=f"Hello from Locust, {name}!")
Beispiel #10
0
 def BidiHello(self, request_iterator, context):
     for request in request_iterator:
         print(request)
         self.prev_request.append(request)
         response = hello.HelloResponse(message=request.message)
         yield response