改名
This commit is contained in:
+1
-1
@@ -41,7 +41,7 @@ class ClientPool extends Component
|
||||
*/
|
||||
public function get($config, callable $callback): mixed
|
||||
{
|
||||
$coroutineName = $this->name(self::POOL_NAME . '::' . $config['ServiceAddress'] . '::' . $config['ServicePort'], true);
|
||||
$coroutineName = $this->name(self::POOL_NAME . '::' . $config['Address'] . '::' . $config['Port'], true);
|
||||
|
||||
$pool = $config['pool'] ?? ['min' => 1, 'max' => 100];
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ class JsonRpcPoolTransporter implements ClientInterface
|
||||
|
||||
$response = $this->request($client = $this->getClient(), $content, false);
|
||||
|
||||
$this->pool->push($client, $this->config['ServiceAddress'], $this->config['ServicePort']);
|
||||
$this->pool->push($client, $this->config['Address'], $this->config['Port']);
|
||||
|
||||
return (new Response())->withBody(new Stream($response));
|
||||
}
|
||||
|
||||
+2
-4
@@ -2,12 +2,10 @@
|
||||
|
||||
namespace Kiri\Rpc;
|
||||
|
||||
use Kiri\Abstracts\Config;
|
||||
use Kiri\Consul\Agent;
|
||||
use Kiri\Consul\Health;
|
||||
use Kiri\Kiri;
|
||||
use ReflectionException;
|
||||
use Swoole\Table;
|
||||
|
||||
class RpcManager
|
||||
{
|
||||
@@ -60,8 +58,8 @@ class RpcManager
|
||||
public function getServices($serviceName): array
|
||||
{
|
||||
$file = storage('.rpc.clients.' . md5($serviceName), 'rpc');
|
||||
if (!file_exists($file)) {
|
||||
$this->tick();
|
||||
if (!file_exists($file) || filesize($file) < 10) {
|
||||
$this->async($serviceName);
|
||||
}
|
||||
$content = json_decode(file_get_contents($file), true);
|
||||
if (empty($content) || !is_array($content)) {
|
||||
|
||||
@@ -57,7 +57,7 @@ trait TraitTransporter
|
||||
$client = Context::inCoroutine() ? new Coroutine\Client(SWOOLE_SOCK_TCP) : new Client(SWOOLE_SOCK_TCP);
|
||||
$this->clients[$alias] = $client;
|
||||
}
|
||||
[$host, $port] = [$this->config['ServiceAddress'], $this->config['ServicePort']];
|
||||
[$host, $port] = [$this->config['Address'], $this->config['Port']];
|
||||
if (!$client->isConnected() && !$client->connect($host, $port, 60)) {
|
||||
throw new Exception('connect fail.');
|
||||
}
|
||||
@@ -71,7 +71,7 @@ trait TraitTransporter
|
||||
*/
|
||||
private function alias(array $config): string
|
||||
{
|
||||
return $config['ServiceAddress'] . '::' . $config['ServicePort'];
|
||||
return $config['Address'] . '::' . $config['Port'];
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user