GearmanClient::ping

(No version information available, might only be in Git)

GearmanClient::pingSend data to all job servers to see if they echo it back

说明

public GearmanClient::ping ( string $workload ) : bool

Sends some arbitrary data to all job servers to see if they echo it back. The data sent is not used or processed in any other way. Primarily used for testing and debugging.

参数

workload

Some arbitrary serialized data to be echo back

返回值

成功时返回 TRUE, 或者在失败时返回 FALSE

User Contributed Notes

liv_romania at yahoo dot com 19-Jul-2015 06:53
If you want to test all job servers you can use the following code:

<?php
// Create our client object
$client= new GearmanClient();

// Add available and unavailable servers
$client->addServers('127.0.0.1:4730,127.0.0.2:4731');

// Test all job servers
$success = @$client->ping('data testing');
if (!
$success) {
    die(
'Error: ' . $client->error());
}

// Sending job
echo $client->doNormal('reverse', 'Hello World!');
?>