mirror of
https://github.com/php/pecl-networking-gearman.git
synced 2026-03-23 23:22:22 +01:00
that was sticking in spaces where some tabs should have been. Fixed small bug in the examples. Updated README and other files
51 lines
1.1 KiB
PHP
51 lines
1.1 KiB
PHP
<?php
|
|
/*
|
|
* Gearman PHP Extension
|
|
*
|
|
* Copyright (C) 2008 James M. Luedke <contact@jamesluedke.com>,
|
|
* Eric Day <eday@oddments.org>
|
|
* All rights reserved.
|
|
*
|
|
* Use and distribution licensed under the PHP license. See
|
|
* the LICENSE file in this directory for full text.
|
|
*/
|
|
|
|
echo "Starting\n";
|
|
|
|
# Create our client object.
|
|
$gmclient= new GearmanClient();
|
|
|
|
# Add default server (localhost).
|
|
$gmclient->addServer();
|
|
|
|
echo "Sending job\n";
|
|
|
|
# Send reverse job
|
|
do
|
|
{
|
|
$result= $gmclient->do("reverse", "Hello!");
|
|
# Check for various return packets and errors.
|
|
switch($gmclient->returnCode())
|
|
{
|
|
case GEARMAN_WORK_DATA:
|
|
echo "Data: $result\n";
|
|
break;
|
|
case GEARMAN_WORK_STATUS:
|
|
list($numerator, $denominator)= $gmclient->doStatus();
|
|
echo "Status: $numerator/$denominator complete\n";
|
|
break;
|
|
case GEARMAN_WORK_FAIL:
|
|
echo "Failed\n";
|
|
exit;
|
|
case GEARMAN_SUCCESS:
|
|
break;
|
|
default:
|
|
echo "RET: " . $gmclient->returnCode() . "\n";
|
|
exit;
|
|
}
|
|
}
|
|
while($gmclient->returnCode() != GEARMAN_SUCCESS);
|
|
echo "Success: $result\n";
|
|
|
|
?>
|