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


PHP Resque_Event::trigger方法代碼示例

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


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

示例1: enqueueAt

 /**
  * Enqueue a job for execution at a given timestamp.
  *
  * Identical to Resque::enqueue, however the first argument is a timestamp
  * (either UNIX timestamp in integer format or an instance of the DateTime
  * class in PHP).
  *
  * @param DateTime|int $at Instance of PHP DateTime object or int of UNIX timestamp.
  * @param string $queue The name of the queue to place the job in.
  * @param string $class The name of the class that contains the code to execute the job.
  * @param array $args Any optional arguments that should be passed when the job is executed.
  */
 public static function enqueueAt($at, $queue, $class, $args = array())
 {
     self::validateJob($class, $queue);
     $job = self::jobToHash($queue, $class, $args);
     self::delayedPush($at, $job);
     Resque_Event::trigger('afterRepeatSchedule', array('at' => $at, 'queue' => $queue, 'class' => $class, 'args' => $args));
 }
開發者ID:commonledger,項目名稱:php-resque-repeater,代碼行數:19,代碼來源:ResqueRepeater.php

示例2: fail

 /**
  * Mark the current job as having failed.
  *
  * @param $exception
  */
 public function fail($exception)
 {
     Resque_Event::trigger('onFailure', array('exception' => $exception, 'job' => $this));
     $this->updateStatus(Resque_Job_Status::STATUS_FAILED);
     Resque_Failure::create($this->payload, $exception, $this->worker, $this->queue);
     Resque_Stat::incr('failed');
     Resque_Stat::incr('failed:' . $this->worker);
 }
開發者ID:snikius,項目名稱:php-resque,代碼行數:13,代碼來源:Job.php

示例3: enqueueDelayedItemsForTimestamp

 /**
  * Schedule all of the delayed jobs for a given timestamp.
  *
  * Searches for all items for a given timestamp, pulls them off the list of
  * delayed jobs and pushes them across to Resque.
  *
  * @param DateTime|int $timestamp Search for any items up to this timestamp to schedule.
  */
 public function enqueueDelayedItemsForTimestamp($timestamp)
 {
     $item = null;
     while ($item = ResqueScheduler::nextItemForTimestamp($timestamp)) {
         $this->log(array('message' => 'Moving scheduled job ' . strtoupper($item['class']) . ' to ' . strtoupper($item['queue']), 'data' => array('type' => 'movescheduled', 'args' => array('timestamp' => (int) $timestamp, 'class' => $item['class'], 'queue' => $item['queue'], 'job_id' => $item['args'][0]['id'], 'wait' => round(microtime(true) - (isset($item['s_time']) ? $item['s_time'] : 0), 3), 's_wait' => $timestamp - floor(isset($item['s_time']) ? $item['s_time'] : 0)))), self::LOG_TYPE_INFO);
         \Resque_Event::trigger('beforeDelayedEnqueue', array('queue' => $item['queue'], 'class' => $item['class'], 'args' => $item['args']));
         $payload = array_merge(array($item['queue'], $item['class']), $item['args'], array($item['track']));
         call_user_func_array('\\Resque::enqueue', $payload);
     }
 }
開發者ID:kamisama,項目名稱:php-resque-ex-scheduler,代碼行數:18,代碼來源:Worker.php

示例4: enqueueDelayedItemsForTimestamp

 /**
  * Schedule all of the delayed jobs for a given timestamp.
  *
  * Searches for all items for a given timestamp, pulls them off the list of
  * delayed jobs and pushes them across to Resque.
  *
  * @param DateTime|int $timestamp Search for any items up to this timestamp to schedule.
  */
 public function enqueueDelayedItemsForTimestamp($timestamp)
 {
     $item = null;
     while ($item = ResqueRepeater::nextItemForTimestamp($timestamp)) {
         $this->log('queueing ' . $item['class'] . ' in ' . $item['queue'] . ' [delayed]');
         Resque_Event::trigger('beforeDelayedEnqueue', array('queue' => $item['queue'], 'class' => $item['class'], 'args' => $item['args']));
         $payload = array_merge(array($item['queue'], $item['class']), $item['args']);
         call_user_func_array('Resque::enqueue', $payload);
     }
 }
開發者ID:commonledger,項目名稱:php-resque-repeater,代碼行數:18,代碼來源:Worker.php

示例5: perform

 public function perform()
 {
     try {
         $closure = $this->getClosure();
         Resque_Event::trigger('beforePerform', $this);
         Resque_Job_Closure::invokeSerializableClosure($closure, $this, $this->getArguments());
         Resque_Event::trigger('afterPerform', $this);
     } catch (Resque_Job_DontPerform $e) {
         return false;
     }
     return true;
 }
開發者ID:snikius,項目名稱:php-resque,代碼行數:12,代碼來源:Closure.php

