| Total Complexity | 6 |
| Total Lines | 71 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 2 |
| 1 | <?php |
||
| 19 | class Clustered implements Cluster |
||
| 20 | { |
||
| 21 | use Options; |
||
| 22 | use Modifier; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @var Resources |
||
| 26 | */ |
||
| 27 | private $resources = null; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @var Endpoints[] |
||
| 31 | */ |
||
| 32 | private $targets = []; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @var array |
||
| 36 | */ |
||
| 37 | private $tags = []; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Clustered constructor. |
||
| 41 | * @param Resources $resources |
||
| 42 | * @param string ...$tags |
||
| 43 | */ |
||
| 44 | public function __construct(Resources $resources, string ...$tags) |
||
| 45 | { |
||
| 46 | $this->resources = $resources; |
||
| 47 | $this->tags = $tags; |
||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @return string[] |
||
| 52 | */ |
||
| 53 | public function tags() : array |
||
| 54 | { |
||
| 55 | return $this->tags; |
||
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * @param string $server |
||
| 60 | */ |
||
| 61 | public function joining(string $server) : void |
||
| 62 | { |
||
| 63 | $cluster = |
||
| 64 | $this->targets[$server] ?? |
||
| 65 | $this->targets[$server] = $this->modifying(new Endpoints($server, $this->tags(), $this->options($server))) |
||
| 66 | ; |
||
| 67 | |||
| 68 | $this->resources->initialize(Scenes::SERVICE, '', $server, $cluster); |
||
| 69 | } |
||
| 70 | |||
| 71 | /** |
||
| 72 | * @param string $server |
||
| 73 | */ |
||
| 74 | public function leaving(string $server) : void |
||
| 77 | } |
||
| 78 | |||
| 79 | /** |
||
| 80 | * @param string $server |
||
| 81 | * @param string ...$tags |
||
| 82 | * @return Client |
||
| 83 | */ |
||
| 84 | public function picking(string $server, string ...$tags) : object |
||
| 93 |