本文整理汇总了PHP中GearmanClient::setCreatedCallback方法的典型用法代码示例。如果您正苦于以下问题:PHP GearmanClient::setCreatedCallback方法的具体用法?PHP GearmanClient::setCreatedCallback怎么用?PHP GearmanClient::setCreatedCallback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GearmanClient
的用法示例。
在下文中一共展示了GearmanClient::setCreatedCallback方法的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: GearmanClient
/*
* Gearman PHP Extension
*
* Copyright (C) 2008 James M. Luedke (jluedke@jamesluedke.com)
* Eric Day (eday@oddments.org)
* All rights reserved.
*
* Use and distribution licensed under the PHP license. See
* the LICENSE file in this directory for full text.
*/
/* create our object */
$gmc = new GearmanClient();
/* add the default server */
$gmc->addServer();
/* set a few callbacks */
$gmc->setCreatedCallback("thumb_created");
$gmc->setCompleteCallback("thumb_complete");
$gmc->setFailCallback("thumb_fail");
for ($x = 0; $x < 20; $x++) {
$data[$x]['src'] = $_SERVER['argv'][1];
$data[$x]['dest'] = "{$x}.jpg";
$data[$x]['x'] = (80 + 1) * ($x + 1);
$data[$x]['y'] = NULL;
}
/* fire off each job */
foreach ($data as $img) {
/* NOTE: if you want to asynchronously queue jobs use
** $task= $gmc->add_task_background("shrink_image", serialize($img));
** however keep in mind that your complete callback will not get called */
if (!$gmc->addTask("shrink_image", serialize($img))) {
echo "ERROR RET: " . $gmc->error() . "\n";
示例3: reverse_created
<?php
$gmc = new GearmanClient();
$gmc->addServer();
$gmc->setCreatedCallback("reverse_created");
$gmc->setStatusCallback("reverse_status");
$gmc->setCompleteCallback("reverse_complete");
$gmc->setFailCallback("reverse_fail");
$task = $gmc->addTask("reverse", "this is a test", NULL);
if (!$gmc->runTasks()) {
echo "ERROR " . $gmc->error() . "\n";
exit;
}
echo "DONE\n";
function reverse_created($task)
{
echo "CREATED: " . $task->jobHandle() . "\n";
}
function reverse_status($task)
{
echo "STATUS: " . $task->jobHandle() . " - " . $task->taskNumerator() . "/" . $task->taskDenominator() . "\n";
}
function reverse_complete($task)
{
echo "COMPLETE: " . $task->jobHandle() . "\n";
}
function reverse_fail($task)
{
echo "FAILED: " . $task->jobHandle() . "\n";
}