當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Job::attempts方法代碼示例

本文整理匯總了PHP中Illuminate\Contracts\Queue\Job::attempts方法的典型用法代碼示例。如果您正苦於以下問題:PHP Job::attempts方法的具體用法?PHP Job::attempts怎麽用?PHP Job::attempts使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Contracts\Queue\Job的用法示例。


在下文中一共展示了Job::attempts方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: fire

 public function fire(Job $job, $data)
 {
     $this->codex->log('alert', 'codex.hooks.git.sync.project.command', ['jobName' => $job->getName(), 'jobAttempts' => $job->attempts(), 'project' => $data['project']]);
     if ($job->attempts() > 2) {
         $job->delete();
     }
     $this->codex->getProject($data['project'])->gitSyncer()->syncAll();
 }
開發者ID:docit,項目名稱:git-hook,代碼行數:8,代碼來源:SyncProject.php

示例2: fire

 public function fire(Job $job, $data)
 {
     if ($job->attempts() > 2) {
         $job->delete();
     }
     $this->factory->getProject($data['project'])->githubSync()->syncAll();
 }
開發者ID:docit,項目名稱:github-hook,代碼行數:7,代碼來源:GithubSyncProject.php

示例3: process

 /**
  * Process a given job from the queue.
  *
  * @param  string  $connection
  * @param  \Illuminate\Contracts\Queue\Job  $job
  * @param  int  $maxTries
  * @param  int  $delay
  * @return array|null
  *
  * @throws \Throwable
  */
 public function process($connection, Job $job, $maxTries = 0, $delay = 0)
 {
     // @TODO Tests using File::put('/test', serialize());
     if ($maxTries > 0 && $job->attempts() > $maxTries) {
         return $this->logFailedJob($connection, $job);
     }
     try {
         // First we will fire off the job. Once it is done we will see if it will
         // be auto-deleted after processing and if so we will go ahead and run
         // the delete method on the job. Otherwise we will just keep moving.
         $this->setJob($job);
         if ($this->isAnSqsJob()) {
             $job = $this->processSqsJob($job);
         }
         $job->fire();
         $this->raiseAfterJobEvent($connection, $job);
         return ['job' => $job, 'failed' => false];
     } catch (Exception $e) {
         // If we catch an exception, we will attempt to release the job back onto
         // the queue so it is not lost. This will let is be retried at a later
         // time by another listener (or the same one). We will do that here.
         if (!$job->isDeleted()) {
             $job->release($delay);
         }
         throw $e;
     } catch (Throwable $e) {
         if (!$job->isDeleted()) {
             $job->release($delay);
         }
         throw $e;
     }
 }
開發者ID:kirschbaum,項目名稱:laravel-sns-subscription-queues,代碼行數:43,代碼來源:QueueWorker.php

示例4: process

 public function process($connection, Job $job, $maxTries = 0, $delay = 0)
 {
     if ($maxTries > 0 && $job->attempts() > $maxTries) {
         return $this->logFailedJob($connection, $job);
     }
     try {
         // First we will fire off the job. Once it is done we will see if it will
         // be auto-deleted after processing and if so we will go ahead and run
         // the delete method on the job. Otherwise we will just keep moving.
         $job->fire();
         return ['job' => $job, 'failed' => false];
     } catch (Exception $e) {
         // If we catch an exception, we will attempt to release the job back onto
         // the queue so it is not lost. This will let is be retried at a later
         // time by another listener (or the same one). We will do that here.
         if (!$job->isDeleted()) {
             // Add exponential delay based on the job attempts and the provided delay seconds.
             // The delay will default to 30 seconds by default or when delay is set to zero.
             // A max delay of 2 hours will be used when exponential delay exceeds 2 hours
             // Example of delay in seconds: 30, 60, 90, 180, ... 7200
             $delay = $delay ?: 30;
             $delay = $job->attempts() > 1 ? pow(2, $job->attempts() - 2) * $delay : 0;
             $maxDelay = 60 * 60 * 2;
             if ($delay > $maxDelay) {
                 $delay = $maxDelay;
             }
             $job->release($delay);
         }
         throw $e;
     }
 }
開發者ID:deboorn,項目名稱:expbackoffworker,代碼行數:31,代碼來源:Worker.php

示例5: markJobAsFailedIfHasExceededMaxAttempts

 /**
  * Mark the given job as failed if it has exceeded the maximum allowed attempts.
  *
  * @param  string  $connectionName
  * @param  \Illuminate\Contracts\Queue\Job  $job
  * @param  int  $maxTries
  * @param  \Exception  $e
  * @return void
  */
 protected function markJobAsFailedIfHasExceededMaxAttempts($connectionName, $job, $maxTries, $e)
 {
     $maxTries = !is_null($job->maxTries()) ? $job->maxTries() : $maxTries;
     if ($maxTries === 0 || $job->attempts() < $maxTries) {
         return;
     }
     $this->failJob($connectionName, $job, $e);
 }
開發者ID:bryanashley,項目名稱:framework,代碼行數:17,代碼來源:Worker.php

示例6: process

 /**
  * Process a given job from the queue.
  *
  * @param  string  $connection
  * @param  \Illuminate\Contracts\Queue\Job  $job
  * @param  int  $maxTries
  * @param  int  $delay
  * @return array|null
  *
  * @throws \Throwable
  */
 public function process($connection, Job $job, $maxTries = 0, $delay = 0)
 {
     if ($maxTries > 0 && $job->attempts() > $maxTries) {
         return $this->logFailedJob($connection, $job);
     }
     try {
         $this->raiseBeforeJobEvent($connection, $job);
         // First we will fire off the job. Once it is done we will see if it will be
         // automatically deleted after processing and if so we'll fire the delete
         // method on the job. Otherwise, we will just keep on running our jobs.
         $job->fire();
         $this->raiseAfterJobEvent($connection, $job);
         return ['job' => $job, 'failed' => false];
     } catch (Exception $e) {
         $this->handleJobException($connection, $job, $delay, $e);
     } catch (Throwable $e) {
         $this->handleJobException($connection, $job, $delay, $e);
     }
 }
開發者ID:teckwei1993,項目名稱:laravel-in-directadmin,代碼行數:30,代碼來源:Worker.php

示例7: attempts

 /**
  * Get the number of times the job has been attempted.
  *
  * @return int
  */
 public function attempts()
 {
     return $this->job ? $this->job->attempts() : 1;
 }
開發者ID:qasem2rubik,項目名稱:laravel,代碼行數:9,代碼來源:InteractsWithQueue.php

示例8: markJobAsFailedIfHasExceededMaxAttempts

 /**
  * Mark the given job as failed if it has exceeded the maximum allowed attempts.
  *
  * @param  string  $connectionName
  * @param  \Illuminate\Contracts\Queue\Job  $job
  * @param  int  $maxTries
  * @param  \Exception  $e
  * @return void
  */
 protected function markJobAsFailedIfHasExceededMaxAttempts($connectionName, $job, $maxTries, $e)
 {
     if ($maxTries === 0 || $job->attempts() < $maxTries) {
         return;
     }
     // If the job has failed, we will delete it, call the "failed" method and then call
     // an event indicating the job has failed so it can be logged if needed. This is
     // to allow every developer to better keep monitor of their failed queue jobs.
     $job->delete();
     $job->failed($e);
     $this->raiseFailedJobEvent($connectionName, $job, $e);
 }
開發者ID:davidhemphill,項目名稱:framework,代碼行數:21,代碼來源:Worker.php

示例9: process

 /**
  * Process a given job from the queue.
  *
  * @param  string  $connection
  * @param  \Illuminate\Contracts\Queue\Job  $job
  * @param  int  $maxTries
  * @param  int  $delay
  * @return void
  *
  * @throws \Throwable
  */
 public function process($connection, Job $job, $maxTries = 0, $delay = 0)
 {
     if ($maxTries > 0 && $job->attempts() > $maxTries) {
         return $this->logFailedJob($connection, $job);
     }
     try {
         $this->raiseBeforeJobEvent($connection, $job);
         // Here we will fire off the job and let it process. We will catch any exceptions so
         // they can be reported to the developers logs, etc. Once the job is finished the
         // proper events will be fired to let any listeners know this job has finished.
         $job->fire();
         $this->raiseAfterJobEvent($connection, $job);
     } catch (Exception $e) {
         $this->handleJobException($connection, $job, $delay, $e);
     } catch (Throwable $e) {
         $this->handleJobException($connection, $job, $delay, $e);
     }
 }
開發者ID:mark86092,項目名稱:laravel-framework,代碼行數:29,代碼來源:Worker.php


注:本文中的Illuminate\Contracts\Queue\Job::attempts方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。