• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP GearmanClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了GearmanClient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: CreateNewClient

function CreateNewClient()
{
    $_client = new GearmanClient();
    $_client->addServer("192.168.201.12");
    $_client->setCompleteCallback("jobEcho");
    return $_client;
}
开发者ID:seiran1944,项目名称:slate,代码行数:7,代码来源:client.php


示例2: createJobServer

 /**
  * 
  * @return \Api_Component_JobServer
  */
 static function createJobServer()
 {
     $gearmanHost = new GearmanHost('localhost');
     $gearmanClient = new GearmanClient();
     $gearmanClient->addServer();
     return new Api_Component_JobServer($gearmanHost, $gearmanClient);
 }
开发者ID:otis22,项目名称:reserve-copy-system,代码行数:11,代码来源:Factory.php


示例3: actionStart

 /**
  * Smpp search all
  * @param $startPage Start page number
  */
 public function actionStart($startPage = 1)
 {
     $gmanClient = new \GearmanClient();
     $gmanClient->addServer($this->module->gman_server);
     $httpClient = new \GuzzleHttp\Client(['base_uri' => 'http://www.smpp.go.kr']);
     $res = $httpClient->request('POST', '/cop/registcorp/selectRegistCorpListVw.do', ['form_params' => ['pageIndex' => $startPage, 'pageUnit' => '100']]);
     $body = $res->getBody();
     $html = (string) $body;
     $p = '#<a.*btnMove last.*fn_getList\\((?<lastpage>\\d+)\\);#';
     if (!preg_match($p, $html, $m)) {
         return;
     }
     $lastPage = $m['lastpage'];
     echo "총 페이지수 : {$lastPage}", PHP_EOL;
     for ($i = $startPage; $i <= $lastPage; $i++) {
         if ($i > $startPage) {
             $res = $httpClient->request('POST', '/cop/registcorp/selectRegistCorpListVw.do', ['form_params' => ['pageIndex' => $i, 'pageUnit' => '100']]);
             $body = $res->getBody();
             $html = (string) $body;
         }
         $this->parseList($html, function ($data) use($gmanClient, $i) {
             echo "page({$i}) >> " . join(',', $data), PHP_EOL;
             $gmanClient->doNormal('smpp_corp_get', Json::encode(['bizno' => $data['bizno']]));
         });
         sleep(1);
     }
 }
开发者ID:didwjdgks,项目名称:yii2-smpp,代码行数:31,代码来源:ListController.php


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


示例5: start

 public static function start()
 {
     $gmc = new \GearmanClient();
     $gmc->addServer("127.0.0.1", 4730);
     $data = array();
     $task = $gmc->doNormal("hunt_postman", "foo");
 }
开发者ID:tempbottle,项目名称:Charme,代码行数:7,代码来源:Distribute.php


示例6: getClient

 /**
  * 获取gearmant客户端
  * @return \GearmanClient
  */
 private function getClient()
 {
     if ($this->client !== null) {
         return $this->client;
     }
     $client = new \GearmanClient();
     $conStrings = array();
     foreach ($this->servers as $ser) {
         if (is_string($ser)) {
             $conStrings[] = $ser;
         } else {
             $conStrings[] = $ser['host'] . (isset($ser['port']) ? ':' . $ser['port'] : '');
         }
     }
     $conString = false;
     if (count($conStrings) > 0) {
         $conString = implode(',', $conStrings);
     }
     if ($conString) {
         $result = $client->addServers($conString);
         if ($result) {
             $this->echoTraceLog('服务器添加成功! servers: ' . $conString);
         } else {
             $this->echoErrorLog('服务器添加失败! servers: ' . $conString);
             return false;
         }
     }
     $this->client = $client;
     return $this->client;
 }
开发者ID:fu-tao,项目名称:meelier_c,代码行数:34,代码来源:Client.php


示例7: getClient

 /**
  * 实现单例模式
  *
  * @param   array   $config
  * @return  GearmanClient
  */
 public static function getClient($config)
 {
     $worker = new GearmanClient();
     foreach ($config as $serverInfo) {
         $worker->addServer($serverInfo['host'], $serverInfo['port']);
     }
     return $worker;
 }
开发者ID:aozhongxu,项目名称:web_hqoj,代码行数:14,代码来源:GearmanPool.class.php


示例8: __construct

 public function __construct(\GearmanClient $client = null)
 {
     if (is_null($client)) {
         $client = new \GearmanClient();
         $client->addServers("localhost:4730");
     }
     $this->client = $client;
 }
开发者ID:gonzalo123,项目名称:gearmanserviceprovider,代码行数:8,代码来源:GearmanServiceProvider.php


示例9: Run

 public function Run()
 {
     /* create our object */
     $gmclient = new \GearmanClient();
     /* add the default server */
     $gmclient->addServer();
     /* run reverse client */
     $job_handle = $gmclient->doBackground("reverse", "this is a test");
 }
开发者ID:JasonOcean,项目名称:iOS_Interest_Group,代码行数:9,代码来源:gearman_ut.php


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


示例11: queueAssignment

