变更
This commit is contained in:
@@ -4,6 +4,7 @@ namespace Kiri\Rpc;
|
|||||||
|
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use JetBrains\PhpStorm\ArrayShape;
|
||||||
use Kiri\Message\ServerRequest;
|
use Kiri\Message\ServerRequest;
|
||||||
use Kiri\Message\Stream;
|
use Kiri\Message\Stream;
|
||||||
use Kiri\Core\Number;
|
use Kiri\Core\Number;
|
||||||
@@ -120,6 +121,7 @@ abstract class JsonRpcConsumers implements OnRpcConsumerInterface
|
|||||||
* @throws RpcServiceException|\ReflectionException
|
* @throws RpcServiceException|\ReflectionException
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
|
#[ArrayShape(['Address' => "mixed", 'Port' => "mixed"])]
|
||||||
private function get_consul($service): array
|
private function get_consul($service): array
|
||||||
{
|
{
|
||||||
if (empty($service)) {
|
if (empty($service)) {
|
||||||
@@ -137,6 +139,7 @@ abstract class JsonRpcConsumers implements OnRpcConsumerInterface
|
|||||||
* @param $services
|
* @param $services
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
|
#[ArrayShape(['Address' => "mixed", 'Port' => "mixed"])]
|
||||||
private function _loadRand($services): array
|
private function _loadRand($services): array
|
||||||
{
|
{
|
||||||
$array = [];
|
$array = [];
|
||||||
|
|||||||
@@ -52,12 +52,11 @@ trait TraitTransporter
|
|||||||
*/
|
*/
|
||||||
private function newClient(): Coroutine\Client|Client
|
private function newClient(): Coroutine\Client|Client
|
||||||
{
|
{
|
||||||
$alias = $this->alias($this->config);
|
if (Context::inCoroutine()) {
|
||||||
$client = $this->clients[$alias] ?? null;
|
$client = new Coroutine\Client(SWOOLE_SOCK_TCP);
|
||||||
if (is_null($client)) {
|
} else {
|
||||||
$client = Context::inCoroutine() ? new Coroutine\Client(SWOOLE_SOCK_TCP) : new Client(SWOOLE_SOCK_TCP);
|
$client = new Client(SWOOLE_SOCK_TCP);
|
||||||
$this->clients[$alias] = $client;
|
}
|
||||||
}
|
|
||||||
[$host, $port] = [$this->config['Address'], $this->config['Port']];
|
[$host, $port] = [$this->config['Address'], $this->config['Port']];
|
||||||
if (!$client->isConnected() && !$client->connect($host, $port, 60)) {
|
if (!$client->isConnected() && !$client->connect($host, $port, 60)) {
|
||||||
throw new Exception('connect fail.');
|
throw new Exception('connect fail.');
|
||||||
|
|||||||
Reference in New Issue
Block a user