Last active
November 10, 2019 09:08
-
-
Save inhere/8e302ed5e6845360278092da26b1d5a6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php declare(strict_types=1); | |
namespace App\Common; | |
use ReflectionException; | |
use Swoft\Bean\Annotation\Mapping\Bean; | |
use Swoft\Bean\Annotation\Mapping\Inject; | |
use Swoft\Bean\Exception\ContainerException; | |
use Swoft\Consul\Agent; | |
use Swoft\Consul\Exception\ClientException; | |
use Swoft\Consul\Exception\ServerException; | |
use Swoft\Rpc\Client\Client; | |
use Swoft\Rpc\Client\Contract\ProviderInterface; | |
/** | |
* Class RpcProvider | |
* | |
* @since 2.0 | |
* | |
* @Bean() | |
*/ | |
class RpcProvider implements ProviderInterface | |
{ | |
/** | |
* @Inject() | |
* | |
* @var Agent | |
*/ | |
private $agent; | |
/** | |
* @param Client $client | |
* | |
* @return array | |
* @throws ReflectionException | |
* @throws ContainerException | |
* @throws ClientException | |
* @throws ServerException | |
* @example | |
* [ | |
* 'host:port', | |
* 'host:port', | |
* 'host:port', | |
* ] | |
*/ | |
public function getList(Client $client): array | |
{ | |
// Get health service from consul | |
$services = $this->agent->services(); | |
$services = [ | |
]; | |
return $services; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment