• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Jobs\Job类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Illuminate\Queue\Jobs\Job的典型用法代码示例。如果您正苦于以下问题:PHP Job类的具体用法?PHP Job怎么用?PHP Job使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Job类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: fire

 public function fire(Job $job, array $data)
 {
     $command = PostToCallback::create($data['image_id']);
     $command->execute();
     // End job
     $job->delete();
 }
开发者ID:aaronbullard,项目名称:litmus,代码行数:7,代码来源:PostToCallbackWorker.php


示例2: fire

 public function fire(\Illuminate\Queue\Jobs\Job $job, array $data)
 {
     if (!$this->index_product_repo->updateIndex($data['fields'], false)) {
         throw new \RunTimeException('Index operation failed: ' . $this->index_product_repo->errors());
     }
     $job->delete();
 }
开发者ID:ryanrobertsname,项目名称:giftertipster.com,代码行数:7,代码来源:UpdateIndexProduct.php


示例3: fire

 public function fire(Job $job, $data)
 {
     // Stop if over three attempts
     if ($job->attempts() > 3) {
         Log::info("Job Delete: " . serialize($job));
         $job->delete();
     }
     // Begin
     try {
         $image = Image::find($data['image_id']);
         $corners = $image->getBoundingBox();
         $rgba = Litmus::getAverageColor($image->url, $corners[0], $corners[1], $corners[2], $corners[3]);
         //Update Image
         $image->red = $rgba->red;
         $image->green = $rgba->green;
         $image->blue = $rgba->blue;
         $image->alpha = $rgba->alpha;
         $image->status = "done";
         $image->save();
         Event::fire('image.done', [$image]);
     } catch (\Exception $e) {
         Log::error($e->getMessage());
         $job->release();
     }
     // Success, delete job...
     $job->delete();
 }
开发者ID:aaronbullard,项目名称:litmus,代码行数:27,代码来源:ProcessImage.php


示例4: fire

 /**
  * Sends an email
  *
  * @param \Illuminate\Queue\Jobs\Job $sqsJob
  * @param array $data
  *
  * @return void
  */
 public function fire($sqsJob, $params)
 {
     // Get the needed parameters
     $domain = $params[0];
     $view = $params[1];
     $data = $params[2];
     $messageData = $params[3];
     $driver = isset($params[4]) ? $params[4] : null;
     // If using a specific driver, set it now
     if (!is_null($driver)) {
         Config::set('mail.driver', $driver);
     }
     // If not using the mailgun driver, send normally ignoring the domain
     if (Config::get('mail.driver') !== 'mailgun') {
         $this->send($view, $data, $messageData);
         // Otherwise, adjust the mailgun domain dynamically
     } else {
         // Backup your default mailer
         $backup = Mail::getSwiftMailer();
         // Setup your mailgun transport
         $transport = new MailgunTransport(Config::get('services.mailgun.secret'), $domain);
         $mailer = new Swift_Mailer($transport);
         // Set the new mailer with the domain
         Mail::setSwiftMailer($mailer);
         // Send your message
         $this->send($view, $data, $messageData);
         // Restore the default mailer instance
         Mail::setSwiftMailer($backup);
     }
     $sqsJob->delete();
 }
开发者ID:elite50,项目名称:e50-mail-laravel,代码行数:39,代码来源:E50MailWorker.php


示例5: fire

 public function fire(Job $job, $data)
 {
     $doSuccess = false;
     // push to url
     if ($data['url']) {
         $curl = new Curl();
         $curl->post($data['url'], $data['data']);
         $doSuccess = $curl->ok();
         if (!$doSuccess) {
             Log::warning('callback.push.url', array('message' => 'callback push failed to ' . $data['url'], 'order' => $data['data']['order']));
         }
     }
     // push to email
     if ($data['email']) {
         Mail::send(array('text' => 'ff-bank-em::demo.email_callback'), $data, function (Message $message) use($data) {
             $message->to($data['email'])->subject('Bank Emulator Payment Message');
         });
         $doSuccess = 0 == count(Mail::failures());
         if (!$doSuccess) {
             Log::warning('callback.push.email', array('message' => 'callback push failed', 'order' => $data['data']['order']));
         }
     }
     // release, if error
     if ($doSuccess) {
         Log::info('callback.push', array('order' => $data['data']['order']));
         $job->delete();
     } else {
         Log::warning('callback.push', array('order' => $data['data']['order']));
         if ($job->attempts() > 10) {
             $job->delete();
         } else {
             $job->release(60);
         }
     }
 }
开发者ID:fintech-fab,项目名称:bank-emulator,代码行数:35,代码来源:CallbackQueue.php


