def hello(self, bs): # add a delay time.sleep(randint(50, 300) / 100) obj = SampleServicePbRequest() obj.ParseFromString(bs) print("server: Processing request", obj) return SampleServicePbResult(result=obj.name).SerializeToString()
def hello(self, bs: bytes): # add a delay # time.sleep(randint(50, 300) / 1000) obj = SampleServicePbRequest() obj.ParseFromString(bs) ret = SampleServicePbResult(result=obj.name).SerializeToString() counter.inc() return ret
def hello(self, bs): # add a delay time.sleep(self._seed) obj = SampleServicePbRequest() obj.ParseFromString(bs) print("Processing Request", obj) return SampleServicePbResult( result=obj.name).SerializeToString()
def hello(self, bs): # add a delay time.sleep(randint(50, 300) / 100) obj = SampleServicePbRequest() obj.ParseFromString(bs) print("server: Processing request", obj) # reference a pre init member ret = obj.name + self._name return SampleServicePbResult(result=ret).SerializeToString()
def _acall(name): return client.invoke_async( self.interface, "hello", SampleServicePbRequest(name="async" + str(name)).SerializeToString(), timeout_ms=500, callback=functools.partial(_cb, expect="async" + str(name)), spanctx=SpanContext())
def _call(name): content = client.invoke_sync( self.interface, "hello", SampleServicePbRequest(name=str(name)).SerializeToString(), timeout_ms=5000, spanctx=SpanContext()) result = SampleServicePbResult() result.ParseFromString(content) print(result.result == str(name)) _result.append(result.result == str(name))
def _acall(name): client = AioClient("perftestapp") client.mesh_service_address = ("127.0.0.1", 12201) fs = [ client.invoke_async( interface, "hello", SampleServicePbRequest(name=str(name)).SerializeToString(), timeout_ms=1000, spanctx=SpanContext()) for i in range(100) ] wait(fs)
def _call(name): client = AioClient("perftestapp") client.mesh_service_address = ("127.0.0.1", 12201) for i in range(100): try: ret = client.invoke_sync( interface, "hello", SampleServicePbRequest(name=str(name)).SerializeToString(), timeout_ms=1000, spanctx=SpanContext()) except Exception as e: pass print("{} finished".format(name))
def run_client(text): print("client start", text) spanctx = SpanContext() client = Client("test_app") client.subscribe(interface) content = client.invoke_sync(interface, "hello", SampleServicePbRequest(name=text).SerializeToString(), timeout_ms=5000, spanctx=spanctx) print("client", content) result = SampleServicePbResult() result.ParseFromString(content) print("client", result)