当前位置: 首页>>代码示例>>PHP>>正文


PHP GearmanClient::setExceptionCallback方法代码示例

本文整理汇总了PHP中GearmanClient::setExceptionCallback方法的典型用法代码示例。如果您正苦于以下问题:PHP GearmanClient::setExceptionCallback方法的具体用法?PHP GearmanClient::setExceptionCallback怎么用?PHP GearmanClient::setExceptionCallback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GearmanClient的用法示例。


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

示例1: assignTaskCallbacks

 /**
  * Assign all GearmanClient callbacks as Symfony2 events
  *
  * @param \GearmanClient $gearmanClient Gearman client
  *
  * @return GearmanCallbacksDispatcher self Object
  */
 public function assignTaskCallbacks(\GearmanClient $gearmanClient)
 {
     $gearmanClient->setCompleteCallback(array($this, 'assignCompleteCallback'));
     $gearmanClient->setFailCallback(array($this, 'assignFailCallback'));
     $gearmanClient->setDataCallback(array($this, 'assignDataCallback'));
     $gearmanClient->setCreatedCallback(array($this, 'assignCreatedCallback'));
     $gearmanClient->setExceptionCallback(array($this, 'assignExceptionCallback'));
     $gearmanClient->setStatusCallback(array($this, 'assignStatusCallback'));
     $gearmanClient->setWarningCallback(array($this, 'assignWarningCallback'));
     $gearmanClient->setWorkloadCallback(array($this, 'assignWorkloadCallback'));
 }
开发者ID:eduardtrandafir,项目名称:gearman-bundle,代码行数:18,代码来源:GearmanCallbacksDispatcher.php

示例2: SplFileObject

$input = new SplFileObject($argv[1], 'r');
$output = new SplFileObject($argv[2], 'w');
$checked = 0;
$valid = 0;
$invalid = 0;
$started = microtime(1);
$client = new GearmanClient();
$client->addServer();
$client->setCompleteCallback(function (GearmanTask $task) use(&$output, &$checked, $started, &$valid, &$invalid) {
    $data = json_decode($task->data(), true);
    if ($data['status']) {
        $output->fwrite($data['email'] . PHP_EOL);
        $valid++;
    } else {
        $invalid++;
    }
    $checked++;
    echo "\r" . date(DATE_ATOM) . " Speed: " . $checked / (microtime(1) - $started) . " emails / sec. Valid: {$valid}, Invalid: {$invalid}.                    ";
});
$client->setExceptionCallback(function (GearmanTask $task) {
    echo "Exception!\n";
});
while (!$input->eof()) {
    //    for ($i = 0; $i < 2048; $i++) {
    $client->doBackground('check_email', trim($input->fgets()));
    //    }
    //    break;
}
//$client->runTasks();
//
//$client->wait();
开发者ID:Skpd,项目名称:email_tester,代码行数:31,代码来源:client.php

示例3: __construct

 /**
  * Constructor method checks for gearman
  * 
  * @throws  Kohana_Request_Exception
  */
 public function __construct()
 {
     if (!extension_loaded('gearman')) {
         throw new Kohana_Request_Exception('Unable to load PHP Gearman. Check your local environment.');
     }
     // Create a new Gearman client and add a server
     $this->_gearman_client = new GearmanClient();
     /**
      * @todo    support multiple Gearman servers
      * @todo    support customisable servers
      */
     if (!$this->_gearman_client->addServer()) {
         throw new Kohana_Request_Exception('Unable to attach to Gearman server');
     }
     // Setup callback functions for Gearman tasks
     $this->_gearman_client->setDataCallback(array($this, '_task_data'));
     $this->_gearman_client->setFailCallback(array($this, '_task_failed'));
     $this->_gearman_client->setCompleteCallback(array($this, '_task_complete'));
     $this->_gearman_client->setExceptionCallback(array($this, '_task_exception'));
 }
开发者ID:samsoir,项目名称:vitesse,代码行数:25,代码来源:gearman.php


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