示例6: fire

 /**
  * @param Job $syncJob Laravel queue job
  * @param $arguments
  * @return bool
  * @throws \Unifact\Connector\Exceptions\HandlerException
  */
 public function fire(Job $syncJob, $arguments)
 {
     try {
         $job = $this->jobRepo->findById($arguments['job_id']);
         $job->setPreviousStatus($arguments['previous_status']);
         $handler = forward_static_call([$job->handler, 'make']);
         $this->logger->debug("Preparing Job..");
         if (!$handler->prepare()) {
             $this->logger->error('Handler returned FALSE in prepare() method, see log for details');
             // delete Laravel queue job
             $syncJob->delete();
             return false;
         }
         $this->logger->debug("Handling Job..");
         if ($handler->handle($job) === false) {
             $this->logger->error('Handler returned FALSE in handle() method, see log for details');
             // delete Laravel queue job
             $syncJob->delete();
             return false;
         }
         $this->logger->debug("Completing Job..");
         $handler->complete();
         $this->logger->info('Finished Job successfully');
     } catch (\Exception $e) {
         $this->oracle->exception($e);
         $this->logger->error('Exception was thrown in JobQueueHandler::fire method.');
         $this->jobRepo->update($arguments['job_id'], ['status' => 'error']);
         // delete Laravel queue job
         $syncJob->delete();
         return false;
     }
     // delete Laravel queue job
     $syncJob->delete();
     return true;
 }
开发者ID:unifact,项目名称:connector,代码行数:41,代码来源:JobQueueHandler.php


示例7: fire

 /**
  * @param Job   $job
  * @param array $data
  */
 public function fire(Job $job, $data)
 {
     Log::info('Получен запрос через очередь с параметрами:', $data);
     Validators::ValidateRequest($data);
     $mainHandler = new MainHandler();
     $mainHandler->processRequest($data);
     $job->delete();
 }
开发者ID:fintech-fab,项目名称:actions-calc,代码行数:12,代码来源:QueueHandler.php


示例8: fire

 public function fire(Job $job, array $data)
 {
     if ($this->filesystem->exists($data['filepath'])) {
         $this->filesystem->delete($data['filepath']);
     }
     // End job
     $job->delete();
 }
开发者ID:aaronbullard,项目名称:litmus,代码行数:8,代码来源:DeleteImageFileWorker.php


示例9: fire

 public function fire(Job $job, array $data)
 {
     // Process Image
     $command = ImageColorAnalysis::create($data['image_id']);
     $command->execute();
     // End job
     $job->delete();
 }
开发者ID:aaronbullard,项目名称:litmus,代码行数:8,代码来源:ImageColorAnalysisWorker.php


示例10: fire

 /**
  * Called by the illuminate queue.
  *
  * @param \Illuminate\Queue\Jobs\Job $job
  * @param array                      $data Data that has been added by the Laravel handler.
  *
  * @return void
  */
 public function fire(IlluminateJob $job, array $data)
 {
     if (empty($this->transport)) {
         $this->transport = new $data['transport']['class']($data['transport']['options']);
     }
     $this->transport->send($data['url'], $data['data'], $data['headers']);
     $job->delete();
 }
开发者ID:RamaneekGill,项目名称:Raven,代码行数:16,代码来源:Job.php


示例11: processBorrowerImportJob

 public function processBorrowerImportJob(Job $job, $data)
 {
     $id = $data['id'];
     $borrowerPayment = $this->paymentQuery->create()->findOneById($id);
     if ($borrowerPayment) {
         $this->processBorrowerPayment($borrowerPayment);
     }
     $job->delete();
 }
开发者ID:Junyue,项目名称:zidisha2,代码行数:9,代码来源:RepaymentService.php


示例12: fire

 public function fire(IlluminateJob $job, $data)
 {
     $client = new Client($data['client']);
     $transport = new $data['transport']['class']();
     foreach ($client->servers as $url) {
         $transport->send($url, $data['message'], Client::getHeaders($client));
     }
     $job->delete();
 }
开发者ID:tonijz,项目名称:raven,代码行数:9,代码来源:Job.php


示例13: fire

 public function fire(Job $job, $models)
 {
     foreach ($models as $model) {
         list($class, $id) = explode(':', $model);
         $model = new $class();
         $model->deleteDoc($id);
     }
     $job->delete();
 }
开发者ID:geekybeaver,项目名称:larasearch,代码行数:9,代码来源:DeleteJob.php


