Esempio n. 1
0
 def rangeSquare(self, request, context):
     print(request.message)
     for i in range(int(request.message + 1)):
         yield Message(message=i**2)
Esempio n. 2
0
#!/usr/bin/env python
import grpc
from data_pb2_grpc import SquareServiceStub
from data_pb2 import Message
url = "localhost:5000"
conn = grpc.insecure_channel(url)
client = SquareServiceStub(channel=conn)
result = client.square(Message(message=12.3))
print(result)
Esempio n. 3
0
#!/usr/bin/env python
import grpc
from data_pb2_grpc import SquareServiceStub
from data_pb2 import Message
url = "localhost:5000"
conn = grpc.insecure_channel(url)
client = SquareServiceStub(channel=conn)
result = client.sumSquare(Message(message=i) for i in range(12))
print(result)
Esempio n. 4
0
async def query():
    async with insecure_channel(url) as conn:
        client = SquareServiceStub(channel=conn)
        async for response in client.streamrangeSquare(
                AsyncIterWrapper(Message(message=i) for i in range(12))):
            print(response.message)
Esempio n. 5
0
async def query():
    async with insecure_channel(url) as conn:
        client = SquareServiceStub(channel=conn)
        async for response in client.rangeSquare(Message(message=12)):
            print(response.message)
Esempio n. 6
0
 def sumSquare(self, request_iterator, context):
     result = 0
     for i in request_iterator:
         result += i.message**2
     return Message(message=result)
Esempio n. 7
0
#!/usr/bin/env python
import grpc
from data_pb2_grpc import SquareServiceStub
from data_pb2 import Message
url = "localhost:5000"
conn = grpc.insecure_channel(url)
client = SquareServiceStub(channel=conn)
for result in client.streamrangeSquare(Message(message=i) for i in range(12)):
    print(result)
Esempio n. 8
0
async def query():
    async with insecure_channel(url) as conn:
        client = SquareServiceStub(channel=conn)
        result = await client.square(Message(message=12.3))
        print(result)
Esempio n. 9
0
#!/usr/bin/env python
import grpc
from data_pb2_grpc import SquareServiceStub
from data_pb2 import Message
url = "localhost:5000"
conn = grpc.insecure_channel(url)
client = SquareServiceStub(channel=conn)
for i in client.rangeSquare(Message(message=12)):
    print(i.message)
Esempio n. 10
0
 def streamrangeSquare(self, request_iterator, context):
     result = []
     for i in request_iterator:
         result.append(i.message**2)
     for j in result:
         yield Message(message=j)
Esempio n. 11
0
 def square(self, request, context):
     return Message(message=request.message**2)
Esempio n. 12
0
 def streamrangeSquare(self, request_iterator, context):
     for i in request_iterator:
         yield Message(message=i.message**2)
Esempio n. 13
0
async def query():
    async with insecure_channel(url) as conn:
        client = SquareServiceStub(channel=conn)
        response = await client.sumSquare(
            AsyncIterWrapper(Message(message=i) for i in range(12)))
        print(response.message)
Esempio n. 14
0
 def square(self, request, context):
     f = Executor.submit(square, request.message)
     futures.as_completed(f)
     result = f.result()
     return Message(message=result)