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


PHP GearmanClient::error方法代码示例

本文整理汇总了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());
     }
 }
开发者ID:rcambien,项目名称:riverline-worker-bundle,代码行数:14,代码来源:Gearman.php

示例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');
 }
开发者ID:flavioheleno,项目名称:uptize-php,代码行数:16,代码来源:GearmanWorker.php

示例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)
{
开发者ID:Sean-Der,项目名称:pecl-gearman,代码行数:31,代码来源:image_thumbnail_client_task.php

示例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";
}
?>
 
开发者ID:huberyhe,项目名称:scripts,代码行数:28,代码来源:GearmanClient.php

示例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";
}
开发者ID:eescallon,项目名称:upload,代码行数:31,代码来源:testwWeb.php

示例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";
开发者ID:Sean-Der,项目名称:pecl-gearman,代码行数:31,代码来源:image_thumbnail_client.php

示例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);
}
开发者ID:ecliptik,项目名称:formstack,代码行数:25,代码来源:temp.php

示例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);
 }
开发者ID:samsoir,项目名称:vitesse,代码行数:15,代码来源:gearman.php


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