Completed
Push — master ( 6a3ea2...b97e84 )
by Maxence
13s
created
lib/Vendor/Elastic/Transport/Exception/NoNodeAvailableException.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,6 +15,5 @@
 block discarded – undo
15 15
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\Exception;
16 16
 
17 17
 use RuntimeException;
18
-class NoNodeAvailableException extends RuntimeException implements TransportException
19
-{
18
+class NoNodeAvailableException extends RuntimeException implements TransportException {
20 19
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
  * Elasticsearch B.V licenses this file to you under the MIT License.
12 12
  * See the LICENSE file in the project root for more information.
13 13
  */
14
-declare (strict_types=1);
14
+declare(strict_types=1);
15 15
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\Exception;
16 16
 
17 17
 use RuntimeException;
Please login to merge, or discard this patch.
lib/Vendor/Elastic/Transport/Exception/TransportException.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
  * Elasticsearch B.V licenses this file to you under the MIT License.
12 12
  * See the LICENSE file in the project root for more information.
13 13
  */
14
-declare (strict_types=1);
14
+declare(strict_types=1);
15 15
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\Exception;
16 16
 
17 17
 use Throwable;
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,6 +15,5 @@
 block discarded – undo
15 15
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\Exception;
16 16
 
17 17
 use Throwable;
18
-interface TransportException extends Throwable
19
-{
18
+interface TransportException extends Throwable {
20 19
 }
Please login to merge, or discard this patch.
lib/Vendor/Elastic/Transport/TransportBuilder.php 3 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  * Elasticsearch B.V licenses this file to you under the MIT License.
12 12
  * See the LICENSE file in the project root for more information.
13 13
  */
14
-declare (strict_types=1);
14
+declare(strict_types=1);
15 15
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport;
16 16
 
17 17
 use OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\NodePool\NodePoolInterface;
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         try {
100 100
             list($name, $encoded) = \explode(':', $cloudId);
101 101
             list($uri, $uuids) = \explode('$', \base64_decode($encoded));
102
-            list($es, ) = \explode(':', $uuids);
102
+            list($es,) = \explode(':', $uuids);
103 103
             return \sprintf("https://%s.%s", $es, $uri);
104 104
         } catch (Throwable $t) {
105 105
             throw new Exception\CloudIdParseException('Cloud ID not valid');
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,8 +24,7 @@
 block discarded – undo
24 24
 use Psr\Log\LoggerInterface;
25 25
 use Psr\Log\NullLogger;
26 26
 use Throwable;
27
-class TransportBuilder
28
-{
27
+class TransportBuilder {
29 28
     protected ClientInterface $client;
30 29
     protected NodePoolInterface $nodePool;
31 30
     protected LoggerInterface $logger;
Please login to merge, or discard this patch.
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -27,84 +27,84 @@
 block discarded – undo
27 27
 use Throwable;
28 28
 class TransportBuilder
29 29
 {
30
-    protected ClientInterface $client;
31
-    protected NodePoolInterface $nodePool;
32
-    protected LoggerInterface $logger;
33
-    protected array $hosts = [];
34
-    protected TracerInterface $OTelTracer;
35
-    public final function __construct()
36
-    {
37
-    }
38
-    public static function create() : TransportBuilder
39
-    {
40
-        return new static();
41
-    }
42
-    public function setClient(ClientInterface $client) : self
43
-    {
44
-        $this->client = $client;
45
-        return $this;
46
-    }
47
-    public function getClient() : ClientInterface
48
-    {
49
-        if (empty($this->client)) {
50
-            $this->client = Psr18ClientDiscovery::find();
51
-        }
52
-        return $this->client;
53
-    }
54
-    public function setNodePool(NodePoolInterface $nodePool) : self
55
-    {
56
-        $this->nodePool = $nodePool;
57
-        return $this;
58
-    }
59
-    public function getNodePool() : NodePoolInterface
60
-    {
61
-        if (empty($this->nodePool)) {
62
-            $this->nodePool = new SimpleNodePool(new RoundRobin(), new NoResurrect());
63
-        }
64
-        return $this->nodePool;
65
-    }
66
-    public function setLogger(LoggerInterface $logger) : self
67
-    {
68
-        $this->logger = $logger;
69
-        return $this;
70
-    }
71
-    public function getLogger() : LoggerInterface
72
-    {
73
-        if (empty($this->logger)) {
74
-            $this->logger = new NullLogger();
75
-        }
76
-        return $this->logger;
77
-    }
78
-    public function setHosts(array $hosts) : self
79
-    {
80
-        $this->hosts = $hosts;
81
-        return $this;
82
-    }
83
-    public function getHosts() : array
84
-    {
85
-        return $this->hosts;
86
-    }
87
-    public function setCloudId(string $cloudId) : self
88
-    {
89
-        $this->hosts = [$this->parseElasticCloudId($cloudId)];
90
-        return $this;
91
-    }
92
-    public function build() : Transport
93
-    {
94
-        return new Transport($this->getClient(), $this->getNodePool()->setHosts($this->hosts), $this->getLogger());
95
-    }
96
-    /**
97
-     * Return the URL of Elastic Cloud from the Cloud ID
98
-     */
99
-    private function parseElasticCloudId(string $cloudId) : string
100
-    {
101
-        try {
102
-            list($name, $encoded) = \explode(':', $cloudId);
103
-            list($uri, $uuids) = \explode('$', \base64_decode($encoded));
104
-            list($es, ) = \explode(':', $uuids);
105
-            return \sprintf("https://%s.%s", $es, $uri);
106
-        } catch (Throwable $t) {
107
-            throw new Exception\CloudIdParseException('Cloud ID not valid');
108
-        }
109
-    }
30
+	protected ClientInterface $client;
31
+	protected NodePoolInterface $nodePool;
32
+	protected LoggerInterface $logger;
33
+	protected array $hosts = [];
34
+	protected TracerInterface $OTelTracer;
35
+	public final function __construct()
36
+	{
37
+	}
38
+	public static function create() : TransportBuilder
39
+	{
40
+		return new static();
41
+	}
42
+	public function setClient(ClientInterface $client) : self
43
+	{
44
+		$this->client = $client;
45
+		return $this;
46
+	}
47
+	public function getClient() : ClientInterface
48
+	{
49
+		if (empty($this->client)) {
50
+			$this->client = Psr18ClientDiscovery::find();
51
+		}
52
+		return $this->client;
53
+	}
54
+	public function setNodePool(NodePoolInterface $nodePool) : self
55
+	{
56
+		$this->nodePool = $nodePool;
57
+		return $this;
58
+	}
59
+	public function getNodePool() : NodePoolInterface
60
+	{
61
+		if (empty($this->nodePool)) {
62
+			$this->nodePool = new SimpleNodePool(new RoundRobin(), new NoResurrect());
63
+		}
64
+		return $this->nodePool;
65
+	}
66
+	public function setLogger(LoggerInterface $logger) : self
67
+	{
68
+		$this->logger = $logger;
69
+		return $this;
70
+	}
71
+	public function getLogger() : LoggerInterface
72
+	{
73
+		if (empty($this->logger)) {
74
+			$this->logger = new NullLogger();
75
+		}
76
+		return $this->logger;
77
+	}
78
+	public function setHosts(array $hosts) : self
79
+	{
80
+		$this->hosts = $hosts;
81
+		return $this;
82
+	}
83
+	public function getHosts() : array
84
+	{
85
+		return $this->hosts;
86
+	}
87
+	public function setCloudId(string $cloudId) : self
88
+	{
89
+		$this->hosts = [$this->parseElasticCloudId($cloudId)];
90
+		return $this;
91
+	}
92
+	public function build() : Transport
93
+	{
94
+		return new Transport($this->getClient(), $this->getNodePool()->setHosts($this->hosts), $this->getLogger());
95
+	}
96
+	/**
97
+	 * Return the URL of Elastic Cloud from the Cloud ID
98
+	 */
99
+	private function parseElasticCloudId(string $cloudId) : string
100
+	{
101
+		try {
102
+			list($name, $encoded) = \explode(':', $cloudId);
103
+			list($uri, $uuids) = \explode('$', \base64_decode($encoded));
104
+			list($es, ) = \explode(':', $uuids);
105
+			return \sprintf("https://%s.%s", $es, $uri);
106
+		} catch (Throwable $t) {
107
+			throw new Exception\CloudIdParseException('Cloud ID not valid');
108
+		}
109
+	}
110 110
 }
Please login to merge, or discard this patch.
lib/Vendor/Elastic/Transport/NodePool/Node.php 3 patches
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -20,25 +20,25 @@
 block discarded – undo
20 20
 use function substr;
21 21
 class Node
22 22
 {
23
-    protected UriInterface $uri;
24
-    protected bool $alive = \true;
25
-    public function __construct(string $host)
26
-    {
27
-        if (substr($host, 0, 5) !== 'http:' && substr($host, 0, 6) !== 'https:') {
28
-            $host = sprintf("http://%s", $host);
29
-        }
30
-        $this->uri = Psr17FactoryDiscovery::findUriFactory()->createUri($host);
31
-    }
32
-    public function markAlive(bool $alive) : void
33
-    {
34
-        $this->alive = $alive;
35
-    }
36
-    public function isAlive() : bool
37
-    {
38
-        return $this->alive;
39
-    }
40
-    public function getUri() : UriInterface
41
-    {
42
-        return $this->uri;
43
-    }
23
+	protected UriInterface $uri;
24
+	protected bool $alive = \true;
25
+	public function __construct(string $host)
26
+	{
27
+		if (substr($host, 0, 5) !== 'http:' && substr($host, 0, 6) !== 'https:') {
28
+			$host = sprintf("http://%s", $host);
29
+		}
30
+		$this->uri = Psr17FactoryDiscovery::findUriFactory()->createUri($host);
31
+	}
32
+	public function markAlive(bool $alive) : void
33
+	{
34
+		$this->alive = $alive;
35
+	}
36
+	public function isAlive() : bool
37
+	{
38
+		return $this->alive;
39
+	}
40
+	public function getUri() : UriInterface
41
+	{
42
+		return $this->uri;
43
+	}
44 44
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
  * Elasticsearch B.V licenses this file to you under the MIT License.
12 12
  * See the LICENSE file in the project root for more information.
13 13
  */
14
-declare (strict_types=1);
14
+declare(strict_types=1);
15 15
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\NodePool;
16 16
 
17 17
 use OCA\FullTextSearch_Elasticsearch\Vendor\Http\Discovery\Psr17FactoryDiscovery;
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,8 +18,7 @@
 block discarded – undo
18 18
 use OCA\FullTextSearch_Elasticsearch\Vendor\Psr\Http\Message\UriInterface;
19 19
 use function sprintf;
20 20
 use function substr;
21
-class Node
22
-{
21
+class Node {
23 22
     protected UriInterface $uri;
24 23
     protected bool $alive = \true;
25 24
     public function __construct(string $host)
Please login to merge, or discard this patch.
lib/Vendor/Elastic/Transport/NodePool/NodePoolInterface.php 3 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@
 block discarded – undo
16 16
 
17 17
 interface NodePoolInterface
18 18
 {
19
-    public function nextNode() : Node;
20
-    /**
21
-     * @param string[] $hosts
22
-     */
23
-    public function setHosts(array $hosts) : self;
19
+	public function nextNode() : Node;
20
+	/**
21
+	 * @param string[] $hosts
22
+	 */
23
+	public function setHosts(array $hosts) : self;
24 24
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
  * Elasticsearch B.V licenses this file to you under the MIT License.
12 12
  * See the LICENSE file in the project root for more information.
13 13
  */
14
-declare (strict_types=1);
14
+declare(strict_types=1);
15 15
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\NodePool;
16 16
 
17 17
 interface NodePoolInterface
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,8 +14,7 @@
 block discarded – undo
14 14
 declare (strict_types=1);
15 15
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\NodePool;
16 16
 
17
-interface NodePoolInterface
18
-{
17
+interface NodePoolInterface {
19 18
     public function nextNode() : Node;
20 19
     /**
21 20
      * @param string[] $hosts
Please login to merge, or discard this patch.
lib/Vendor/Elastic/Transport/NodePool/Selector/SelectorInterface.php 3 patches
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -17,13 +17,13 @@
 block discarded – undo
17 17
 use OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\NodePool\Node;
18 18
 interface SelectorInterface
19 19
 {
20
-    public function nextNode() : Node;
21
-    /**
22
-     * @param Node[] $nodes
23
-     */
24
-    public function setNodes(array $nodes) : void;
25
-    /**
26
-     * @return Node[]
27
-     */
28
-    public function getNodes() : array;
20
+	public function nextNode() : Node;
21
+	/**
22
+	 * @param Node[] $nodes
23
+	 */
24
+	public function setNodes(array $nodes) : void;
25
+	/**
26
+	 * @return Node[]
27
+	 */
28
+	public function getNodes() : array;
29 29
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
  * Elasticsearch B.V licenses this file to you under the MIT License.
12 12
  * See the LICENSE file in the project root for more information.
13 13
  */
14
-declare (strict_types=1);
14
+declare(strict_types=1);
15 15
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\NodePool\Selector;
16 16
 
17 17
 use OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\NodePool\Node;
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,8 +15,7 @@
 block discarded – undo
15 15
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\NodePool\Selector;
16 16
 
17 17
 use OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\NodePool\Node;
18
-interface SelectorInterface
19
-{
18
+interface SelectorInterface {
20 19
     public function nextNode() : Node;
21 20
     /**
22 21
      * @param Node[] $nodes
Please login to merge, or discard this patch.
lib/Vendor/Elastic/Transport/NodePool/Selector/RoundRobin.php 3 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -18,17 +18,17 @@
 block discarded – undo
18 18
 use OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\Exception\NoNodeAvailableException;
19 19
 class RoundRobin implements SelectorInterface
20 20
 {
21
-    use SelectorTrait;
22
-    public function nextNode() : Node
23
-    {
24
-        if (empty($this->getNodes())) {
25
-            $className = \substr(__CLASS__, \strrpos(__CLASS__, '\\') + 1);
26
-            throw new NoNodeAvailableException(\sprintf("No node available. Please use %s::setNodes() before calling %s::nextNode().", $className, $className));
27
-        }
28
-        $node = \current($this->nodes);
29
-        if (\false === \next($this->nodes)) {
30
-            \reset($this->nodes);
31
-        }
32
-        return $node;
33
-    }
21
+	use SelectorTrait;
22
+	public function nextNode() : Node
23
+	{
24
+		if (empty($this->getNodes())) {
25
+			$className = \substr(__CLASS__, \strrpos(__CLASS__, '\\') + 1);
26
+			throw new NoNodeAvailableException(\sprintf("No node available. Please use %s::setNodes() before calling %s::nextNode().", $className, $className));
27
+		}
28
+		$node = \current($this->nodes);
29
+		if (\false === \next($this->nodes)) {
30
+			\reset($this->nodes);
31
+		}
32
+		return $node;
33
+	}
34 34
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,8 +16,7 @@
 block discarded – undo
16 16
 
17 17
 use OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\NodePool\Node;
18 18
 use OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\Exception\NoNodeAvailableException;
19
-class RoundRobin implements SelectorInterface
20
-{
19
+class RoundRobin implements SelectorInterface {
21 20
     use SelectorTrait;
22 21
     public function nextNode() : Node
23 22
     {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
  * Elasticsearch B.V licenses this file to you under the MIT License.
12 12
  * See the LICENSE file in the project root for more information.
13 13
  */
14
-declare (strict_types=1);
14
+declare(strict_types=1);
15 15
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\NodePool\Selector;
16 16
 
17 17
 use OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\NodePool\Node;
Please login to merge, or discard this patch.
lib/Vendor/Elastic/Transport/NodePool/Selector/SelectorTrait.php 3 patches
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -18,18 +18,18 @@
 block discarded – undo
18 18
 use OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\Exception\InvalidArrayException;
19 19
 trait SelectorTrait
20 20
 {
21
-    protected array $nodes = [];
22
-    public function setNodes(array $nodes) : void
23
-    {
24
-        foreach ($nodes as $node) {
25
-            if (!$node instanceof Node) {
26
-                throw new InvalidArrayException(\sprintf("The nodes array must contain only %s objects", Node::class));
27
-            }
28
-        }
29
-        $this->nodes = $nodes;
30
-    }
31
-    public function getNodes() : array
32
-    {
33
-        return $this->nodes;
34
-    }
21
+	protected array $nodes = [];
22
+	public function setNodes(array $nodes) : void
23
+	{
24
+		foreach ($nodes as $node) {
25
+			if (!$node instanceof Node) {
26
+				throw new InvalidArrayException(\sprintf("The nodes array must contain only %s objects", Node::class));
27
+			}
28
+		}
29
+		$this->nodes = $nodes;
30
+	}
31
+	public function getNodes() : array
32
+	{
33
+		return $this->nodes;
34
+	}
35 35
 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,8 +16,7 @@
 block discarded – undo
16 16
 
17 17
 use OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\NodePool\Node;
18 18
 use OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\Exception\InvalidArrayException;
19
-trait SelectorTrait
20
-{
19
+trait SelectorTrait {
21 20
     protected array $nodes = [];
22 21
     public function setNodes(array $nodes) : void
23 22
     {
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
  * Elasticsearch B.V licenses this file to you under the MIT License.
12 12
  * See the LICENSE file in the project root for more information.
13 13
  */
14
-declare (strict_types=1);
14
+declare(strict_types=1);
15 15
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\NodePool\Selector;
16 16
 
17 17
 use OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\NodePool\Node;
Please login to merge, or discard this patch.
lib/Vendor/Elastic/Transport/NodePool/SimpleNodePool.php 3 patches
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -22,49 +22,49 @@
 block discarded – undo
22 22
 use function sprintf;
23 23
 class SimpleNodePool implements NodePoolInterface
24 24
 {
25
-    /**
26
-     * @var array
27
-     */
28
-    protected $nodes = [];
29
-    /**
30
-     * @var SelectorInterface
31
-     */
32
-    protected $selector;
33
-    /**
34
-     * @var ResurrectInterface
35
-     */
36
-    protected $resurrect;
37
-    public function __construct(SelectorInterface $selector, ResurrectInterface $resurrect)
38
-    {
39
-        $this->selector = $selector;
40
-        $this->resurrect = $resurrect;
41
-    }
42
-    public function setHosts(array $hosts) : self
43
-    {
44
-        $this->nodes = [];
45
-        foreach ($hosts as $host) {
46
-            $this->nodes[] = new Node($host);
47
-        }
48
-        shuffle($this->nodes);
49
-        // randomize for use different hosts on each execution
50
-        $this->selector->setNodes($this->nodes);
51
-        return $this;
52
-    }
53
-    public function nextNode() : Node
54
-    {
55
-        $totNodes = count($this->nodes);
56
-        $dead = 0;
57
-        while ($dead < $totNodes) {
58
-            $next = $this->selector->nextNode();
59
-            if ($next->isAlive()) {
60
-                return $next;
61
-            }
62
-            if ($this->resurrect->ping($next)) {
63
-                $next->markAlive(\true);
64
-                return $next;
65
-            }
66
-            $dead++;
67
-        }
68
-        throw new NoNodeAvailableException(sprintf('No alive nodes. All the %d nodes seem to be down.', $totNodes));
69
-    }
25
+	/**
26
+	 * @var array
27
+	 */
28
+	protected $nodes = [];
29
+	/**
30
+	 * @var SelectorInterface
31
+	 */
32
+	protected $selector;
33
+	/**
34
+	 * @var ResurrectInterface
35
+	 */
36
+	protected $resurrect;
37
+	public function __construct(SelectorInterface $selector, ResurrectInterface $resurrect)
38
+	{
39
+		$this->selector = $selector;
40
+		$this->resurrect = $resurrect;
41
+	}
42
+	public function setHosts(array $hosts) : self
43
+	{
44
+		$this->nodes = [];
45
+		foreach ($hosts as $host) {
46
+			$this->nodes[] = new Node($host);
47
+		}
48
+		shuffle($this->nodes);
49
+		// randomize for use different hosts on each execution
50
+		$this->selector->setNodes($this->nodes);
51
+		return $this;
52
+	}
53
+	public function nextNode() : Node
54
+	{
55
+		$totNodes = count($this->nodes);
56
+		$dead = 0;
57
+		while ($dead < $totNodes) {
58
+			$next = $this->selector->nextNode();
59
+			if ($next->isAlive()) {
60
+				return $next;
61
+			}
62
+			if ($this->resurrect->ping($next)) {
63
+				$next->markAlive(\true);
64
+				return $next;
65
+			}
66
+			$dead++;
67
+		}
68
+		throw new NoNodeAvailableException(sprintf('No alive nodes. All the %d nodes seem to be down.', $totNodes));
69
+	}
70 70
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
  * Elasticsearch B.V licenses this file to you under the MIT License.
12 12
  * See the LICENSE file in the project root for more information.
13 13
  */
14
-declare (strict_types=1);
14
+declare(strict_types=1);
15 15
 namespace OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\NodePool;
16 16
 
17 17
 use OCA\FullTextSearch_Elasticsearch\Vendor\Elastic\Transport\NodePool\Resurrect\ResurrectInterface;
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,8 +20,7 @@
 block discarded – undo
20 20
 use function count;
21 21
 use function shuffle;
22 22
 use function sprintf;
23
-class SimpleNodePool implements NodePoolInterface
24
-{
23
+class SimpleNodePool implements NodePoolInterface {
25 24
     /**
26 25
      * @var array
27 26
      */
Please login to merge, or discard this patch.