コード例 #1
0
 public function fire(Job $job, $data)
 {
     if ($job->attempts() > 2) {
         $job->delete();
     }
     $this->factory->getProject($data['project'])->githubSync()->syncAll();
 }
コード例 #2
0
 /**
  * Raise the failed queue job event.
  *
  * @param  \Illuminate\Contracts\Queue\Job  $job
  * @return void
  */
 protected function raiseFailedJobEvent(Job $job)
 {
     $data = json_decode($job->getRawBody(), true);
     if ($this->container->bound('events')) {
         $this->container['events']->fire('illuminate.queue.failed', array('sync', $job, $data));
     }
 }
コード例 #3
0
ファイル: BroadcastEvent.php プロジェクト: scrobot/Lumen
 /**
  * Handle the queued job.
  *
  * @param  \Illuminate\Contracts\Queue\Job $job
  * @param  array $data
  * @return void
  */
 public function fire(Job $job, array $data)
 {
     $event = unserialize($data['event']);
     $name = method_exists($event, 'broadcastAs') ? $event->broadcastAs() : get_class($event);
     $this->broadcaster->broadcast($event->broadcastOn(), $name, $this->getPayloadFromEvent($event));
     $job->delete();
 }
コード例 #4
0
ファイル: Worker.php プロジェクト: deboorn/expbackoffworker
 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;
     }
 }
コード例 #5
0
 /**
  * @param \Illuminate\Contracts\Queue\Job $job
  * @param array $data
  * @return mixed
  */
 public function fire($job, array $data)
 {
     $id = $data[0];
     $task = $this->serializer->unserialize($data[1]);
     $response = call_user_func($task);
     $job->delete();
     $this->publisher->publish("kyew:task:{$id}", $response);
 }
コード例 #6
0
ファイル: SyncProject.php プロジェクト: docit/git-hook
 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();
 }
 /**
  * Handle a queued push notification message job.
  * 
  * @param \Illuminate\Contracts\Queue\Job  $job
  * @param DeveloperDynamo\PushNotification\Payload\AbstractPayload $payload
  * @param array<DeveloperDynamo\PushNotification\Token> $tokens
  * @return void
  */
 public function handleQueuedSending($job, $data)
 {
     //Unserialize data
     $payload = unserialize($data['payload']);
     $tokens = unserialize($data['tokens']);
     //Execute task
     $this->send($payload, $tokens);
     //Delete job from the queue
     $job->delete();
 }
コード例 #8
0
ファイル: DeleteTenant.php プロジェクト: DavidIWilson/site1
 /**
  * Run queue on deleting a model.
  *
  * @param  \Illuminate\Contracts\Queue\Job  $job
  * @param  array  $data
  *
  * @return void
  */
 public function fire(Job $job, array $data)
 {
     $database = Arr::get($data, 'database');
     $migrator = $this->resolveMigrator($data);
     $entity = $this->resolveModelEntity($migrator, $data);
     if (is_null($entity)) {
         $job->delete();
         return;
     }
     $migrator->runReset($entity, $database);
     $job->delete();
 }
コード例 #9
0
 /**
  * Write the status output for the queue walker.
  *
  * @param  \Illuminate\Contracts\Queue\Job  $job
  * @param  bool  $failed
  * @return void
  */
 protected function writeOutput(Job $job, $failed)
 {
     if ($failed) {
         $this->output->writeln('<error>Failed:</error> ' . $job->getName());
     } else {
         $this->output->writeln('<info>Processed:</info> ' . $job->getName());
     }
 }
コード例 #10
0
 /**
  * Raise the failed queue job event.
  *
  * @param  string  $connection
  * @param  \Illuminate\Contracts\Queue\Job  $job
  * @return void
  */
 protected function raiseFailedJobEvent($connection, Job $job)
 {
     if ($this->events) {
         $data = json_decode($job->getRawBody(), true);
         $this->events->fire(new Events\JobFailed($connection, $job, $data));
     }
 }
コード例 #11
0
 /**
  * Get the number of times the job has been attempted.
  *
  * @return int
  */
 public function attempts()
 {
     return $this->job ? $this->job->attempts() : 1;
 }
コード例 #12
0
ファイル: WorkCommand.php プロジェクト: saj696/pipe
 /**
  * Write the status output for the queue worker.
  *
  * @param  \Illuminate\Contracts\Queue\Job $job
  * @param  bool $failed
  * @return void
  */
 protected function writeOutput(Job $job, $failed)
 {
     if ($failed) {
         $this->output->writeln('<error>[' . Carbon::now()->format('Y-m-d H:i:s') . '] Failed:</error> ' . $job->getName());
     } else {
         $this->output->writeln('<info>[' . Carbon::now()->format('Y-m-d H:i:s') . '] Processed:</info> ' . $job->getName());
     }
 }
