diff --git a/composer.json b/composer.json index c8558c9..736cb82 100644 --- a/composer.json +++ b/composer.json @@ -11,12 +11,12 @@ "require": { "php": ">=8.0", "ext-json": "*", - "sensiolabs/consul-php-sdk": "v4.1.1" + "game-worker/kiri-consul": "dev-master" }, "autoload": { "psr-4": { "Kiri\\Rpc\\": "src/" - } + } }, "require-dev": { } diff --git a/src/Consumers.php b/src/Consumers.php index 232d08e..fc87cea 100644 --- a/src/Consumers.php +++ b/src/Consumers.php @@ -3,7 +3,10 @@ namespace Kiri\Rpc; +use Kiri\Kiri; use Kiri\Pool\Pool; +use SensioLabs\Consul\ServiceFactory; +use SensioLabs\Consul\Services\Agent; /** * @@ -19,34 +22,38 @@ class Consumers implements OnRpcConsumerInterface /** + * @param string $service * @param string $method * @param mixed $data * @param string $version */ - public function notify(string $method, mixed $data, string $version = '2.0'): void + public function notify(string $service, string $method, mixed $data, string $version = '2.0'): void { } /** + * @param string $service * @param string $method * @param mixed $data * @param string $version * @param string $id * @return mixed */ - public function get(string $method, mixed $data, string $version = '2.0', string $id = ''): mixed + public function get(string $service, string $method, mixed $data, string $version = '2.0', string $id = ''): mixed { } - private function get_consul() + private function get_consul($service) { + $sf = Kiri::getDi()->get(\Kiri\Consul\Agent::class); + $content = $sf->service->service($service)->getBody()->getContents(); - + $content = json_decode($content, true); }