Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4d60a24fac | |||
| 4dc6bc661a | |||
| 0d7fd5e356 | |||
| da16b0685d | |||
| febbdea8c8 | |||
| a45c3d875c | |||
| 64d01c0a80 | |||
| bf5fe594e4 | |||
| 5cfe3c6d6d | |||
| 773e3c0f57 | |||
| b1c91343ef | |||
| 3f821ca9d0 | |||
| d296b3107e | |||
| f606c58204 |
@@ -5,7 +5,7 @@ namespace Kiri\Rpc\Annotation;
|
|||||||
use Kiri\Abstracts\Config;
|
use Kiri\Abstracts\Config;
|
||||||
use Kiri\Core\Network;
|
use Kiri\Core\Network;
|
||||||
use Kiri\Exception\ConfigException;
|
use Kiri\Exception\ConfigException;
|
||||||
use Kiri\Kiri;
|
use Kiri;
|
||||||
use Kiri\Rpc\RpcManager;
|
use Kiri\Rpc\RpcManager;
|
||||||
use Kiri\Annotation\Attribute;
|
use Kiri\Annotation\Attribute;
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
@@ -70,7 +70,7 @@ use ReflectionException;
|
|||||||
"Check" => [
|
"Check" => [
|
||||||
"CheckId" => "service:rpc.json.{$this->service}." . $this->uniqueId,
|
"CheckId" => "service:rpc.json.{$this->service}." . $this->uniqueId,
|
||||||
"Name" => "service " . $this->service . ' health check',
|
"Name" => "service " . $this->service . ' health check',
|
||||||
"Annotations" => "Script based health check",
|
"Notes" => "Script based health check",
|
||||||
"ServiceID" => $this->service,
|
"ServiceID" => $this->service,
|
||||||
"TCP" => $this->checkUrl,
|
"TCP" => $this->checkUrl,
|
||||||
"Interval" => "5s",
|
"Interval" => "5s",
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ use Exception;
|
|||||||
use Kiri\Abstracts\Component;
|
use Kiri\Abstracts\Component;
|
||||||
use Kiri\Context;
|
use Kiri\Context;
|
||||||
use Kiri\Exception\ConfigException;
|
use Kiri\Exception\ConfigException;
|
||||||
use Kiri\Kiri;
|
use Kiri;
|
||||||
use Kiri\Pool\Alias;
|
use Kiri\Pool\Alias;
|
||||||
use Kiri\Pool\Pool;
|
use Kiri\Pool\Pool;
|
||||||
use Swoole\Client;
|
use Swoole\Client;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use Exception;
|
|||||||
use Kiri\Message\ServerRequest;
|
use Kiri\Message\ServerRequest;
|
||||||
use Kiri\Message\Stream;
|
use Kiri\Message\Stream;
|
||||||
use Kiri\Core\Number;
|
use Kiri\Core\Number;
|
||||||
use Kiri\Kiri;
|
use Kiri;
|
||||||
use Kiri\Pool\Pool;
|
use Kiri\Pool\Pool;
|
||||||
use Psr\Http\Client\ClientExceptionInterface;
|
use Psr\Http\Client\ClientExceptionInterface;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
|||||||
+2
-2
@@ -12,7 +12,7 @@ use Kiri\Consul\Agent;
|
|||||||
use Kiri\Context;
|
use Kiri\Context;
|
||||||
use Kiri\Events\EventProvider;
|
use Kiri\Events\EventProvider;
|
||||||
use Kiri\Exception\ConfigException;
|
use Kiri\Exception\ConfigException;
|
||||||
use Kiri\Kiri;
|
use Kiri;
|
||||||
use Kiri\Annotation\Inject;
|
use Kiri\Annotation\Inject;
|
||||||
use Kiri\Annotation\Annotation;
|
use Kiri\Annotation\Annotation;
|
||||||
use Psr\Container\ContainerExceptionInterface;
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
@@ -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($async_time, static function ($timeId) {
|
Timer::tick(5000, static function ($timeId) {
|
||||||
if (env('state', 'start') == 'exit') {
|
if (env('state', 'start') == 'exit') {
|
||||||
Timer::clear($timeId);
|
Timer::clear($timeId);
|
||||||
return;
|
return;
|
||||||
|
|||||||
+3
-2
@@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
namespace Kiri\Rpc;
|
namespace Kiri\Rpc;
|
||||||
|
|
||||||
use Kiri\Message\Handler\Handler;
|
|
||||||
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\Kiri;
|
use Kiri;
|
||||||
|
use Kiri\Message\Handler\Handler;
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
|
|
||||||
class RpcManager extends Component
|
class RpcManager extends Component
|
||||||
@@ -117,6 +117,7 @@ class RpcManager extends Component
|
|||||||
{
|
{
|
||||||
$agent = Kiri::getDi()->get(Agent::class);
|
$agent = Kiri::getDi()->get(Agent::class);
|
||||||
foreach ($this->_rpc as $list) {
|
foreach ($this->_rpc as $list) {
|
||||||
|
$agent->service->deregister($list['config']['ID']);
|
||||||
$data = $agent->service->register($list['config']);
|
$data = $agent->service->register($list['config']);
|
||||||
if ($data->getStatusCode() != 200) {
|
if ($data->getStatusCode() != 200) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user