本文整理汇总了PHP中GearmanClient::error方法的典型用法代码示例。如果您正苦于以下问题:PHP GearmanClient::error方法的具体用法?PHP GearmanClient::error怎么用?PHP GearmanClient::error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GearmanClient
的用法示例。
在下文中一共展示了GearmanClient::error方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: put
public function put($queueName, $workload)
{
if (null === $this->client) {
$this->client = new \GearmanClient();
foreach ($this->servers as $server) {
$this->client->addServer($server);
}
}
$workload = serialize($workload);
$this->client->doBackground($queueName, $workload);
if ($this->client->returnCode() != GEARMAN_SUCCESS) {
throw new \RuntimeException($this->client->error());
}
}
示例2: check
public function check()
{
if (class_exists('\\GearmanClient')) {
$client = new \GearmanClient();
$client->setTimeout($this->timeout);
$client->addServer($this->host, $this->port);
$mtime = microtime(true);
$result = $client->doNormal($this->functionName, json_encode(array('monitor' => 'uptize')));
if ($client->returnCode() == \GEARMAN_SUCCESS) {
$mtime = microtime(true) - $mtime;
return new Result(true, array('time' => $mtime));
}
return new Result(false, array(), $client->error());
}
return new Result(false, array(), 'Class GearmanClient not found');
}
示例3: thumb_created
$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";
exit;
}
}
if (!$gmc->runTasks()) {
echo "ERROR RET:" . $gmc->error() . "\n";
exit;
}
echo "DONE\n";
exit;
function thumb_created($task)
{
echo "CREATED -> job: " . $task->jobHandle() . "\n";
}
function thumb_complete($task)
{
示例4: reverse_status
<?php
# The client script
# create our gearman client
$gmc = new GearmanClient();
# add the default job server
$gmc->addServer();
# set a couple of callbacks so we can track progress
$gmc->setCompleteCallback("reverse_complete");
$gmc->setStatusCallback("reverse_status");
# add a task for the "reverse" function
$task = $gmc->addTask("reverse", "Hello World!", null, "1");
# add another task, but this one to run in the background
$task = $gmc->addTaskBackground("reverse", "!dlroW olleH", null, "2");
if (!$gmc->runTasks()) {
echo "ERROR " . $gmc->error() . "\n";
exit;
}
echo "DONE\n";
function reverse_status($task)
{
echo "STATUS: " . $task->unique() . ", " . $task->jobHandle() . " - " . $task->taskNumerator() . "/" . $task->taskDenominator() . "\n";
}
function reverse_complete($task)
{
echo "COMPLETE: " . $task->unique() . ", " . $task->data() . "\n";
}
?>
示例5: count
$tt1 = microtime(true);
$ctg = new data(array('server' => '10.102.1.3', 'user' => 'sa', 'pass' => 'i3kygbb2', 'database' => 'sifinca', 'engine' => 'mssql'));
$inmueble = new inmuebles($ctg);
echo " Cargando inmuebles ->";
$inmuebles = $inmueble->getInmuebles(array('promocion' => 0));
echo count($inmuebles) . "\n";
$client = new GearmanClient();
//por defecto el localhost
$client->addServer();
$client->setCompleteCallback("complete");
$map = array("total" => 0, "data" => null);
$json = json_encode($map);
// crear task
$i = 0;
foreach ($inmuebles as $row) {
$i++;
$json = json_encode(array("id" => 'C' . $row['id_inmueble']));
$job_handle = $client->addTask("delete", $json, null, $i);
echo "Enviando Tasks -> {$i} \n";
}
if (!$client->runTasks()) {
echo "ERROR " . $client->error() . "\n";
exit;
}
$tt2 = microtime(true);
$r = $tt2 - $tt1;
echo "\n\nTiempo de " . $r . " para {$i} registros\n";
function complete($task)
{
print "COMPLETE: " . $task->unique() . "\n";
}
示例6: GearmanClient
*
* 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();
$data['src'] = $_SERVER['argv'][1];
$data['dest'] = "small_" . $_SERVER['argv'][1];
$data['x'] = 200;
$data['y'] = NULL;
/* run reverse client */
do {
$value = $gmc->do("shrink_image", serialize($data));
switch ($gmc->returnCode()) {
case GEARMAN_WORK_DATA:
echo "DATA: {$value}\n";
break;
case GEARMAN_SUCCESS:
echo "SUCCESS: {$value}\n";
break;
case GEARMAN_WORK_STATUS:
list($numerator, $denominator) = $gmc->doStatus();
echo "Status: {$numerator}/{$denominator}\n";
break;
default:
echo "ERR: " . $gmc->error() . "\n";
}
} while ($gmc->returnCode() != GEARMAN_SUCCESS);
echo "DONE: {$value}\n";
示例7: error
<?php
if (empty($_REQUEST['city'])) {
error('city is a required parameter');
exit;
}
$gearman = new \GearmanClient();
$gearman->addServer("gearmand", "4730");
$gearman->setTimeout(1 * 500000);
$temp = $gearman->doNormal('getTemp', json_encode(array('city' => $_REQUEST['city'])));
if (!$temp) {
error($gearman->error());
} else {
jsonify(array('temp' => $temp));
}
function error($message)
{
jsonify(array('error' => $message), 500);
}
function jsonify($params, $status = 200)
{
header(' ', true, $status);
header('Content-Type: application/json');
print json_encode($params);
}
示例8: _task_exception
/**
* Handles exceptions thrown by Kohana and Gearman client, setting the
* errors array as appropriate
*
* @param GearmanTask $task
* @param Exception $exception
* @return void
* @author Sam de Freyssinet
*/
protected function _task_exception(GearmanTask $task, Exception $exception = NULL)
{
$uuid = $task->unique();
$error = $exception === NULL;
$this->errors[$uuid] = array('type' => $error ? 'error' : 'exception', 'errorNo' => $error ? $this->_gearman_client->getErrno() : $exception->getCode(), 'error' => $error ? $this->_gearman_client->error() : $exception);
}