本文整理汇总了PHP中GearmanClient::ping方法的典型用法代码示例。如果您正苦于以下问题:PHP GearmanClient::ping方法的具体用法?PHP GearmanClient::ping怎么用?PHP GearmanClient::ping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GearmanClient
的用法示例。
在下文中一共展示了GearmanClient::ping方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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');
}
}
示例2: 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;
}
}
示例3: client
/**
* @return \GearmanClient
* @throws MQException
*/
protected function client()
{
$client = new \GearmanClient();
$client->addServers($this->dns);
if (($haveGoodServer = $client->ping($this->id)) === false) {
throw new MQException("Server does not access: {$this->dns}");
}
return $client;
}