src/Eloquent/Repository.php
public function getByContinuously($column, $value, array $columns = ['*'], $retries = 10, $delayMs = 100, $maxDelay = 2000, $maxRetries = 100)
    {
        // Hard limits
        $maxDelay = ($maxDelay > 2000) ? 2000 : $maxDelay;
        $maxRetries = ($maxRetries > 100) ? 100 : $maxRetries;

        // Validate delay parameter
        if ($delayMs > $maxDelay) {
            throw new NodesException('Invalid input parameter. Maximum delay is '.$maxDelay.' milliseconds', 0, null, false);
        }

        // Validate retry parameter
        if ($retries > $maxRetries) {
            throw new NodesException('Invalid input parameter. Maximum retry amount is '.$maxRetries, 0, null, false);
        }

        // Retrieve entity continuously
        for ($try = 0; $try < $retries; $try++) {
            $entity = $this->getBy($column, $value, $columns);
            if (! empty($entity)) {
                return $entity;
            }

            // Delay next retry
            usleep($delayMs * 1000);
        }

        return false;
    }
public function getByContinuously($column, $value, array $columns = ['*'], $retries = 10, $delayMs = 100, $maxDelay = 2000, $maxRetries = 100)
    {
        // Hard limits
        $maxDelay = ($maxDelay > 2000) ? 2000 : $maxDelay;
        $maxRetries = ($maxRetries > 100) ? 100 : $maxRetries;

        // Validate delay parameter
        if ($delayMs > $maxDelay) {
            throw new NodesException('Invalid input parameter. Maximum delay is '.$maxDelay.' milliseconds', 0, null, false);
        }

        // Validate retry parameter
        if ($retries > $maxRetries) {
            throw new NodesException('Invalid input parameter. Maximum retry amount is '.$maxRetries, 0, null, false);
        }

        // Retrieve entity continuously
        for ($try = 0; $try < $retries; $try++) {
            $entity = $this->getBy($column, $value, $columns);
            if (! empty($entity)) {
                return $entity;
            }

            // Delay next retry
            usleep($delayMs * 1000);
        }

        return false;
    }
public function getByContinuously ( $ column , $ value , array $ columns = [ '*' ] , $ retries = 10 , $ delayMs = 100 , $ maxDelay = 2000 , $ maxRetries = 100 ) { // Hard limits $ maxDelay = ( $ maxDelay > 2000 ) ? 2000 : $ maxDelay ; $ maxRetries = ( $ maxRetries > 100 ) ? 100 : $ maxRetries ; // Validate delay parameter if ( $ delayMs > $ maxDelay ) { throw new NodesException ( 'Invalid input parameter. Maximum delay is ' . $ maxDelay . ' milliseconds' , 0 , null , false ) ; } // Validate retry parameter if ( $ retries > $ maxRetries ) { throw new NodesException ( 'Invalid input parameter. Maximum retry amount is ' . $ maxRetries , 0 , null , false ) ; } // Retrieve entity continuously for ( $ try = 0 ; $ try < $ retries ; $ try ++ ) { $ entity = $ this -> getBy ( $ column , $ value , $ columns ) ; if ( ! empty ( $ entity ) ) { return $ entity ; } // Delay next retry usleep ( $ delayMs * 1000 ) ; } return false ; }
Retrieve entity by a specific column and value. Will retry with a delay until found.

Should only be used in queues, where databases are in a cluster
and there's a chance it's not always in sync

@author Casper Rasmussen <cr@nodes.dk>

@param  string  $column
@param  string  $value
@param  array   $columns
@param  int $retries
@param  int $delayMs
@param  int $maxDelay
@param  int $maxRetries
@return \Illuminate\Database\Eloquent\Model
@throws \Nodes\Exceptions\Exception
Retrieve entity by a specific column and value . Will retry with a delay until found .