Doctrine\MongoDB\Connection::retry PHP Method

retry() protected method

If the closure does not return successfully within the configured number of retries, its first exception will be thrown.
protected retry ( Closure $retry ) : mixed
$retry Closure
return mixed
    protected function retry(\Closure $retry)
    {
        $numRetries = $this->config->getRetryConnect();
        if ($numRetries < 1) {
            return $retry();
        }
        $firstException = null;
        for ($i = 0; $i <= $numRetries; $i++) {
            try {
                return $retry();
            } catch (\MongoException $e) {
                if ($firstException === null) {
                    $firstException = $e;
                }
                if ($i === $numRetries) {
                    throw $firstException;
                }
            }
        }
    }