From 1242c01e3886175da837546fda56a8038f57b985 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A6=82=E6=9E=9C=E7=9A=84=E5=A6=82=E6=9E=9C?= Date: Wed, 23 Dec 2020 15:42:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=AF=B7=E6=B1=82clientArg?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Client.php | 20 ++++++++++++++++++++ src/Protocol/Request.php | 18 ++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/src/Client.php b/src/Client.php index 6f533fb..6122ce4 100644 --- a/src/Client.php +++ b/src/Client.php @@ -22,6 +22,8 @@ class Client private $onSuccess; /** @var callable|null */ private $onFail; + /** @var mixed */ + private $clientArg; function __construct(NodeManagerInterface $manager, ClientConfig $config) { @@ -84,6 +86,7 @@ function exec(float $timeout = 3.0) $pack->setAction($action); $pack->setArg($requestContext->getArg()); $pack->setRequestUUID($requestContext->getRequestUUID()); + $pack->setClientArg($this->clientArg); $client = new TcpClient($this->config->getMaxPackageSize(),$timeout); if(!$client->connect($node)){ $res->setStatus(Response::STATUS_CONNECT_TIMEOUT); @@ -115,6 +118,23 @@ function exec(float $timeout = 3.0) return $all; } + /** + * @return mixed + */ + public function getClientArg() + { + return $this->clientArg; + } + + /** + * @param mixed $clientArg + */ + public function setClientArg($clientArg): void + { + $this->clientArg = $clientArg; + } + + private function execCallback(Response $response,RequestContext $context) { //失败状态监测 diff --git a/src/Protocol/Request.php b/src/Protocol/Request.php index 783331f..190a4e5 100644 --- a/src/Protocol/Request.php +++ b/src/Protocol/Request.php @@ -18,6 +18,8 @@ class Request extends SplBean protected $arg; /** @var string */ protected $requestUUID; + /** @var mixed */ + protected $clientArg; /** * @return string|null @@ -98,4 +100,20 @@ public function setRequestUUID(string $requestUUID): void { $this->requestUUID = $requestUUID; } + + /** + * @return mixed + */ + public function getClientArg() + { + return $this->clientArg; + } + + /** + * @param mixed $clientArg + */ + public function setClientArg($clientArg): void + { + $this->clientArg = $clientArg; + } } \ No newline at end of file