Ejemplo 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
Ejemplo 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}")
Ejemplo 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}")
Ejemplo n.º 4
0
 def DoubleIter(self, Int_iterator, context):
     for i in Int_iterator:
         rsp = helloWorld_pb2.Int(value=i.value * 2)
         yield rsp
Ejemplo n.º 5
0
 def Range(self, Int, context):
     for i in range(Int.value):
         rsp = helloWorld_pb2.Int(value=i)
         yield rsp
Ejemplo n.º 6
0
    def Double(self, Int, context):
        rsp = helloWorld_pb2.Int(value=Int.value * 2)

        return rsp
Ejemplo 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}")
Ejemplo 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}")
Ejemplo 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}")
Ejemplo n.º 10
0
def getDoubleSync(stub, value):
    req = helloWorld_pb2.Int(value=value)
    rsp = stub.Double(req)

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