Esempio n. 1
0
    def Sum(self, Int_iterator, context):
        result = 0
        for i in Int_iterator:
            result += i.value

        rsp = helloWorld_pb2.Int(value=result)
        return rsp
Esempio n. 2
0
def getSumAsync(stub, value):
    req = (helloWorld_pb2.Int(value=i) for i in range(value))
    rspFuture = stub.Sum.future(req)

    rsp = rspFuture.result()
    print("Async")

    print(f"Sum range({value}) => {rsp.value}")
Esempio n. 3
0
def getDoubleAsync(stub, value):
    req = helloWorld_pb2.Int(value=value)
    rspFuture = stub.Double.future(req)

    rsp = rspFuture.result()
    print("Async")

    print(f"double {value} => {rsp.value}")
Esempio n. 4
0
 def DoubleIter(self, Int_iterator, context):
     for i in Int_iterator:
         rsp = helloWorld_pb2.Int(value=i.value * 2)
         yield rsp
Esempio n. 5
0
 def Range(self, Int, context):
     for i in range(Int.value):
         rsp = helloWorld_pb2.Int(value=i)
         yield rsp
Esempio n. 6
0
    def Double(self, Int, context):
        rsp = helloWorld_pb2.Int(value=Int.value * 2)

        return rsp
Esempio n. 7
0
def getDoubleIter(stub, value):
    req = (helloWorld_pb2.Int(value=i) for i in range(value))
    rsp = stub.DoubleIter(req)
    for i in rsp:
        print(f"double range({value}) => {i.value * 2}")
Esempio n. 8
0
def getSumSync(stub, value):
    req = (helloWorld_pb2.Int(value=i) for i in range(value))
    rsp = stub.Sum(req)

    print(f"Sum range({value}) => {rsp.value}")
Esempio n. 9
0
def getRange(stub, value):
    req = helloWorld_pb2.Int(value=value)
    rsp = stub.Range(req)

    for i in rsp:
        print(f"range {value} => {i.value}")
Esempio n. 10
0
def getDoubleSync(stub, value):
    req = helloWorld_pb2.Int(value=value)
    rsp = stub.Double(req)

    print(f"double {value} => {rsp.value}")