From e0073ce5157d047c31663762fe2c8be261f87a29 Mon Sep 17 00:00:00 2001 From: wuhua3 Date: Tue, 22 Aug 2023 15:58:51 +0800 Subject: [PATCH 1/3] doMultiCall bugfix --- src/Motan/Endpointer.php | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/src/Motan/Endpointer.php b/src/Motan/Endpointer.php index 46afe00..681ab90 100644 --- a/src/Motan/Endpointer.php +++ b/src/Motan/Endpointer.php @@ -360,6 +360,33 @@ protected function _doRecv($resp_obj = NULL) return new \Motan\Response($res, $exception, $resp_msg); } + protected function _doRecvRespMsg() { + return $this->_connection_obj->read(); + } + + protected function _parseRespMsg($resp_msg, $resp_obj = NULL) { + $resp_body = $resp_msg->getBody(); + if ($resp_msg->getHeader()->isGzip()) { + $resp_body = zlib_decode($resp_body); + } + // aquires seialization type from response header. + $resp_seria=$resp_msg->getHeader()->getSerialize(); + // create seialization object from $resp_seria. + // notice: $resp_seria is a int typed flag. + $serializer=Utils::getSerializer($resp_seria); + // if create fail, using $this->_serializer as default serializer. + empty($serializer)&&$serializer=$this->_serializer; + + $res = $exception = NULL; + $res = $serializer->deserialize($resp_obj, $resp_body); + // @TODO Check resp_taged for grpc + $resp_meta = $resp_msg->getMetadata(); + if (isset($resp_meta['M_e'])) { + $exception = $resp_meta['M_e']; + } + return new \Motan\Response($res, $exception, $resp_msg); + } + /** * multi call * @@ -413,13 +440,15 @@ public function doMultiCall($request_objs) } $multi_exceptions = []; - foreach ($results as $req_id => $prepared_resp) { + foreach ($results as $prepared_resp) { if ($prepared_resp !== NULL) { continue; } try { - $resp_obj = isset($requests[$req_id]) ? $requests[$req_id]->getRespSerializerObj() : null; - $resp= $this->_doRecv($resp_obj); + $respMsg = $this->_doRecvRespMsg(); + $requestId = $respMsg->getHeader()->getRequestId(); + $resp_obj = isset($requests[$requestId]) ? $requests[$requestId]->getRespSerializerObj() : null; + $resp= $this->_parseRespMsg($respMsg, $resp_obj); } catch (\Exception $e) { array_push($multi_exceptions, $e); continue; From cb437a53cde7f1ce99eb77de37b3c5604e4cbdc3 Mon Sep 17 00:00:00 2001 From: wuhua3 Date: Tue, 22 Aug 2023 15:59:58 +0800 Subject: [PATCH 2/3] doMultiCall bugfix version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 6be6ef8..c7926da 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "motan/motan-php", - "version": "v1.1.9", + "version": "v1.1.10", "description": "Motan For PHP", "autoload": { "psr-4": { From f16bed3ad96c841316089ef43b2c490124e735eb Mon Sep 17 00:00:00 2001 From: wuhua3 Date: Fri, 25 Aug 2023 10:16:15 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Motan/Endpointer.php | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/src/Motan/Endpointer.php b/src/Motan/Endpointer.php index 681ab90..3878c96 100644 --- a/src/Motan/Endpointer.php +++ b/src/Motan/Endpointer.php @@ -337,27 +337,8 @@ protected function _doSend(\Motan\Request $request) protected function _doRecv($resp_obj = NULL) { - $resp_msg = $this->_connection_obj->read(); - $resp_body = $resp_msg->getBody(); - if ($resp_msg->getHeader()->isGzip()) { - $resp_body = zlib_decode($resp_body); - } - // aquires seialization type from response header. - $resp_seria=$resp_msg->getHeader()->getSerialize(); - // create seialization object from $resp_seria. - // notice: $resp_seria is a int typed flag. - $serializer=Utils::getSerializer($resp_seria); - // if create fail, using $this->_serializer as default serializer. - empty($serializer)&&$serializer=$this->_serializer; - - $res = $exception = NULL; - $res = $serializer->deserialize($resp_obj, $resp_body); - // @TODO Check resp_taged for grpc - $resp_meta = $resp_msg->getMetadata(); - if (isset($resp_meta['M_e'])) { - $exception = $resp_meta['M_e']; - } - return new \Motan\Response($res, $exception, $resp_msg); + $resp_msg = $this->_doRecvRespMsg(); + return $this->_parseRespMsg($resp_msg, $resp_obj); } protected function _doRecvRespMsg() {