From 286d06a42a411900462f36a7ace7a5482b0d2483 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Fri, 29 Oct 2021 11:05:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/RpcJsonp.php | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/RpcJsonp.php b/src/RpcJsonp.php index 4c0b05c..4db0d90 100644 --- a/src/RpcJsonp.php +++ b/src/RpcJsonp.php @@ -6,8 +6,7 @@ use Annotation\Annotation; use Annotation\Inject; use Http\Handler\Router; use Kiri\Abstracts\Component; -use Kiri\Abstracts\Config; -use Kiri\Di\ContainerInterface; +use Kiri\Consul\Agent; use Kiri\Di\NoteManager; use Kiri\Kiri; use Server\SInterface\OnCloseInterface; @@ -57,6 +56,34 @@ class RpcJsonp extends Component implements OnConnectInterface, OnReceiveInterfa } } } + $this->register(); + } + + + public function register() + { + $agent = Kiri::getDi()->get(Agent::class); + $agent->service->register([ + "ID" => "redis1", + "Name" => "redis", + "Tags" => ["primary", "v1"], + "Address" => "127.0.0.1", + "Port" => 8000, + "Meta" => [ + "redis_version" => "4.0" + ], + "EnableTagOverride" => false, + "Check" => [ + "DeregisterCriticalServiceAfter" => "90m", +// "Args" => ["/usr/local/bin/check_redis.py"], + "Interval" => "10s", + "Timeout" => "5s" + ], + "Weights" => [ + "Passing" => 10, + "Warning" => 1 + ] + ]); }