示例14: fire

 /**
  * Handle the queue job.
  *
  * @param LaravelJob $laravelJob
  * @param mixed $data
  */
 public function fire(LaravelJob $laravelJob, $data)
 {
     $job = null;
     try {
         $job = $this->jobs->find($data['job_id']);
         // Check if the job is valid (not expired and ready). This might
         // happen on some timing edge cases.
         if (!$job->ready()) {
             $laravelJob->delete();
             return;
         }
         // Look for a task handler
         $handler = $this->resolver->resolve($job);
         if ($handler->getSpec() instanceof Spec) {
             $result = $handler->getSpec()->check($job->getData());
             if ($result->failed()) {
                 $laravelJob->delete();
                 $this->jobs->giveUp($job, 'Task data does not pass Spec.');
                 return;
             }
         }
         // Execute the handler
         $this->jobs->started($job, "Task handler started.\n");
         $handler->fire($job, $this->scheduler);
         if ($handler->isSelfDeleting()) {
             $this->jobs->delete($job->id);
         } else {
             $this->jobs->complete($job);
         }
     } catch (ModelNotFoundException $e) {
         // Here we just cancel the queue job since there is no point in
         // retrying.
         $laravelJob->delete();
     } catch (UnresolvableException $e) {
         // Here we just cancel the queue job since there is no point in
         // retrying.
         $laravelJob->delete();
         $this->jobs->giveUp($job, 'Task handler was not found');
     } catch (Exception $e) {
         // If we were not able to find the job, just give up.
         if (is_null($job)) {
             $laravelJob->delete();
             return;
         }
         if ($job->hasAttemptsLeft()) {
             $this->jobs->release($job);
             $laravelJob->release();
             return;
         }
         $this->jobs->fail($job, 'Exception: ' . $e->getMessage());
         $laravelJob->delete();
     }
 }
开发者ID:chromabits,项目名称:illuminated,代码行数:59,代码来源:RunTaskCommand.php


示例15: fire

 public function fire(\Illuminate\Queue\Jobs\Job $job, array $data)
 {
     if (empty($data['product_id']) || empty($data['add_type_id']) || empty($data['add_profile']) || !is_array($data['add_profile'])) {
         throw new \InvalidArgumentException('Job data missing product_id or add_profile');
     }
     $add_attributes = $data['add_profile'];
     $add_attributes['product_id'] = $data['product_id'];
     $add_attributes['add_type_id'] = $data['add_type_id'];
     if (!$this->add_repo->create($add_attributes)) {
         throw new \RunTimeException('Error saving Add to database: ' . $this->add_repo->errors());
     }
     $job->delete();
 }
开发者ID:ryanrobertsname,项目名称:giftertipster.com,代码行数:13,代码来源:RecordAdd.php


示例16: fire

 public function fire(Job $job, $models)
 {
     try {
         foreach ($models as $model) {
             list($class, $id) = explode(':', $model);
             $model = $class::findOrFail($id);
             $model->refreshDoc($model);
         }
         $job->delete();
     } catch (ModelNotFoundException $e) {
         $job->release(60);
     }
 }
开发者ID:geekybeaver,项目名称:larasearch,代码行数:13,代码来源:ReindexJob.php


示例17: fire

 /**
  * @param Job $job
  * @param mixed $models
  */
 public function fire(Job $job, $models)
 {
     $loggerContainerBinding = $this->config->get('logger', 'menthol.flexible.logger');
     $logger = $this->app->make($loggerContainerBinding);
     foreach ($models as $model) {
         list($class, $id) = explode(':', $model);
         $logger->info('Deleting ' . $class . ' with ID: ' . $id . ' from Elasticsearch');
         $model = new $class();
         if (method_exists($model, 'getProxy')) {
             $model->deleteDoc($id);
         }
     }
     $job->delete();
 }
开发者ID:menthol,项目名称:Flexible,代码行数:18,代码来源:DeleteJob.php


示例18: fire

 /**
  * @param Job   $job
  * @param array $data
  *
  * @throws Exception
  */
 public function fire($job, $data)
 {
     $this->job = $job;
     if ($data['test1'] != 1 || $data['test2'] != 2) {
         throw new Exception("Parameters passed incorrectly" . var_export($data, true));
     }
     if (isset($data['delete'])) {
         $this->job->delete();
         return;
     }
     if (isset($data['release'])) {
         $this->job->release();
         return;
     }
 }
开发者ID:fhteam,项目名称:laravel-amqp,代码行数:21,代码来源:TestJobHandler.php


示例19: release

 /**
  * Release the job back into the queue.
  *
  * @param  int   $delay
  * @return void
  */
 public function release($delay = 0)
 {
     parent::release($delay);
     if (!$this->pushed) {
         $this->delete();
     }
     $this->recreateJob($delay);
 }
开发者ID:EnmanuelCode,项目名称:backend-laravel,代码行数:14,代码来源:IronJob.php


示例20: process

 /**
  * Process a given job from the queue.
  *
  * @param  \Illuminate\Queue\Jobs\Job  $job
  * @param  int  $delay
  * @return void
  */
 public function process(Job $job, $delay)
 {
     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();
         if ($job->autoDelete()) {
             $job->delete();
         }
     } 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.
         $job->release($delay);
         throw $e;
     }
 }
开发者ID:centaurustech,项目名称:sagip,代码行数:25,代码来源:Worker.php



注:本文中的Illuminate\Queue\Jobs\Job类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Redis\Database类代码示例发布时间:2022-05-23
下一篇:
PHP Queue\SyncQueue类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap