本文整理匯總了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;
}