carno-php /
hrpc
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Service registry via "consul" |
||
| 4 | * User: moyo |
||
| 5 | * Date: 13/12/2017 |
||
| 6 | * Time: 11:21 AM |
||
| 7 | */ |
||
| 8 | |||
| 9 | namespace Carno\HRPC\Serviced; |
||
| 10 | |||
| 11 | use Carno\Consul\Registry as CRegistry; |
||
|
0 ignored issues
–
show
|
|||
| 12 | use Carno\Consul\Types\Agent; |
||
|
0 ignored issues
–
show
The type
Carno\Consul\Types\Agent was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 13 | use Carno\Consul\Types\Service; |
||
|
0 ignored issues
–
show
The type
Carno\Consul\Types\Service was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 14 | use Carno\Consul\Types\Tagging; |
||
|
0 ignored issues
–
show
The type
Carno\Consul\Types\Tagging was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 15 | use Carno\Net\Address; |
||
| 16 | use Carno\Promise\Promise; |
||
| 17 | use Carno\Promise\Promised; |
||
| 18 | use Carno\RPC\Service\Router; |
||
| 19 | |||
| 20 | class ConsulRG implements Registry |
||
| 21 | { |
||
| 22 | /** |
||
| 23 | * @var Agent |
||
| 24 | */ |
||
| 25 | private $cAgent = null; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @var Router |
||
| 29 | */ |
||
| 30 | private $dRouter = null; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * @var Tagging |
||
| 34 | */ |
||
| 35 | private $dTagging = null; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * @var Service[] |
||
| 39 | */ |
||
| 40 | private $sRegistered = []; |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Register constructor. |
||
| 44 | * @param Agent $agent |
||
| 45 | * @param Router $router |
||
| 46 | * @param Tagging $tagging |
||
| 47 | */ |
||
| 48 | public function __construct(Agent $agent, Router $router, Tagging $tagging) |
||
| 49 | { |
||
| 50 | $this->cAgent = $agent; |
||
| 51 | $this->dRouter = $router; |
||
| 52 | $this->dTagging = $tagging; |
||
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * @param Address $advertise |
||
| 57 | * @return Promised |
||
| 58 | */ |
||
| 59 | public function register(Address $advertise) : Promised |
||
| 60 | { |
||
| 61 | $waits = []; |
||
| 62 | |||
| 63 | foreach ($this->dRouter->servers() as $server) { |
||
| 64 | $this->sRegistered[] = $service = (new CRegistry($this->cAgent)) |
||
| 65 | ->servicing($advertise, $server, $this->dTagging->getTags()) |
||
| 66 | ; |
||
| 67 | |||
| 68 | ($ready = $service->ready())->then(static function () use ($service) { |
||
| 69 | logger('hrpc')->info('Service has been registered', ['node' => $service->endpoint()]); |
||
| 70 | }); |
||
| 71 | |||
| 72 | $waits[] = $ready; |
||
| 73 | } |
||
| 74 | |||
| 75 | return Promise::all(...$waits); |
||
| 76 | } |
||
| 77 | |||
| 78 | /** |
||
| 79 | * @return Promised |
||
| 80 | */ |
||
| 81 | public function deregister() : Promised |
||
| 82 | { |
||
| 83 | $waits = []; |
||
| 84 | |||
| 85 | foreach ($this->sRegistered as $service) { |
||
| 86 | ($respond = $service->deregister())->then(static function () use ($service) { |
||
| 87 | logger('hrpc')->info('Service has been deregistered', ['node' => $service->endpoint()]); |
||
| 88 | }); |
||
| 89 | $waits[] = $respond; |
||
| 90 | } |
||
| 91 | |||
| 92 | return Promise::all(...$waits); |
||
| 93 | } |
||
| 94 | } |
||
| 95 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths