Revert "改名"
This reverts commit fdf58326
This commit is contained in:
+1
-1
@@ -94,7 +94,7 @@ class RpcJsonp extends Component implements OnConnectInterface, OnReceiveInterfa
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$async_time = (int)Config::get('consul.async_time', 1000);
|
$async_time = (int)Config::get('consul.async_time', 1000);
|
||||||
Timer::tick(5000, static function ($timeId) {
|
Timer::tick($async_time, static function ($timeId) {
|
||||||
if (env('state', 'start') == 'exit') {
|
if (env('state', 'start') == 'exit') {
|
||||||
Timer::clear($timeId);
|
Timer::clear($timeId);
|
||||||
return;
|
return;
|
||||||
|
|||||||
+31
-4
@@ -2,10 +2,11 @@
|
|||||||
|
|
||||||
namespace Kiri\Rpc;
|
namespace Kiri\Rpc;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Kiri;
|
||||||
use Kiri\Abstracts\Component;
|
use Kiri\Abstracts\Component;
|
||||||
use Kiri\Consul\Agent;
|
use Kiri\Consul\Agent;
|
||||||
use Kiri\Consul\Health;
|
use Kiri\Consul\Health;
|
||||||
use Kiri;
|
|
||||||
use Kiri\Message\Handler\Handler;
|
use Kiri\Message\Handler\Handler;
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
|
|
||||||
@@ -22,11 +23,12 @@ class RpcManager extends Component
|
|||||||
/**
|
/**
|
||||||
* @param $serviceName
|
* @param $serviceName
|
||||||
* @return void
|
* @return void
|
||||||
* @throws ReflectionException
|
* @throws Exception
|
||||||
* @throws \Exception
|
|
||||||
*/
|
*/
|
||||||
public function async($serviceName): void
|
public function async($serviceName): void
|
||||||
{
|
{
|
||||||
|
$this->reRegister($serviceName);
|
||||||
|
|
||||||
$lists = Kiri::getDi()->get(Health::class)->setQuery('passing=true')->service($serviceName);
|
$lists = Kiri::getDi()->get(Health::class)->setQuery('passing=true')->service($serviceName);
|
||||||
if ($lists->getStatusCode() != 200) {
|
if ($lists->getStatusCode() != 200) {
|
||||||
return;
|
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 ReflectionException
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function tick(): void
|
public function tick(): void
|
||||||
{
|
{
|
||||||
@@ -55,7 +82,7 @@ class RpcManager extends Component
|
|||||||
/**
|
/**
|
||||||
* @param $serviceName
|
* @param $serviceName
|
||||||
* @return array
|
* @return array
|
||||||
* @throws \Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function getServices($serviceName): array
|
public function getServices($serviceName): array
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user