當前位置: 首頁>>代碼示例>>PHP>>正文


PHP GearmanClient::addServer方法代碼示例

本文整理匯總了PHP中GearmanClient::addServer方法的典型用法代碼示例。如果您正苦於以下問題:PHP GearmanClient::addServer方法的具體用法?PHP GearmanClient::addServer怎麽用?PHP GearmanClient::addServer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在GearmanClient的用法示例。


在下文中一共展示了GearmanClient::addServer方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: addServer

 public function addServer($host, $port)
 {
     $start = microtime(true);
     $result = $this->client->addServer($host, $port);
     $this->logCall($start, 'addServer', array($host, $port), $result);
     return $result;
 }
開發者ID:NeonXP,項目名稱:symfony-gearman-bundle,代碼行數:7,代碼來源:LogClient.php

示例2: init

 public function init()
 {
     // Only use gearman implementation when WP_GEARS is defined and true
     if (!defined('WP_GEARS') || !WP_GEARS) {
         return false;
     }
     global $gearman_servers;
     if (!class_exists('GearmanClient') || !class_exists('GearmanWorker')) {
         return false;
     }
     if (defined('DOING_ASYNC') && DOING_ASYNC) {
         $this->_worker = new GearmanWorker();
         $this->_client = new GearmanClient();
         if (empty($gearman_servers)) {
             $this->_client->addServer();
             return $this->_worker->addServer();
         } else {
             $this->_client->addServers(implode(',', $gearman_servers));
             return $this->_worker->addServers(implode(',', $gearman_servers));
         }
     } else {
         $this->_client = new GearmanClient();
         if (empty($gearman_servers)) {
             $this->_client->addServer();
         } else {
             $this->_client->addServers(implode(',', $gearman_servers));
         }
         // Supressing errors, because this will return true or false, depending on if we could connect & communicate
         return @$this->_client->ping('test');
     }
 }
開發者ID:10up,項目名稱:wp-gears,代碼行數:31,代碼來源:class-gearman-async-task.php

示例3: init

 private function init()
 {
     if (!$this->gc) {
         $this->gc = new \GearmanClient();
         $this->gc->addServer();
         $this->gc->setCompleteCallback([$this, 'onTaskComplete']);
     }
 }
開發者ID:myurasov,項目名稱:mym-gearman-tools,代碼行數:8,代碼來源:GearmanTaskPool.php

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

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

示例6: getClientConnection

 /**
  * Get the GearmanClient instance
  * 
  * @return GearmanClient
  */
 public function getClientConnection()
 {
     //we have a stored connection
     if (!$this->_gmClient) {
         //Get the config, start the client object
         $_config = $this->_getConfiguration();
         $this->_gmClient = new GearmanClient();
         //add the servers to the client
         foreach ($_config as $_server) {
             $this->_gmClient->addServer($_server['host'], $_server['port']);
         }
     }
     return $this->_gmClient;
 }
開發者ID:svenvarkel,項目名稱:magento-lilmuckers_queue,代碼行數:19,代碼來源:Gearman.php

示例7: CreateNewClient

function CreateNewClient()
{
    $_client = new GearmanClient();
    $_client->addServer("192.168.201.12");
    $_client->setCompleteCallback("jobEcho");
    return $_client;
}
開發者ID:seiran1944,項目名稱:slate,代碼行數:7,代碼來源:client.php

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

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

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

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

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

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

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

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


注:本文中的GearmanClient::addServer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。