Skip to content

Commit

Permalink
新增请求clientArg
Browse files Browse the repository at this point in the history
  • Loading branch information
kiss291323003 committed Dec 23, 2020
1 parent f7e9efd commit 1242c01
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class Client
private $onSuccess;
/** @var callable|null */
private $onFail;
/** @var mixed */
private $clientArg;

function __construct(NodeManagerInterface $manager, ClientConfig $config)
{
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
{
//失败状态监测
Expand Down
18 changes: 18 additions & 0 deletions src/Protocol/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class Request extends SplBean
protected $arg;
/** @var string */
protected $requestUUID;
/** @var mixed */
protected $clientArg;

/**
* @return string|null
Expand Down Expand Up @@ -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;
}
}

0 comments on commit 1242c01

Please sign in to comment.