private function failoverConnect()

in src/Apache/Ignite/Internal/Connection/ClientFailoverSocket.php [87:108]


    private function failoverConnect(): void
    {
        $errors = [];
        for ($i = 0; $i < $this->endpointsNumber; $i++) {
            $index = ($this->endpointIndex + $i) % $this->endpointsNumber;
            $endpoint = $this->config->getEndpoints()[$index];
            try {
                $this->changeState(ClientFailoverSocket::STATE_CONNECTING, $endpoint);
                $this->socket = new ClientSocket($endpoint, $this->config);
                $this->socket->connect();
                $this->changeState(ClientFailoverSocket::STATE_CONNECTED, $endpoint);
                $this->endpointIndex = $index;
                return;
            } catch (NoConnectionException $e) {
                Logger::logError($e->getMessage());
                array_push($errors, sprintf('[%s] %s', $endpoint, $e->getMessage()));
                $this->changeState(ClientFailoverSocket::STATE_DISCONNECTED, $endpoint);
            }
        }
        $this->socket = null;
        throw new NoConnectionException(implode(';', $errors));
    }