本文整理汇总了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'));
}
示例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();
示例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'));
}