/**
 * This function will take 3 arguments and pass it to gearman worker to store in database
*/
function queueAssignment($name, $email, $phone)
{
    $detailsArray = array('name' => $name, 'email' => $email, 'phone' => $phone);
    $detailsStr = json_encode($detailsArray);
    writeFile($detailsArray);
    // client code
    $client = new GearmanClient();
    $client->addServer();
    $store = $client->do("saveRecord", $detailsStr);
}
开发者ID:garimagupta03,项目名称:gearman_project,代码行数:13,代码来源:index.php


示例12: setup

 /**
  * do driver instance init
  */
 public function setup()
 {
     $settings = $this->getSettings();
     if (empty($settings)) {
         throw new BoxRouteInstanceException('init driver instance failed: empty settings');
     }
     $curInst = new \GearmanClient();
     $curInst->addServers($settings['gearmanHosts']);
     $this->instance = $curInst;
     $this->isAvailable = $this->instance ? true : false;
 }
开发者ID:nickfan,项目名称:appbox,代码行数:14,代码来源:GearmanClientBoxRouteInstanceDriver.php


示例13: _setupGearmanClient

 /**
  * Ustawienie gearman klienta
  */
 protected function _setupGearmanClient()
 {
     $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV);
     foreach ($config->gearman->client->server as $serverAddress) {
         try {
             self::$_client->addServer($serverAddress);
         } catch (Exception $exc) {
             throw new Exception("Gearman server on {$serverAddress} is not working!");
         }
     }
 }
开发者ID:knatorski,项目名称:SMS,代码行数:14,代码来源:Client.php


示例14: getInstance

 /**
  * This method will instantiate the object, configure it and return it
  *
  * @return Zend_Cache_Manager
  */
 public static function getInstance()
 {
     $config = App_DI_Container::get('ConfigObject');
     $gearmanClient = new GearmanClient();
     if (!empty($config->gearman->servers)) {
         $gearmanClient->addServers($config->gearman->servers->toArray());
     } else {
         $gearmanClient->addServer();
     }
     return $gearmanClient;
 }
开发者ID:omusico,项目名称:logica,代码行数:16,代码来源:GearmanClient.php


示例15: enqueue

 /**
  * enqueue
  *
  * @param string $value
  * @return boolean
  */
 public function enqueue($value)
 {
     $gm = new \GearmanClient();
     $gm->addServer($this->host, $this->port);
     $gm->queue_name = $this->queue_name;
     if ($gm->ping('ping')) {
         $job_handle = $gmclient->doBackground($this->queue_name, json_encode($value), md5($value));
         return $this->gmclient->returnCode() != GEARMAN_SUCCESS ? false : true;
     } else {
         return false;
     }
 }
开发者ID:nbari,项目名称:DALMP,代码行数:18,代码来源:Gearman.php


示例16: singleton

 public static function singleton()
 {
     if (is_null(self::$_instance)) {
         register_shutdown_function(array("\\Pool\\Client", shutdown));
         $client = new \GearmanClient();
         foreach (\PoolConf::$SERVERS as $server) {
             $client->addServer($server[0], $server[1]);
         }
         self::$_instance = new Client($client);
     }
     return self::$_instance;
 }
开发者ID:suraj-shingade,项目名称:php-pool,代码行数:12,代码来源:Client.php


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


示例18: createBackgroundProcess

 public function createBackgroundProcess($functionName, $workload)
 {
     // client
     $client = new \GearmanClient();
     $client->addServer('127.0.0.1', 4730);
     $result = $client->doBackground($functionName, $workload);
     $this->isWorkerExist($functionName);
     // worker
     $this->worker = new \GearmanWorker();
     $this->worker->addServer('127.0.0.1', 4730);
     $this->worker->setTimeout(240000);
     return $this;
 }
开发者ID:vadimizmalkov,项目名称:visoft-base-module,代码行数:13,代码来源:ProcessingService.php


示例19: send_gearman

 public static function send_gearman($toAddresses, $subject, $content)
 {
     if (class_exists('GearmanClient', false)) {
         $conf = (require 'conf.php');
         $confGearman = $conf['gearman'];
         $client = new GearmanClient();
         $client->addServer($confGearman['host'], $confGearman['port']);
         $data = array('toAddresses' => $toAddresses, 'subject' => $subject, 'content' => $content);
         return $client->doBackground("send_mail", serialize($data));
     } else {
         return Mail::send($toAddresses, $subject, $content);
     }
 }
开发者ID:tonny-zhang,项目名称:mailer-php,代码行数:13,代码来源:class.Mail.php


示例20: getGearmanClient

 /**
  * Get GearmanClient
  *
  * @return \GearmanClient
  */
 public function getGearmanClient()
 {
     if (!$this->client) {
         $this->client = new \GearmanClient();
     }
     if ($this->timeout !== null) {
         $this->client->setTimeout($this->timeout);
     }
     if ($this->context !== null) {
         $this->client->setContext($this->context);
     }
     return $this->client;
 }
开发者ID:jackdpeterson,项目名称:MwGearman,代码行数:18,代码来源:Pecl.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP GearmanWorker类代码示例发布时间:2022-05-23
下一篇:
PHP GeSHi类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap