This commit is contained in:
2022-09-23 18:55:46 +08:00
parent c190c749f4
commit c01dc5f41a
14 changed files with 239 additions and 331 deletions
+8 -19
View File
@@ -12,7 +12,7 @@ use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Swoole\Coroutine\Client;
class JsonRpcPoolTransporter implements RpcClientInterface
class JsonRpcPoolTransporter implements JsonRpcTransporterInterface
{
@@ -23,32 +23,21 @@ class JsonRpcPoolTransporter implements RpcClientInterface
public ClientPool $pool;
const POOL_NAME = 'rpc.client.pool';
/**
* @param string $content
* @param string $service
* @return string|bool
* @throws ConfigException|RpcServiceException
*/
public function init()
public function push(string $content, string $service): string|bool
{
}
/**
* @param RequestInterface $request
* @return ResponseInterface
* @throws Exception
*/
public function sendRequest(RequestInterface $request): ResponseInterface
{
$content = $request->getBody()->getContents();
$client = $this->getClient();
$client = $this->get_consul($service)->getClient();
$response = $this->request($client, $content);
$this->pool->push($client, $this->config['Address'], $this->config['Port']);
return (new Response())->withBody(new Stream($response));
return $response;
}