示例6: enqueueAt

 /**
  * Enqueue a job for execution at a given timestamp.
  *
  * Identical to Resque::enqueue, however the first argument is a timestamp
  * (either UNIX timestamp in integer format or an instance of the DateTime
  * class in PHP).
  *
  * @param   DateTime|int $at            Instance of PHP DateTime object or int of UNIX timestamp.
  * @param   string       $queue         The name of the queue to place the job in.
  * @param   string       $class         The name of the class that contains the code to execute the job.
  * @param   array        $args          Any optional arguments that should be passed when the job is executed.
  * @param   boolean      $trackStatus   Set to true to be able to monitor the status of a job.
  * @return  string                      Job ID
  */
 public static function enqueueAt($at, $queue, $class, $args = array(), $trackStatus = false)
 {
     self::validateJob($class, $queue);
     $args['id'] = md5(uniqid('', true));
     $args['s_time'] = time();
     $job = self::jobToHash($queue, $class, $args, $trackStatus);
     self::delayedPush($at, $job);
     if ($trackStatus) {
         \Resque_Job_Status::create($args['id'], Job\Status::STATUS_SCHEDULED);
     }
     \Resque_Event::trigger('afterSchedule', array('at' => $at, 'queue' => $queue, 'class' => $class, 'args' => $args));
     return $args['id'];
 }
開發者ID:kamisama,項目名稱:php-resque-ex-scheduler,代碼行數:27,代碼來源:ResqueScheduler.php

示例7: perform

 public function perform()
 {
     try {
         Resque_Event::trigger('beforePerform', $this);
         $instance = $this->getInstance();
         if (method_exists($instance, 'setUp')) {
             $instance->setUp();
         }
         $method = $this->method;
         $instance->{$method}($this, $this->getArguments());
         if (method_exists($instance, 'tearDown')) {
             $instance->tearDown();
         }
         Resque_Event::trigger('afterPerform', $this);
     } catch (Resque_Job_DontPerform $e) {
         return false;
     }
     return true;
 }
開發者ID:snikius,項目名稱:php-resque,代碼行數:19,代碼來源:Class.php

示例8: perform

 private function perform($job)
 {
     // $startTime = microtime(true);
     try {
         if (!$job instanceof \Randr\Job) {
             throw new \Exception('Job is not a class');
         }
         \Resque_Event::trigger('afterFork', $job);
         $rc = $job->perform();
         //$this->log(array('message' => 'done ID:' . $job->payload['id'], 'data' => array('type' => 'done', 'job_id' => $job->payload['id'], 'time' => round(microtime(true) - $startTime, 3) * 1000)), self::LOG_TYPE_INFO)
     } catch (Exception $e) {
         /*$this->log([
         			'message' => $job . ' failed: ' . $e->getMessage(),
         			'data' => [
         				'type' => 'fail',
         				'log' => $e->getMessage(),
         				'job_id' => $job->payload['id'],
         				'time' => round(microtime(true) - $startTime, 3) * 1000
         			]],
         			Resque_Worker::LOG_TYPE_ERROR
         		);
         		*/
         if ($job instanceof \Randr\Job) {
             $job->fail($e);
         }
         print "ERROR: " . $e->getMessage() . "\n";
     }
     $this->emit('finish', [$rc]);
     $job->updateStatus(\Resque_Job_Status::STATUS_COMPLETE);
     if ($this->ttl > 0) {
         $this->ttl--;
     }
     if ($this->ttl == 0) {
         print "TIME TO DIE for " . getmypid() . "\n";
         exit(0);
     }
 }
開發者ID:pwhelan,項目名稱:randr,代碼行數:37,代碼來源:Unit.php

示例9: enqueue

 /**
  * Create a new job and save it to the specified queue.
  * 創建一個Job並將它放入到隊列中
  *
  * @param string $queue The name of the queue to place the job in.
  * @param string $class The name of the class that contains the code to execute the job.
  * @param array $args Any optional arguments that should be passed when the job is executed.
  * @param boolean $trackStatus Set to true to be able to monitor the status of a job.
  *
  * @return string
  */
 public static function enqueue($queue, $class, $args = null, $trackStatus = false)
 {
     require_once dirname(__FILE__) . '/Resque/Job.php';
     // 創建job
     $result = Resque_Job::create($queue, $class, $args, $trackStatus);
     if ($result) {
         // 觸發入隊的事件
         Resque_Event::trigger('afterEnqueue', array('class' => $class, 'args' => $args, 'queue' => $queue));
     }
     return $result;
 }
開發者ID:CraryPrimitiveMan,項目名稱:php-resque-1.2-annotated,代碼行數:22,代碼來源:Resque.php

