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


PHP GearmanClient::setTimeout方法代码示例

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


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

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

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


//.........这里部分代码省略.........
      ***********************************/
     $di->set('dbMaster', function () use($self) {
         return $self->diDbMaster();
     }, true);
     $di->set('dbSlave', function () use($self) {
         return $self->diDbSlave();
     }, true);
     $di->set('transactions', function () use($di) {
         $transactions = new \Phalcon\Mvc\Model\Transaction\Manager();
         $transactions->setDbService('dbMaster');
         return $transactions;
     }, true);
     /**********************************
      * DI initialize for cache
      ***********************************/
     $di->set('globalCache', function () use($self) {
         return $self->diGlobalCache();
     }, true);
     $di->set('viewCache', function () use($self) {
         return $self->diViewCache();
     }, true);
     $di->set('modelsCache', function () use($self) {
         return $self->diModelsCache();
     }, true);
     $di->set('apiCache', function () use($self) {
         return $self->diApiCache();
     }, true);
     $di->set('fastCache', function () use($self) {
         return $self->diFastCache();
     }, true);
     /**********************************
      * DI initialize for queue
      ***********************************/
     $di->set('queue', function () use($di) {
         $config = $di->getConfig();
         $client = new \GearmanClient();
         $client->setTimeout(1000);
         foreach ($config->queue->servers as $key => $server) {
             $client->addServer($server->host, $server->port);
         }
         return $client;
     }, true);
     $di->set('worker', function () use($di) {
         $config = $di->getConfig();
         $worker = new \GearmanWorker();
         foreach ($config->queue->servers as $key => $server) {
             $worker->addServer($server->host, $server->port);
         }
         return $worker;
     }, true);
     /**********************************
      * DI initialize for email
      ***********************************/
     $di->set('mailer', function () use($self) {
         return $self->diMailer();
     }, true);
     $di->set('mailMessage', 'Eva\\EvaEngine\\MailMessage');
     $di->set('smsSender', function () use($self) {
         return $self->diSmsSender();
     }, true);
     /**********************************
      * DI initialize for helpers
      ***********************************/
     $di->set('url', function () use($di) {
         $config = $di->getConfig();
         $url = new UrlResolver();
         $url->setVersionFile($config->staticBaseUriVersionFile);
         $url->setBaseUri($config->baseUri);
         $url->setStaticBaseUri($config->staticBaseUri);
         return $url;
     }, true);
     $di->set('escaper', 'Phalcon\\Escaper');
     $di->set('tag', function () use($di, $self) {
         Tag::setDi($di);
         $self->registerViewHelpers();
         return new Tag();
     });
     $di->set('flash', 'Phalcon\\Flash\\Session');
     $di->set('placeholder', 'Eva\\EvaEngine\\View\\Helper\\Placeholder');
     $di->set('cookies', function () {
         $cookies = new \Phalcon\Http\Response\Cookies();
         $cookies->useEncryption(false);
         return $cookies;
     });
     $di->set('translate', function () use($self) {
         return $self->diTranslate();
     });
     $di->set('fileSystem', function () use($self) {
         return $self->diFileSystem();
     });
     $di->set('logException', function () use($di) {
         $config = $di->getConfig();
         return new FileLogger($config->logger->path . 'error.log');
     });
     if ($this->appMode == 'cli') {
         $this->cliDI($di);
     }
     IoC::setDI($di);
     return $this->di = $di;
 }
开发者ID:hushibing,项目名称:EvaEngine,代码行数:101,代码来源:Engine.php

示例4: assignTimeout

 /**
  * Given a GearmanClient, set timeout
  *
  * @param \GearmanClient $gearmanClient Object to include servers
  *
  * @return GearmanClient Returns self object
  */
 protected function assignTimeout(\GearmanClient $gearmanClient)
 {
     if ($this->timeout) {
         $gearmanClient->setTimeout($this->timeout);
     }
     return $this;
 }
开发者ID:WayOfBrave,项目名称:GearmanBundle,代码行数:14,代码来源:GearmanClient.php

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

示例6: sendMessage

 public function sendMessage($phones, $content)
 {
     $client = new GearmanClient();
     $client->addServer("219.232.243.98");
     $client->setTimeout(2000);
     if ($client->timeout() > 2000) {
         return false;
     }
     $result = $client->doBackground("sendMessage", json_encode(array('content' => $content, 'phones' => $phones)));
 }
开发者ID:qyt1988528,项目名称:union,代码行数:10,代码来源:Channel.php

示例7: sendPasswordEmailGearman

 public function sendPasswordEmailGearman($id, $token, $email)
 {
     $client = new GearmanClient();
     $client->addServer();
     $client->setTimeout(2000);
     if ($client->timeout() > 2000) {
         return false;
     }
     $result = $client->doBackground("sendPasswordEmail", json_encode(array('id' => $id, 'email' => $email, 'token' => $token)));
 }
开发者ID:qyt1988528,项目名称:union,代码行数:10,代码来源:User.php

示例8: rotate

 /**
  * 
  * 图片旋转接口
  * GET rotate/:id.json?direction={方向}&size={尺寸}
  */
 public function rotate($pid)
 {
     $direction = intval($_GET['direction']);
     $size = intval($_GET['size']);
     $size = in_array($size, Core::config('photo_standard_type')) ? $size : 130;
     if ($direction != -1) {
         $direction = 1;
     }
     if (!$pid) {
         $this->response(ResponseType::ERROR_LACKPARAMS);
     }
     $client = new GearmanClient();
     $client->addServers(Core::config('job_servers'));
     $client->setTimeout(3000);
     $result = @$client->doHigh("rotate", serialize(array($pid, $direction)));
     $result && ($sid = @unserialize($result));
     if (!$sid) {
         $thumb = new Thumb();
         if ($thumb->rotate(NULL, $pid, $direction)) {
             $sid = TRUE;
         }
     }
     if ($sid) {
         $photoModel = new Models\Photo();
         $imgurls = $photoModel->geturi($pid, $size);
         $return['src'] = $imgurls[0];
         $this->response(ResponseType::PHOTO_ROTATE_OK, '', $return);
     } else {
         $this->response(ResponseType::PHOTO_ROTATE_ERROR);
     }
 }
开发者ID:momoim,项目名称:momo-api,代码行数:36,代码来源:photo.php


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