Revert "改名"

This reverts commit fdf58326
This commit is contained in:
2022-01-13 18:25:29 +08:00
parent 4d60a24fac
commit 07533e29f9
2 changed files with 32 additions and 5 deletions
+31 -4
View File
@@ -2,10 +2,11 @@
namespace Kiri\Rpc;
use Exception;
use Kiri;
use Kiri\Abstracts\Component;
use Kiri\Consul\Agent;
use Kiri\Consul\Health;
use Kiri;
use Kiri\Message\Handler\Handler;
use ReflectionException;
@@ -22,11 +23,12 @@ class RpcManager extends Component
/**
* @param $serviceName
* @return void
* @throws ReflectionException
* @throws \Exception
* @throws Exception
*/
public function async($serviceName): void
{
$this->reRegister($serviceName);
$lists = Kiri::getDi()->get(Health::class)->setQuery('passing=true')->service($serviceName);
if ($lists->getStatusCode() != 200) {
return;
@@ -41,8 +43,33 @@ class RpcManager extends Component
}
/**
* @param string $serviceName
* @return void
* @throws Kiri\Exception\ConfigException
* @throws Exception
*/
public function reRegister(string $serviceName)
{
$config = $this->_rpc[$serviceName] ?? [];
if (empty($config)) {
return;
}
$service = Kiri::getDi()->get(Agent::class);
$info = $service->service->service_health($config['config']['ID']);
if ($info->getStatusCode() == 200) {
return;
}
$data = $service->service->register($config['config']);
$this->logger()->info($data);
}
/**
* @throws ReflectionException
* @throws Exception
*/
public function tick(): void
{
@@ -55,7 +82,7 @@ class RpcManager extends Component
/**
* @param $serviceName
* @return array
* @throws \Exception
* @throws Exception
*/
public function getServices($serviceName): array
{