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


PHP GearmanClient::returnCode方法代码示例

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


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

 public function client()
 {
     $config = $this->config->item('base_config');
     $host = $config['gearman']['host'];
     $port = $config['gearman']['port'];
     $client = new GearmanClient();
     $client->addServer($host, $port);
     $data = array('method' => 'get', 'url' => 'http://master.500mi.com/main/gearman/test', 'params' => array('wd' => '哈哈'));
     $job_handle = $client->doBackground("send_request", json_encode($data));
     if ($client->returnCode() != GEARMAN_SUCCESS) {
         echo "bad return code\n";
         exit;
     }
     $done = false;
     do {
         sleep(1);
         $stat = $client->jobStatus($job_handle);
         var_dump($stat);
         if (!$stat[0]) {
             $done = true;
         }
         echo "Running: " . ($stat[1] ? "true" : "false") . ", numerator: " . $stat[2] . ", denomintor: " . $stat[3] . "\n";
     } while (!$done);
     echo "done!\n";
 }
开发者ID:sdgdsffdsfff,项目名称:hiveAdmin,代码行数:25,代码来源:gearman.php

示例3: addJob

 public static function addJob($id, $function, $data)
 {
     $client = new \GearmanClient();
     $client->addServer(gearman_server, gearman_port);
     $job = new Job();
     $job->setId($id)->setExpireTime(time() + 172800)->setReference(array('CLIController', $function, $data));
     $job_handle = $client->doBackground(app_name . 'handle', serialize($job));
     Log::write(__METHOD__ . ' invoked gearman job (' . $function . ') for id ' . $id . ' ' . app_name . 'handle' . ' ' . $client->returnCode());
 }
开发者ID:badtux,项目名称:pmg,代码行数:9,代码来源:job.class.php

示例4: run

 public function run($task)
 {
     $client = new GearmanClient();
     $client->addServers($task["server"]);
     $client->doBackground($task["cmd"], $task["ext"]);
     if (($code = $client->returnCode()) != GEARMAN_SUCCESS) {
         Main::log_write("Gearman:" . $task["cmd"] . " to " . $task["server"] . " error,code=" . $code);
         exit;
     }
     Main::log_write("Gearman:" . $task["cmd"] . " to " . $task["server"] . " success,code=" . $code);
     exit;
 }
开发者ID:royalwang,项目名称:swoole-crontab,代码行数:12,代码来源:Gearman.class.php

示例5: 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

示例6: GearmanClient

 * All rights reserved.
 *
 * Use and distribution licensed under the PHP license.  See
 * the LICENSE file in this directory for full text.
 */
echo "Starting\n";
# Create our client object.
$gmclient = new GearmanClient();
# Add default server (localhost).
$gmclient->addServer();
echo "Sending job\n";
# Send reverse job
do {
    $result = $gmclient->do("reverse", "Hello!");
    # Check for various return packets and errors.
    switch ($gmclient->returnCode()) {
        case GEARMAN_WORK_DATA:
            echo "Data: {$result}\n";
            break;
        case GEARMAN_WORK_STATUS:
            list($numerator, $denominator) = $gmclient->doStatus();
            echo "Status: {$numerator}/{$denominator} complete\n";
            break;
        case GEARMAN_SUCCESS:
            break;
        default:
            echo "RET: " . $gmclient->returnCode() . "\n";
            exit;
    }
} while ($gmclient->returnCode() != GEARMAN_SUCCESS);
echo "Success: {$result}\n";
开发者ID:Sean-Der,项目名称:pecl-gearman,代码行数:31,代码来源:reverse_client.php

示例7: GearmanClient

<?php

$client = new GearmanClient();
$client->addServer();
$job_handle = $client->doBackground("setup", 1);
var_dump($job_handle);
if ($client->returnCode() != GEARMAN_SUCCESS) {
    echo "bad return code\n";
    exit;
}
$done = false;
do {
    sleep(3);
    $stat = $client->jobStatus($job_handle);
    if (!$stat[0]) {
        // the job is known so it is not done
        $done = true;
    }
    echo "Running: " . ($stat[1] ? "true" : "false") . ", numerator: " . $stat[2] . ", denomintor: " . $stat[3] . "\n";
} while (!$done);
echo "done!\n";
开发者ID:knatorski,项目名称:SMS,代码行数:21,代码来源:client.php

示例8: returnCode

 /**
  * Get the last Gearman return code
  *
  * @return int
  * @link http://docs.php.net/manual/en/gearmanclient.returncode.php
  */
 public function returnCode()
 {
     return $this->gearmanClient->returnCode();
 }
开发者ID:cimus,项目名称:gearman-bundle,代码行数:10,代码来源:GearmanClient.php

示例9: do_background_job

function do_background_job($action, $data)
{
    // 保存数据到gearman,异步执行
    $gm = new GearmanClient();
    foreach (explode(";", $GLOBALS['AX_GEARMAN_SERVER']) as $server) {
        list($host, $port) = explode(":", $server);
        $gm->addServer($host, $port);
    }
    @$gm->doBackground($action, $data);
    if ($gm->returnCode() == GEARMAN_SUCCESS) {
        return true;
    }
    return false;
}
开发者ID:songliang89,项目名称:auto-xhprof,代码行数:14,代码来源:auto-xhprof.php

示例10: sendParams

 public function sendParams($newPass)
 {
     try {
         $gmclient = new GearmanClient();
         $gmclient->addServer(GEARMAN_SERVER, GEARMAN_PORT);
         $payload = serialize(array('contextid' => $this->inputs['cid'], 'userid' => $this->inputs['userid'], 'newpassword' => $newPass));
         $gmclient->doNormal(CHANGE_PASSWORD_FUNCTION, $payload);
         if ($gmclient->returnCode() == GEARMAN_SUCCESS) {
             $this->logMessage = sprintf("[INFO] Change password for uid: %s within context: %s succeeded.", $this->inputs['username'], $this->inputs['cid']);
             $this->logToFile($this->logMessage);
             exit(0);
         } else {
             if ($gmclient->returnCode() == GEARMAN_COULD_NOT_CONNECT) {
                 $this->logMessage = sprintf("[ERROR] Could not connect to Gearman Server with IP : %s:%s", GEARMAN_SERVER, GEARMAN_PORT);
                 $this->logToFile($this->logMessage);
                 exit(1);
             } else {
                 $this->logMessage = sprintf("[ERROR] Gearman Server error, error code: %s", $gmclient->returnCode());
                 $this->logToFile($this->logMessage);
                 exit(1);
             }
         }
     } catch (GearmanException $e) {
         print_r($e->getMessage() . PHP_EOL);
         exit(1);
     }
 }
开发者ID:fica990,项目名称:jsonapi,代码行数:27,代码来源:changepwd.php

示例11: 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

示例12: GearmanClient

<?php

/*
 * 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();
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) {
    $job_handle[] = $gmc->doBackground("shrink_image", serialize($img));
    if ($gmc->returnCode() != GEARMAN_SUCCESS) {
        echo "ERROR RET: " . $gmc->error() . "\n";
        exit;
    }
}
echo "DONE\n";
开发者ID:Sean-Der,项目名称:pecl-gearman,代码行数:31,代码来源:image_thumbnail_client_bg.php


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