コード例 #13
0
ファイル: SyncQueue.php プロジェクト: bryanashley/framework
 /**
  * Handle the failed job.
  *
  * @param  \Illuminate\Contracts\Queue\Job  $job
  * @param  \Exception  $e
  * @return array
  */
 protected function handleFailedJob(Job $job, $e)
 {
     $job->failed($e);
     $this->raiseFailedJobEvent($job, $e);
 }
コード例 #14
0
ファイル: QueueMonitorJob.php プロジェクト: nodes-php/core
 /**
  * fire.
  *
  * @author Casper Rasmussen <*****@*****.**>
  *
  * @param \Illuminate\Contracts\Queue\Job $job
  * @param                                 $queuName
  *
  * @return void
  */
 public function fire(Job $job, $queueName)
 {
     (new Client())->patch('https://nstack.io/api/queues/monitors/' . $queueName);
     $job->delete();
 }
コード例 #15
0
 public function setSqsJob(Job $job)
 {
     $this->sqs_job = $job->getSqsJob();
 }
コード例 #16
0
ファイル: Mailer.php プロジェクト: Volicon/framework
 /**
  * Handle a queued e-mail message job.
  *
  * @param  \Illuminate\Contracts\Queue\Job  $job
  * @param  array  $data
  * @return void
  */
 public function handleQueuedMessage($job, $data)
 {
     $this->send($data['view'], $data['data'], $this->getQueuedCallable($data));
     $job->delete();
 }
コード例 #17
0
ファイル: Worker.php プロジェクト: edwardricardo/zenska
 /**
  * Raise the after queue job event.
  *
  * @param  string $connection
  * @param  \Illuminate\Contracts\Queue\Job $job
  * @return void
  */
 protected function raiseAfterJobEvent($connection, Job $job)
 {
     if ($this->events) {
         $data = json_decode($job->getRawBody(), true);
         $this->events->fire('illuminate.queue.after', [$connection, $job, $data]);
     }
 }
コード例 #18
0
ファイル: SyncQueue.php プロジェクト: risan/framework
 /**
  * Raise the failed queue job event.
  *
  * @param  \Illuminate\Contracts\Queue\Job  $job
  * @return void
  */
 protected function raiseFailedJobEvent(Job $job)
 {
     $data = json_decode($job->getRawBody(), true);
     if ($this->container->bound('events')) {
         $this->container['events']->fire(new Events\JobFailed('sync', $job, $data));
     }
 }
コード例 #19
0
 /**
  * Handle the queued job.
  *
  * @param  \Illuminate\Contracts\Queue\Job  $job
  * @param  array  $data
  * @return void
  */
 public function fire(Job $job, array $data)
 {
     call_user_func_array([$this->container->make($data['class']), $data['method']], $data['data']);
     $job->delete();
 }
コード例 #20
0
 /**
  * Release the job back into the queue.
  *
  * @param  int   $delay
  * @return void
  */
 public function release($delay = 0)
 {
     if ($this->job) {
         return $this->job->release($delay);
     }
 }
コード例 #21
0
ファイル: Worker.php プロジェクト: bryanashley/framework
 /**
  * Mark the given job as failed and raise the relevant event.
  *
  * @param  string  $connectionName
  * @param  \Illuminate\Contracts\Queue\Job  $job
  * @param  \Exception  $e
  * @return void
  */
 protected function failJob($connectionName, $job, $e)
 {
     if ($job->isDeleted()) {
         return;
     }
     try {
         // 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);
     } finally {
         $this->raiseFailedJobEvent($connectionName, $job, $e);
     }
 }
コード例 #22
0
ファイル: SMS.php プロジェクト: adetoola/sms
 /**
  * Handle a queued e-mail message job.
  *
  * @param  \Illuminate\Contracts\Queue\Job  $job
  * @param  array  $data
  * @return void
  */
 public function handleQueuedMessage($job, $data)
 {
     $this->send($data['recepient'], $data['message'], $data['sender'], $data['message_type']);
     $job->delete();
 }
コード例 #23
0
 /**
  * Handle a queued message job.
  *
  * @param  \Illuminate\Contracts\Queue\Job  $job
  * @param  array  $data
  *
  * @return void
  */
 public function handleQueuedMessage(Job $job, $data)
 {
     $this->send($this->getQueuedCallable($data));
     $job->delete();
 }
コード例 #24
0
ファイル: Worker.php プロジェクト: AlexCutts/framework
 /**
  * Raise the failed queue job event.
  *
  * @param  string  $connection
  * @param  \Illuminate\Contracts\Queue\Job  $job
  * @return void
  */
 protected function raiseFailedJobEvent($connection, Job $job)
 {
     if ($this->events) {
         $data = json_decode($job->getRawBody(), true);
         $this->events->fire('illuminate.queue.failed', array($connection, $job, $data));
     }
 }
コード例 #25
0
ファイル: Worker.php プロジェクト: davidhemphill/framework
 /**
  * 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);
 }