示例10: recreate

 /**
  * Re-queue the current job.
  * @return string
  */
 public function recreate()
 {
     $status = new Resque_Job_Status($this->payload['id']);
     $monitor = false;
     if ($status->isTracking()) {
         $monitor = true;
         $status->update(Resque_Job_Status::STATUS_WAITING);
     }
     $this->worker->logger->log(Psr\Log\LogLevel::NOTICE, 'Requeing {job}', array('job' => $this));
     Resque::redis()->lrem('working:' . $this->queue, 0, $this->payload['id']);
     Resque_Event::trigger('onRecreate', array('job' => $this));
     return self::create($this->queue, $this->payload['class'], $this->getArguments(), $monitor, $this->payload['id']);
 }
開發者ID:daneren2005,項目名稱:php-resque,代碼行數:17,代碼來源:Job.php

示例11: fail

 /**
  * Mark the current job as having failed.
  *
  * @param $exception
  */
 public function fail($exception)
 {
     Resque_Event::trigger('onFailure', array('exception' => $exception, 'job' => $this));
     // job的狀態更新成failed
     $this->updateStatus(Resque_Job_Status::STATUS_FAILED);
     require_once dirname(__FILE__) . '/Failure.php';
     // 記錄信息到failed隊列中
     Resque_Failure::create($this->payload, $exception, $this->worker, $this->queue);
     // 失敗狀態的個數+1
     Resque_Stat::incr('failed');
     Resque_Stat::incr('failed:' . $this->worker);
 }
開發者ID:CraryPrimitiveMan,項目名稱:php-resque-1.2-annotated,代碼行數:17,代碼來源:Job.php

示例12: enqueue

 /**
  * Create a new job and save it to the specified queue.
  *
  * @param string $queue The name of the queue to place the job in.
  * @param string $class The name of the class that contains the code to execute the job.
  * @param array $args Any optional arguments that should be passed when the job is executed.
  * @param boolean $trackStatus Set to true to be able to monitor the status of a job.
  *
  * @return string
  */
 public static function enqueue($queue, $class, $args = null, $trackStatus = false)
 {
     $result = Resque_Job::create($queue, $class, $args, $trackStatus);
     if ($result) {
         Resque_Event::trigger('afterEnqueue', array('class' => $class, 'args' => $args, 'queue' => $queue));
     }
     return $result;
 }
開發者ID:rolies106,項目名稱:yii2resque,代碼行數:18,代碼來源:Resque.php

示例13: enqueueFromConfig

 protected function enqueueFromConfig($config)
 {
     if (isset($config['cron'])) {
         //ResqueScheduler::removeDelayed($config['args']['queue'], $config['class'], $config['args']);
         $this->logger->log(Psr\Log\LogLevel::NOTICE, 'queueing {class} in {queue} Scheduled {schedule_at}', array('class' => $config['class'], 'queue' => $config['args']['queue'], 'schedule_at' => $config['schedule_at']));
         ResqueScheduler::enqueueAt($config['schedule_at'], $config['args']['queue'], $config['class'], $config['args']);
     } else {
         $this->logger->log(Psr\Log\LogLevel::INFO, 'queueing {class} in {queue} [delayed]', array('class' => $config['class'], 'queue' => $config['queue']));
         Resque_Event::trigger('beforeDelayedEnqueue', array('queue' => $config['queue'], 'class' => $config['class'], 'args' => $config['args']));
         $payload = array_merge(array($config['queue'], $config['class']), $config['args']);
         call_user_func_array('Resque::enqueue', $payload);
     }
 }
開發者ID:neilmillard,項目名稱:php-resque-scheduler,代碼行數:13,代碼來源:Worker.php

示例14: startup

 /**
  * Perform necessary actions to start a worker.
  */
 private function startup()
 {
     $this->registerSigHandlers();
     $this->pruneDeadWorkers();
     Resque_Event::trigger('beforeFirstFork', $this);
     $this->registerWorker();
 }
開發者ID:realestateconz,項目名稱:php-resque,代碼行數:10,代碼來源:Worker.php

示例15: enqueue

 /**
  * Create a new job and save it to the specified queue.
  *
  * @param string $queue The name of the queue to place the job in.
  * @param string $class The name of the class that contains the code to execute the job.
  * @param array $args Any optional arguments that should be passed when the job is executed.
  * @param boolean $trackStatus Set to true to be able to monitor the status of a job.
  *
  * @return string|boolean Job ID when the job was created, false if creation was cancelled due to beforeEnqueue
  */
 public static function enqueue($queue, $class, $args = null, $trackStatus = false)
 {
     $id = Resque::generateJobId();
     $hookParams = array('class' => $class, 'args' => $args, 'queue' => $queue, 'id' => $id);
     try {
         Resque_Event::trigger('beforeEnqueue', $hookParams);
     } catch (Resque_Job_DontCreate $e) {
         return false;
     }
     Resque_Job::create($queue, $class, $args, $trackStatus, $id);
     Resque_Event::trigger('afterEnqueue', $hookParams);
     return $id;
 }
開發者ID:varvar,項目名稱:php-resque,代碼行數:23,代碼來源:Resque.php


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