*/ protected $errorCodes; /** * @var int */ protected $retryInterval; /** * @param array $errorCodes DB-specific error codes that allow retrying * @param int $retryInterval Seconds to wait before allowing next retry, 0 for no wait. */ public function __construct(array $errorCodes, int $retryInterval) { $this->errorCodes = $errorCodes; $this->retryInterval = $retryInterval; } /** * @inheritDoc */ public function shouldRetry(Exception $exception, int $retryCount): bool { if ( $exception instanceof PDOException && $exception->errorInfo && in_array($exception->errorInfo[1], $this->errorCodes) ) { if ($this->retryInterval > 0) { sleep($this->retryInterval); } return true; } return false; } }