package.xml 0000644 0001750 0001750 00000044107 14603537402 012613 0 ustar rasmus rasmus
gearman
pecl.php.net
PHP wrapper to libgearman
This extension uses libgearman library to provide API for communicating with gearmand, and writing clients and workers.
James M. Luedke
jluedke
contact@jamesluedke.com
no
Herman J. Radtke III
hradtke
hradtke@php.net
yes
2024-04-04
2.1.2
2.1.2
stable
stable
PHP
PHP 8 is now supported
7.0.0
8.3.99
6.0.0
1.4.0b1
gearman
stable
stable
2.1.2
2.1.2
2024-04-03
- Bump max PHP version to support PHP 8.2 and 8.3
stable
stable
2.1.1
2.1.1
2024-04-02
- Compatibility fix - remove ZVAL_NEW_ARR usage
- add Param to skip exception handling setup in addServer/addServers in GearmanWorker class
- fix memory leak in GearmanClient::doXXX methods
- fix some proto and stubs types
stable
stable
2.1.0
2.1.0
2021-01-16
- PHP 8.0 Support
- Fix a serialization segfault
stable
stable
1.1.2
1.1.2
2013-08-28
- All callbacks should have a reference pointer (Special thanks to guilhermeblanco)
stable
stable
1.1.1
1.1.1
2013-01-08
- Updated README with new libgearman requirements.
- Add explicit check for >= libgearman-1.1.0
- Fixed PECL Bug 63807 (Special thanks to kgovande)
- Add support for gearman_client_unique_status() method
stable
stable
1.1.0
1.1.0
2012-09-22
- libgearman v1.1.* is now required
- Fixed PECL bug #60877 (no way to set client_id for a GearmanWorker)
- Fixed BC breaks in libgearman v1.1.0
- Make phpversion('gearman') return the real version
stable
stable
1.0.3
1.0.3
2012-08-04
- Additional fix for PECL Bug #59423 (GearmanWorker::wait and GearmanWorker::work are spamming the log with warnings.)
stable
stable
1.0.2
1.0.2
2012-03-05
- Updates for PHP 5.4
stable
stable
1.0.1
1.0.1
2011-12-05
- Fixed PECL Bug #60438 (wrong version number in php_gearman.h)
stable
stable
1.0.0
1.0.0
2011-12-02
- Fixed PECL Bug #18658 (GearmanWorker::wait and GearmanWorker::work are spamming the log with warnings.)
- Fixed PECL Bug #22636 (Uncaught worker exception sends back GEARMAN_SUCCESS return code)
- Fixed PECL Bug #16900 (Don't use reseved method names)
- Fixed PECL Bug #59944 (Undefined symbol: gearman_client_set_server_option)
- Now requires libgearman 0.21 or greater
beta
beta
0.8.0
0.8.0
2010-05-17
- Fixed PECL Bug #17114 (Return values that are class private variables are null'd)
- Fixed PECL Bug #22637 (GearmanJob::setReturn causes segfault)
- Fixed PECL Bug #16883 (GearmanJob::sendWarning() segfaults)
- Fixed PECL Bug #16884 (GearmanJob::sendData() crashes)
- Fixed PECL Bug #16883 (GearmanWorker::addFunction segfaults when function name is non-string)
- Fixed PECL Bug #17539 (Segmentation fault on calling error() of a fresh worker). Patch by jiayong.
beta
beta
0.7.0
0.7.0
2010-03-09
- Now builds against gearmand 0.12
- Had to remove some of the low level code I was working on.
beta
beta
0.6.0
0.6.0
2009-10-01
- Fixed build issue with 5.1.x
- Merged eday changes
- Added wait functions, uncommented other worker functions.
- Added timeout functions.
- Updated function list from C library and removed free methods (should use unset).
- Added stubs for new functions, fixed tests, fixed some of the existing functions from changes.
beta
beta
0.5.0
0.5.0
2009-07-27
- Fixed a bug in the task callbacks, the addtional data arg will now work as expected.
- Added gearman_client_add_servers. This was adde in a recent version of libgearman.
- Updates to zts for php 5.3
- Replaced errno with getErrno
beta
beta
0.4.0
0.4.0
2009-06-30
- Fixed memory leak in $task object
- Regened constants off of libgearman v0.7
- Removed gearman_task_take_data
- Added exception to task job object when created without a geaman obj arg
- Fixed a bunch of places where it was possible to use objects before verifying them
- Other small bug fixes
beta
beta
0.3
0.3
2009-05-20
- Initial PECL import
- Reworked client/worker/task/job objects.
- Added $obj->return_code() to all objects
- Fixed compile issues with PHP 5.1 and 5.3
gearman-2.1.2/examples/image_thumbnail_client_bg.php 0000644 0001750 0001750 00000001506 14603537402 022224 0 ustar rasmus rasmus addServer();
for ($x=0; $x<20; $x++)
{
$data[$x]['src']= $_SERVER['argv'][1];
$data[$x]['dest']= "$x.jpg";
$data[$x]['x']= ((80+1)*($x+1));
$data[$x]['y']= NULL;
}
/* fire off each job */
foreach ($data as $img)
{
$job_handle[]= $gmc->doBackground("shrink_image", serialize($img));
if ($gmc->returnCode() != GEARMAN_SUCCESS)
{
echo "ERROR RET: " . $gmc->error() . "\n";
exit;
}
}
echo "DONE\n";
gearman-2.1.2/examples/image_thumbnail_client.php 0000644 0001750 0001750 00000002130 14603537402 021546 0 ustar rasmus rasmus addServer();
$data['src']= $_SERVER['argv'][1];
$data['dest']= "small_" . $_SERVER['argv'][1];
$data['x']= 200;
$data['y']= NULL;
/* run reverse client */
do
{
$value = $gmc->do("shrink_image", serialize($data));
switch ($gmc->returnCode())
{
case GEARMAN_WORK_DATA:
echo "DATA: $value\n";
break;
case GEARMAN_SUCCESS:
echo "SUCCESS: $value\n";
break;
case GEARMAN_WORK_STATUS:
list($numerator, $denominator)= $gmc->doStatus();
echo "Status: $numerator/$denominator\n";
break;
default:
echo "ERR: " . $gmc->error() . "\n";
}
}
while($gmc->returnCode() != GEARMAN_SUCCESS);
echo "DONE: $value\n";
gearman-2.1.2/examples/image_thumbnail_client_task.php 0000644 0001750 0001750 00000003012 14603537402 022570 0 ustar rasmus rasmus addServer();
/* set a few callbacks */
$gmc->setCreatedCallback("thumb_created");
$gmc->setCompleteCallback("thumb_complete");
$gmc->setFailCallback("thumb_fail");
for ($x= 0; $x<20; $x++)
{
$data[$x]['src']= $_SERVER['argv'][1];
$data[$x]['dest']= "$x.jpg";
$data[$x]['x']= ((80+1)*($x+1));
$data[$x]['y']= NULL;
}
/* fire off each job */
foreach ($data as $img)
{
/* NOTE: if you want to asynchronously queue jobs use
** $task= $gmc->add_task_background("shrink_image", serialize($img));
** however keep in mind that your complete callback will not get called */
if (! $gmc->addTask("shrink_image", serialize($img)))
{
echo "ERROR RET: " . $gmc->error() . "\n";
exit;
}
}
if (! $gmc->runTasks())
{
echo "ERROR RET:" . $gmc->error() . "\n";
exit;
}
echo "DONE\n";
exit;
function thumb_created($task)
{
echo "CREATED -> job: " . $task->jobHandle() . "\n";
}
function thumb_complete($task)
{
echo "COMPLETE -> job: " . $task->jobHandle() .
" new_file: " . $task->data() . "\n";
}
function thumb_fail($task)
{
echo "FAIL job: " . $task->jobHandle() . "\n";
}
?>
gearman-2.1.2/examples/image_thumbnail_worker.php 0000644 0001750 0001750 00000002415 14603537402 021607 0 ustar rasmus rasmus addServer();
# optional config paramsj
$args;
$gmw->addFunction("shrink_image", "resize_image", $args);
while($gmw->work())
{
switch ($gmw->returnCode())
{
case GEARMAN_SUCCESS:
break;
default:
echo "ERROR RET: " . $gmc->returnCode() . "\n";
exit;
}
}
echo "DONE\n";
/* simple function to resize an image
* Requires the Imagick extension */
function resize_image($job, $args)
{
$wrk= $job->workload();
$data= unserialize($wrk);
if (! $data['src'] || ! $data['dest'] || ! $data['x'])
{ $job->sendFail(); print_r($data); return; }
echo $job->handle() . " - creating: $data[dest] x:$data[x] y:$data[y]\n";
$im= new Imagick();
$im->readimage($data['src']);
$im->thumbnailImage($data['x'], $data['y']);
$im->writeImage($data['dest']);
$im->destroy();
$job->sendStatus(1, 1);
return $data['dest'];
}
?>
gearman-2.1.2/examples/reverse_client_bg.php 0000644 0001750 0001750 00000001131 14603537402 020544 0 ustar rasmus rasmus ,
* Eric Day
* All rights reserved.
*
* Use and distribution licensed under the PHP license. See
* the LICENSE file in this directory for full text.
*/
/* create our object */
$gmclient= new GearmanClient();
/* add the default server */
$gmclient->addServer();
/* run reverse client */
$job_handle = $gmclient->doBackground("reverse", "this is a test");
if ($gmclient->returnCode() != GEARMAN_SUCCESS)
{
echo "bad return code\n";
exit;
}
exit;
?>
gearman-2.1.2/examples/reverse_client.php 0000644 0001750 0001750 00000002050 14603537402 020075 0 ustar rasmus rasmus ,
* Eric Day
* 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->doNormal("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_SUCCESS:
break;
default:
echo "RET: " . $gmclient->returnCode() . "\n";
exit;
}
}
while($gmclient->returnCode() != GEARMAN_SUCCESS);
echo "Success: $result\n";
?>
gearman-2.1.2/examples/reverse_client_task.php 0000644 0001750 0001750 00000001443 14603537402 021124 0 ustar rasmus rasmus addServer();
$gmc->setCreatedCallback("reverse_created");
$gmc->setStatusCallback("reverse_status");
$gmc->setCompleteCallback("reverse_complete");
$gmc->setFailCallback("reverse_fail");
$task= $gmc->addTask("reverse", "this is a test", NULL);
if (! $gmc->runTasks())
{
echo "ERROR " . $gmc->error() . "\n";
exit;
}
echo "DONE\n";
function reverse_created($task)
{
echo "CREATED: " . $task->jobHandle() . "\n";
}
function reverse_status($task)
{
echo "STATUS: " . $task->jobHandle() . " - " . $task->taskNumerator() .
"/" . $task->taskDenominator() . "\n";
}
function reverse_complete($task)
{
echo "COMPLETE: " . $task->jobHandle() . "\n";
}
function reverse_fail($task)
{
echo "FAILED: " . $task->jobHandle() . "\n";
}
?>
gearman-2.1.2/examples/reverse_worker.php 0000644 0001750 0001750 00000002774 14603537402 020145 0 ustar rasmus rasmus ,
* Eric Day
* 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 worker object.
$gmworker= new GearmanWorker();
# Add default server (localhost).
$gmworker->addServer();
# Register function "reverse" with the server. Change the worker function to
# "reverse_fn_fast" for a faster worker with no output.
$gmworker->addFunction("reverse", "reverse_fn");
print "Waiting for job...\n";
while($gmworker->work())
{
if ($gmworker->returnCode() != GEARMAN_SUCCESS)
{
echo "return_code: " . $gmworker->returnCode() . "\n";
break;
}
}
function reverse_fn($job)
{
echo "Received job: " . $job->handle() . "\n";
$workload= $job->workload();
$workload_size= $job->workloadSize();
echo "Workload: $workload ($workload_size)\n";
# This status loop is not needed, just showing how it works
for ($x= 0; $x < $workload_size; $x++)
{
echo "Sending status: $x/$workload_size complete\n";
/*
$job->sendStatus($x, $workload_size);
sleep(1);
*/
}
$result= strrev($workload);
echo "Result: $result\n";
# Return what we want to send back to the client.
return $result;
}
# A much simpler and less verbose version of the above function would be:
function reverse_fn_fast($job)
{
return strrev($job->workload());
}
?>
gearman-2.1.2/README 0000644 0001750 0001750 00000003653 14603537402 013427 0 ustar rasmus rasmus The Gearman PHP Extension provides a wrapper to libgearman. This
gives the user the ability to write fully featured Gearman clients
and workers in PHP, allowing them to quickly develop distributed
applications.
For more information about Gearman, see: http://www.gearman.org/
Requirements
* For the 0.8.* versions, libgearman v0.14 or greater
* For the 1.0.* versions, libgearman v0.21 or greater
* For the 1.1.* versions, libgearman v1.1.0 or greater
* For the 2.0.* versions, testing is done against libgearman v1.1.8 and PHP 7.0-7.4
* For the 2.1.* versions, testing is done against libgearman v1.1.18 and PHP 7.0-8.3
The Gearman PHP Extension requires the Gearman C server and library package
to be installed. You can download the latest from:
https://github.com/gearman/gearmand/releases
See the README file in that package for installation instructions. Once
it is installed you can compile the Gearman PHP Extension. You'll need
to make sure you have the PHP development packages installed first
(if you have 'phpize' command you’re all set). You'll also probably
want the PHP command line interface installed as well (usually named
php-cli). After extracting the Gearman PHP tarball, just run:
phpize
./configure
make
make install
You then need to make PHP aware of the new extension by adding the
following line to your php.ini:
extension="gearman.so"
You can then test if the module is configured correctly with the
PHP cli:
php --info | grep gearman
To run a simple example
cd examples
1. Start the gearmand server in a separate terminal:
gearmand
2. In another terminal, change to this source directory and run:
php examples/reverse_worker.php
3. In another terminal, change to this source directory and run:
php examples/reverse_client.php
You should see some output from both the reverse client and worker
scripts about the status and then a final result.
Have fun!
http://pecl.php.net/package/gearman
gearman-2.1.2/CREDITS 0000644 0001750 0001750 00000000211 14603537402 013552 0 ustar rasmus rasmus Authors: James M. Luedke
Eric Day
Big Thanks: Pierre Joye (http://blog.thepimp.net/)
gearman-2.1.2/LICENSE 0000644 0001750 0001750 00000006222 14603537402 013547 0 ustar rasmus rasmus --------------------------------------------------------------------
The PHP License, version 3.01
Copyright (c) 1999 - 2008 The PHP Group. All rights reserved.
--------------------------------------------------------------------
Redistribution and use in source and binary forms, with or without
modification, is permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. The name "PHP" must not be used to endorse or promote products
derived from this software without prior written permission. For
written permission, please contact group@php.net.
4. Products derived from this software may not be called "PHP", nor
may "PHP" appear in their name, without prior written permission
from group@php.net. You may indicate that your software works in
conjunction with PHP by saying "Foo for PHP" instead of calling
it "PHP Foo" or "phpfoo"
5. The PHP Group may publish revised and/or new versions of the
license from time to time. Each version will be given a
distinguishing version number.
Once covered code has been published under a particular version
of the license, you may always continue to use it under the terms
of that version. You may also choose to use such covered code
under the terms of any subsequent version of the license
published by the PHP Group. No one other than the PHP Group has
the right to modify the terms applicable to covered code created
under this License.
6. Redistributions of any form whatsoever must retain the following
acknowledgment:
"This product includes PHP software, freely available from
".
THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND
ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP
DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------
This software consists of voluntary contributions made by many
individuals on behalf of the PHP Group.
The PHP Group can be contacted via Email at group@php.net.
For more information on the PHP Group and the PHP project,
please see .
PHP includes the Zend Engine, freely available at
.
gearman-2.1.2/ChangeLog 0000644 0001750 0001750 00000004057 14603537402 014320 0 ustar rasmus rasmus Version 2.1.2
-------------
- Bump max PHP version so pecl will install for PHP 8.2 and 8.3 as well
Version 2.1.1
-------------
- Compatibility fix - remove ZVAL_NEW_ARR usage
- add Param to skip exception handling setup in addServer/addServers in GearmanWorker class
- fix memory leak in GearmanClient::doXXX methods
- fix some proto and stubs types
Version 2.1.0
-------------
- PHP 8.0 support
- Serialization segfault fix
- Clean up tests
Version 2.0.6
-------------
- fixing issue with double calling of zval_dtor in set fail callback
Version 2.0.5
-------------
- fixing incorrect number of required parameters for GearmanClient::addServer
and GearmanClient::addServers, along with proceduralequivalents
Version 2.0.4
-------------
- bug fix for issue #59, Param to skip exception handling setup in addServer/addServers
in GearmanClient class
Version 2.0.3
-------------
- Including changes for PHP 7.x
- smaller bug fixes
- splitting up into several smaller files
Version 0.6.0
-------------
- Fixed build issue with 5.1.x
- Merged eday changes
- Added wait functions, uncommented other worker functions.
- Added timeout functions.
- Updated function list from C library and removed free methods (should use unset).
- Added stubs for new functions, fixed tests, fixed some of the existing functions from changes.
Version 0.5.0
-------------
- Fixed a bug in the task callbacks, the addtional data arg will now work as expected.
- Added gearman_client_add_servers. This was adde in a recent version of libgearman.
- Updates to zts for php 5.3
- Replaced errno with getErrno
Version 0.4.0
-------------
- Fixed memory leak in $task object
- Regened constants off of libgearman v0.7
- Removed gearman_task_take_data
- Added exception to task job object when created without a geaman obj arg
- Fixed a bunch of places where it was possible to use objects before verifying them
- Other small bug fixes
Version 0.3.1
-------------
- Initial PECL import
- Reworked client/worker/task/job objects.
- Added $obj->return_code() to all objects
- Fixed compile issues with PHP 5.1 and 5.3
gearman-2.1.2/TODO 0000644 0001750 0001750 00000000420 14603537402 013224 0 ustar rasmus rasmus Sat Mar 28 16:44:11 PDT 2009
1. Create generic add_task_*/client_do function so there is not so much
code duplication.
2. Clean up test_[client|worker].php scripts. Check every return val etc.
3. Split code into more files php_gearman.c client.c worker.c task.c job.c
gearman-2.1.2/test_client.php 0000644 0001750 0001750 00000024330 14603537402 015570 0 ustar rasmus rasmus ,
* Eric Day
* All rights reserved.
*
* Use and distribution licensed under the PHP license. See
* the LICENSE file in this directory for full text.
*/
/* client */
echo "# TESTING CLIENT INTERFACE\n";
$client = gearman_client_create();
if (! is_object($client))
{
echo "gearman_client_create() FAILED\n";
exit(0);
}
else
echo "gearman_client_create() pass\n";
/*
$client_new = gearman_client_clone($client);
if (! is_object($client_new))
{
echo "gearman_client_clone() FAILED\n";
exit(0);
}
else
echo "gearman_client_clone() pass\n";
unset($client_new);
echo "unset client pass\n";
*/
$ret= gearman_client_error($client);
if ($ret != GEARMAN_SUCCESS)
{
echo "gearman_client_error() FAILED\n";
exit(0);
}
else
echo "gearman_client_error() pass\n";
$ret= gearman_client_get_errno($client);
if ($ret != 0)
{
echo "gearman_client_get_errno() FAILED\n";
exit(0);
}
else
echo "gearman_client_get_errno() pass\n";
if (! gearman_client_add_options($client, GEARMAN_CLIENT_UNBUFFERED_RESULT))
{
echo "gearman_client_set_options() FAILED\n";
exit(0);
}
gearman_client_remove_options($client, GEARMAN_CLIENT_UNBUFFERED_RESULT);
echo "gearman_client_set_options() pass\n";
/*
if (! gearman_client_add_server($client))
{
echo "gearman_client_add_server() FAILED\n";
exit(0);
}
echo "gearman_client_add_server() pass\n";
*/
if (! gearman_client_add_servers($client, "127.0.0.1:4730"))
{
echo "gearman_client_add_servers() FAILED\n";
exit(0);
}
echo "gearman_client_add_servers() pass\n";
$value = gearman_client_do_normal($client, "test_worker", "gearman_client_do");
if ($client->returnCode() != GEARMAN_SUCCESS)
{
echo "gearman_client_do_normal() FAILED\n";
exit(0);
}
else
echo "gearman_client_do_normal() pass -> $value\n";
$job_handle = gearman_client_do_background($client, "test_worker", "gearman_client_do_background");
if ($client->returnCode() != GEARMAN_SUCCESS)
{
echo "gearman_client_do_background() FAILED\n";
exit(0);
}
else
echo "gearman_client_do_background() pass -> $job_handle\n";
$value = gearman_client_do_high($client, "test_worker", "gearman_client_do_high");
if ($client->returnCode() != GEARMAN_SUCCESS)
{
echo "gearman_client_do_high() FAILED\n";
exit(0);
}
else
echo "gearman_client_do_high() pass -> $value\n";
$value = gearman_client_do_low($client, "test_worker", "gearman_client_do_low");
if ($client->returnCode() != GEARMAN_SUCCESS)
{
echo "gearman_client_do_low() FAILED\n";
exit(0);
}
else
echo "gearman_client_do_low() pass -> $value\n";
$value = gearman_client_do_high_background($client, "test_worker", "gearman_client_do_high_background");
if ($client->returnCode() != GEARMAN_SUCCESS)
{
echo "gearman_client_do_high_background() FAILED\n";
exit(0);
}
else
echo "gearman_client_do_high_background() pass -> $value\n";
$value = gearman_client_do_low_background($client, "test_worker", "gearman_client_do_low_background");
if ($client->returnCode() != GEARMAN_SUCCESS)
{
echo "gearman_client_do_low_background() FAILED\n";
exit(0);
}
else
echo "gearman_client_do_low_background() pass -> $value\n";
$job_handle = gearman_client_do_background($client, "test_gearman_job_status", "test_gearman_job_status");
if ($client->returnCode() != GEARMAN_SUCCESS)
{
echo "gearman_client_do_background() FAILED -> while checking status\n";
exit(0);
}
sleep(1);
list($is_known, $is_running, $numerator, $denominator) = gearman_client_job_status($client, $job_handle);
if ($client->returnCode() != GEARMAN_SUCCESS || ! $is_known || ! $is_running || ! $numerator || ! $denominator)
{
echo "gearman_client_job_status() FAILED\n";
}
else
echo "gearman_client_job_status() pass -> is_known: $is_known is_running: $is_running $numerator / $denominator\n";
if ($job_handle != gearman_client_do_job_handle($client))
{
echo "gearman_client_do_job_handle() FAILED\n";
exit(0);
}
else
echo "gearman_client_do_job_handle() pass -> $job_handle\n";
gearman_client_ping($client, "gearman_client_ping");
echo "gearman_client_ping() pass\n";
gearman_client_add_task($client, "test_gearman_job", "test_gearman_job", "test_gearman_job");
echo "gearman_client_add_task() pass\n";
/* run a task see if they all work */
$res = gearman_client_run_tasks($client);
echo "gearman_client_run_tasks() pass\n";
/* clear all the callbacks so they dont mess with other test */
gearman_client_clear_callbacks($client);
echo "gearman_client_clear_callbacks() pass\n";
/* set all of our callback functions */
/*
gearman_client_set_workload_fn($client, "test_gearman_client_set_workload_fn");
echo "gearman_client_set_workload_fn() pass\n";
*/
gearman_client_set_created_callback($client, "test_gearman_client_set_created_callback");
// XXX gearman_client_set_data_fn($client, "test_gearman_client_set_data_fn");
gearman_client_set_warning_callback($client, "test_gearman_client_set_warning_callback");
gearman_client_set_status_callback($client, "test_gearman_client_set_status_callback");
gearman_client_set_complete_callback($client, "test_gearman_client_set_complete_callback");
gearman_client_set_exception_callback($client, "test_gearman_client_set_exception_callback");
gearman_client_set_fail_callback($client, "test_gearman_client_set_fail_callback");
gearman_client_add_task($client, "test_set_callback_callback", "test_set_callback_callback", "test_set_callback_callback");
/* run a task see if they all work */
$res = gearman_client_run_tasks($client);
// gearman_client_clear_fn($client);
/* test tasks interface */
gearman_client_clear_callback($client);
gearman_client_set_complete_callback($client, "test_gearman_tasks");
gearman_client_add_task($client, "test_tasks", "test_tasks", "test_tasks");
$res = gearman_client_run_tasks($client);
gearman_client_clear_callback($client);
# You can turn off auto task destruction by unsetting this flag on a gearman client.
gearman_client_remove_options($client, GEARMAN_CLIENT_FREE_TASKS);
$task = gearman_client_add_task_background($client, "test_tasks_background", "test_tasks_background", "test_tasks_background");
gearman_client_set_status_callback($client, "test_gearman_task_status");
$res = gearman_client_run_tasks($client);
$job_handle = gearman_task_job_handle($task);
gearman_client_add_task_status($client, $job_handle);
echo "\tgearman_client_add_task_status() pass\n";
$res = gearman_client_run_tasks($client);
function test_gearman_task_status($task)
{
$is_known = gearman_task_is_known($task);
if ($is_known)
echo "\tgearman_task_is_known() pass\n";
else
echo "\tgearman_task_is_known() FAILED\n";
sleep(1);
$is_running = gearman_task_is_running($task);
if ($is_running)
echo "\tgearman_task_is_running() pass\n";
else
echo "\tgearman_task_is_running() pass\n";
}
echo "gearman_client_add_task_background() pass\n";
gearman_client_clear_callback($client);
gearman_client_add_task_high($client, "test_tasks_high", "test_tasks_high", "test_tasks_high");
echo "gearman_client_add_task_high() pass\n";
gearman_client_add_task_low($client, "test_tasks_low", "test_tasks_low", "test_tasks_low");
echo "gearman_client_add_task_low() pass\n";
gearman_client_add_task_high_background($client, "test_tasks_high_background", "test_tasks_high_background", "test_tasks_high_background");
echo "gearman_client_add_task_high_background() pass\n";
gearman_client_add_task_low_background($client, "test_tasks_low_background", "test_tasks_low_background", "test_tasks_low_background");
echo "gearman_client_add_task_low_background() pass\n";
$res = gearman_client_run_tasks($client);
/* XXX add task high seems to break things
*/
$value = gearman_client_do($client, "exit_test", "exit_test");
echo "DONE $ret\n";
/* XXX does not seem to call cb as i would expect
$data = "gearman_job_exception";
gearman_client_add_task($client, "test_gearman_job_exception", $data, NULL);
$data = "gearman_job_fail";
gearman_client_add_task($client, "test_gearman_job_fail", $data, NULL);
*/
/* XXX can not test till I have the gearman low level functions done
$task_new = gearman_task_create();
gearman_task_fn_arg($task_new);
echo "gearman_task_fn_arg() pass\n";
*/
/*
* Test Functions
*/
function test_gearman_client_set_fail_callback($task)
{
echo "\tgearman_client_set_fail_callback() pass\n";
}
function test_gearman_client_set_exception_callback($task)
{
echo "\tgearman_client_set_exception_callback() pass\n";
}
function test_gearman_client_set_complete_callback($task)
{
echo "\tgearman_client_set_complete_callback() pass\n";
}
function test_gearman_client_set_status_callback($task)
{
echo "\tgearman_client_set_status_callback() pass\n";
}
function test_gearman_client_set_warning_callback($task)
{
echo "\tgearman_client_set_warning_callback() pass\n";
}
function test_gearman_client_set_data_callback($task)
{
echo "\tgearman_client_set_data_callback() pass\n";
}
function test_gearman_client_set_created_callback($task)
{
echo "\tgearman_client_set_created_callback() pass\n";
}
function test_gearman_client_set_workload_callback($task)
{
echo "\tgearman_client_set_workload_callback() pass\n";
}
function test_gearman_tasks($task)
{
$is_known= false;
$is_running= false;
echo "Testing Task Functions\n";
$func = gearman_task_function_name($task);
echo "\tgearman_task_function_name() pass - $func\n";
$uuid = gearman_task_unique($task);
echo "\tgearman_task_unique() pass - $uuid\n";
$job_handle = gearman_task_job_handle($task);
echo "\tgearman_task_job_handle() pass - $job_handle\n";
$numerator = gearman_task_numerator($task);
echo "\tgearman_task_numerator() pass - $numerator\n";
$denominator = gearman_task_denominator($task);
echo "\tgearman_task_denominator() pass - $denominator\n";
$data = gearman_task_data($task);
echo "\tgearman_task_data() pass - $data\n";
$data_size = gearman_task_data_size($task);
echo "\tgearman_task_data_size() pass - $data_size\n";
/* XXX Not sure how to test task data yet
gearman_task_take_data($task);
echo "gearman_task_take_data() pass\n";
gearman_task_send_data()
gearman_task_recv_data()
*/
}
?>
gearman-2.1.2/test_worker.php 0000644 0001750 0001750 00000017241 14603537402 015626 0 ustar rasmus rasmus ,
* Eric Day
* All rights reserved.
*
* Use and distribution licensed under the PHP license. See
* the LICENSE file in this directory for full text.
*/
/* worker */
$worker = gearman_worker_create();
if (! is_object($worker))
{
echo "gearman_worker_create() FAILED\n";
exit(0);
}
else
echo "gearman_worker_create() pass\n";
/*
if(! gearman_worker_add_server($worker))
{
echo "gearman_worker_add_server() FAILED\n";
exit(0);
}
echo "gearman_worker_add_server() pass\n";
*/
if(! gearman_worker_add_servers($worker, "127.0.0.1:4730"))
{
echo "gearman_worker_add_servers() FAILED\n";
exit(0);
}
echo "gearman_worker_add_servers() pass\n";
/*
$worker_new = gearman_worker_clone($worker);
if (! is_object($worker_new))
{
echo "gearman_worker_clone() FAILED\n";
exit(0);
}
else
echo "gearman_worker_clone() pass\n";
unset($worker_new);
echo "unset worker pass\n";
$ret = gearman_worker_error($worker);
if ($ret != GEARMAN_SUCCESS)
{
echo "gearman_worker_error() FAILED\n";
exit(0);
}
else
echo "gearman_worker_error() pass\n";
if(! gearman_worker_set_options($worker, GEARMAN_WORKER_NON_BLOCKING, 1))
{
echo "gearman_worker_set_options() FAILED\n";
exit(0);
}
gearman_worker_set_options($worker, GEARMAN_WORKER_NON_BLOCKING, 0);
echo "gearman_worker_set_options() pass\n";
if(! gearman_worker_register($worker, "test_one"))
{
echo "gearman_worker_register() FAILED\n";
exit(0);
}
gearman_worker_register($worker, "test_two");
gearman_worker_register($worker, "test_three");
echo "gearman_worker_register() pass\n";
if(! gearman_worker_unregister($worker, "test_three"))
{
echo "gearman_worker_unregister() FAILED\n";
exit(0);
}
echo "gearman_worker_unregister() pass\n";
if(! gearman_worker_unregister_all($worker))
{
echo "gearman_worker_unregister_all() FAILED\n";
exit(0);
}
echo "gearman_worker_unregister_all() pass\n";
gearman_worker_echo($worker, "gearman_worker_echo");
echo "gearman_worker_echo() pass\n";
*/
if (! gearman_worker_add_function($worker, "test_worker", "test_worker", "test_worker"))
{
echo "gearman_worker_add_function() FAILED\n";
exit(0);
}
gearman_worker_add_function($worker, "exit_test", "exit_test", "exit_test");
gearman_worker_add_function($worker, "test_gearman_job", "test_gearman_job", "test_gearman_job");
gearman_worker_add_function($worker, "test_set_callback_fn", "test_set_callback_fn", "test_set_callback_fn");
gearman_worker_add_function($worker, "test_tasks", "test_tasks", "test_tasks");
gearman_worker_add_function($worker, "test_tasks_background", "test_tasks_background", "test_tasks_background");
gearman_worker_add_function($worker, "test_tasks_high", "test_tasks_high", "test_tasks_high");
gearman_worker_add_function($worker, "test_tasks_low", "test_tasks_low", "test_tasks_low");
gearman_worker_add_function($worker, "test_tasks_high_background", "test_tasks_high_background", "test_tasks_high_background");
gearman_worker_add_function($worker, "test_tasks_low_background", "test_tasks_low_background", "test_tasks_low_background");
gearman_worker_add_function($worker, "test_gearman_job_status", "test_gearman_job_status", "test_status");
gearman_worker_add_function($worker, "test_gearman_job_complete", "test_gearman_job_complete", "test_complete");
gearman_worker_add_function($worker, "test_gearman_job_exception", "test_gearman_job_exception", "test_exception");
gearman_worker_add_function($worker, "test_gearman_job_fail", "test_gearman_job_fail", "test_fail");
echo "gearman_worker_add_function() pass\n";
echo "Starting Worker...\n";
$numb_test = 5;
$do_loop= true;
while ($do_loop)
{
if (! gearman_worker_work($worker))
{
echo "gearman_worker_work: FAILED\n";
exit(0);
}
}
echo "gearman_worker_work() pass\n";
/*
* Job Functions
*/
/* XXX finish this up once the gearman objects are added
$job = gearman_job_create();
if (! is_object($job))
{
echo "gearman_job_create() FAILED\n";
exit(0);
}
else
echo "gearman_job_create() pass\n";
$data = "job_data";
gearman_job_data($job, $data);
echo "gearman_job_data() pass\n";
gearman_job_warning($job, "gearman_job_warning");
echo "gearman_job_warning() pass\n";
gearman_job_status($job, 1, 2);
gearman_job_status($job, 2, 2);
echo "gearman_job_status() pass\n";
gearman_job_complete($job, "gearman_job_complete");
echo "gearman_job_complete() pass\n";
gearman_job_exception($job, "gearman_job_exception");
echo "gearman_job_exception() pass\n";
geaman_job_fail($job, "gearman_job_fail");
echo "gearman_job_fail() pass\n";
$job_handle= gearman_job_handle($job);
if (! is_string($job_handle))
{
echo "gearman_job_handle() FAILED\n";
exit(0);
}
else
echo "gearman_job_handle() pass\n";
*/
/*
* Test Functions
*/
function exit_test($job, $data)
{
global $do_loop;
echo "Done Working\n";
$do_loop=false;
}
function test_gearman_job_fail($job, $data)
{
gearman_job_fail($job);
echo "gearman_job_fail() pass\n";
}
function test_gearman_job_exception($job, $data)
{
gearman_job_exception($job, "test_exception");
echo "gearman_job_exception() pass\n";
}
function test_gearman_job_complete($job, $data)
{
gearman_job_complete($job, "test_complete");
echo "gearman_job_complete() pass\n";
}
function test_gearman_job_status($job, $data)
{
gearman_job_send_data($job, "test data");
gearman_job_send_status($job, 1, 4);
sleep(1);
gearman_job_send_status($job, 2, 4);
sleep(1);
gearman_job_send_status($job, 3, 4);
sleep(1);
gearman_job_send_status($job, 4, 4);
sleep(1);
echo "gearman_send_job_status() pass\n";
}
function test_worker($job, $data=NULL)
{
return $job->workload();
}
function test_gearman_job($job, $data)
{
echo "Testing Job Functions\n";
$job_handle = gearman_job_handle($job);
echo "\tgearman_job_handle() pass - $job_handle\n";
$workload = gearman_job_workload($job);
echo "\tgearman_job_workload() pass - $workload\n";
$workload_size = gearman_job_workload_size($job);
echo "\tgearman_job_workload_size() pass - $workload_size\n";
$fname = gearman_job_function_name($job);
echo "\tgearman_job_function_name() pass - $fname\n";
return "test_set_callback_fn";
}
function test_set_callback_fn($job, $data)
{
gearman_job_send_status($job, 1, 1);
echo "\tgearman_job_send_status() pass\n";
sleep(1);
gearman_job_send_warning($job, "test_set_callback_fn warning");
echo "\tgearman_job_send_warning() pass\n";
sleep(1);
gearman_job_send_exception($job, "test_set_callback_fn exception");
echo "\tgearman_job_send_exception() pass\n";
sleep(1);
/* $job->set_return(GEARMAN_WORK_FAIL); == $job->fail() == */
if(! gearman_job_send_fail($job))
echo "\tgearman_job_send_fail() FAILED\n";
else
echo "\tgearman_job_send_fail() pass\n";
sleep(1);
}
function test_tasks($job, $data)
{
$job->sendData("foobar");
gearman_job_send_status($job, 1, 1);
sleep(2);
return "test_tasks";
}
function test_tasks_background($job, $data)
{
echo "\ttest_tasks_background() pass\n";
gearman_job_send_status($job, 1, 2);
sleep(4);
gearman_job_send_status($job, 2, 2);
return "done";
}
function test_tasks_high($job, $data)
{
echo "\ttest_task_high() pass\n";
sleep(1);
}
function test_tasks_low($job, $data)
{
echo "\ttest_task_low() pass\n";
sleep(1);
}
function test_tasks_high_background($job, $data)
{
echo "\ttest_task_high_background() pass\n";
sleep(1);
}
function test_tasks_low_background($job, $data)
{
echo "\ttest_task_low_background() pass\n";
sleep(1);
}
?>
gearman-2.1.2/config.m4 0000644 0001750 0001750 00000004470 14603537402 014254 0 ustar rasmus rasmus dnl Gearman PHP Extension
dnl
dnl Copyright (C) 2008 James M. Luedke ,
dnl Eric Day
dnl All rights reserved.
dnl
dnl Use and distribution licensed under the PHP license. See
dnl the LICENSE file in this directory for full text.
CFLAGS="$CFLAGS -Wall"
PHP_ARG_WITH(gearman, whether to enable gearman support,
[[ --with-gearman[=PATH] Include gearman support]])
if test "$PHP_GEARMAN" != "no"; then
for i in $PHP_GEARMAN /usr/local /usr /opt/local; do
if test -r $i/include/libgearman-1.0/gearman.h; then
GEARMAN_LIB_DIR=$i/$PHP_LIBDIR
GEARMAN_INC_DIR=$i/include
AC_MSG_RESULT([found in $i])
break
fi
done
if test -z "$GEARMAN_LIB_DIR" -o -z "$GEARMAN_INC_DIR"; then
AC_MSG_RESULT([not found])
AC_MSG_ERROR([Please install libgearman])
fi
PHP_CHECK_LIBRARY(gearman, gearman_client_set_context,
[
PHP_ADD_LIBRARY_WITH_PATH(gearman, $GEARMAN_LIB_DIR, GEARMAN_SHARED_LIBADD)
AC_DEFINE(HAVE_GEARMAN, 1, [Whether you have gearman])
],[
AC_MSG_ERROR([libgearman version 0.10 or later required])
],[
-L$GEARMAN_LIB_DIR -R$GEARMAN_LIB_DIR
])
PHP_CHECK_LIBRARY(gearman, gearman_worker_set_server_option,
[
PHP_ADD_LIBRARY_WITH_PATH(gearman, $GEARMAN_LIB_DIR, GEARMAN_SHARED_LIBADD)
AC_DEFINE(HAVE_GEARMAN, 1, [Whether you have gearman])
],[
AC_MSG_ERROR([libgearman version 0.21 or later required])
],[
-L$GEARMAN_LIB_DIR -R$GEARMAN_LIB_DIR
])
PHP_CHECK_LIBRARY(gearman, gearman_job_error,
[
PHP_ADD_LIBRARY_WITH_PATH(gearman, $GEARMAN_LIB_DIR, GEARMAN_SHARED_LIBADD)
AC_DEFINE(HAVE_GEARMAN, 1, [Whether you have gearman])
],[
AC_MSG_ERROR([libgearman version 1.1.0 or later required])
],[
-L$GEARMAN_LIB_DIR -R$GEARMAN_LIB_DIR
])
PHP_CHECK_LIBRARY(gearman, gearman_client_unique_status,
[
PHP_ADD_LIBRARY_WITH_PATH(gearman, $GEARMAN_LIB_DIR, GEARMAN_SHARED_LIBADD)
AC_DEFINE(HAVE_GEARMAN, 1, [Whether you have gearman])
],[
AC_MSG_ERROR([libgearman version 1.1.0 or later required])
],[
-L$GEARMAN_LIB_DIR -R$GEARMAN_LIB_DIR
])
PHP_SUBST(GEARMAN_SHARED_LIBADD)
PHP_ADD_INCLUDE($GEARMAN_INC_DIR)
PHP_NEW_EXTENSION(gearman, php_gearman.c php_gearman_client.c php_gearman_worker.c php_gearman_job.c php_gearman_task.c, $ext_shared)
fi
gearman-2.1.2/php_gearman.c 0000644 0001750 0001750 00000054761 14603537402 015202 0 ustar rasmus rasmus /*
* Gearman PHP Extension
*
* Copyright (C) 2008 James M. Luedke ,
* Eric Day
* All rights reserved.
*
* Use and distribution licensed under the PHP license. See
* the LICENSE file in this directory for full text.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "php_gearman.h"
#include "php_gearman_client.h"
#include "php_gearman_task.h"
#include "php_gearman_worker.h"
#include "zend_exceptions.h"
#include "zend_interfaces.h"
#include "gearman_arginfo.h"
#include
#include
#include
zend_class_entry *gearman_exception_ce;
zend_class_entry *gearman_client_ce;
zend_object_handlers gearman_client_obj_handlers;
zend_class_entry *gearman_task_ce;
zend_object_handlers gearman_task_obj_handlers;
zend_class_entry *gearman_job_ce;
zend_object_handlers gearman_job_obj_handlers;
zend_class_entry *gearman_worker_ce;
zend_object_handlers gearman_worker_obj_handlers;
/* Custom malloc and free calls to avoid excessive buffer copies. */
void *_php_malloc(size_t size, void *arg) {
uint8_t *ret;
ret = emalloc(size+1);
ret[size]= 0;
return ret;
}
void _php_free(void *ptr, void *arg) {
efree(ptr);
}
/*
* Functions from gearman.h
*/
/* {{{ proto string gearman_version()
Returns libgearman version */
PHP_FUNCTION(gearman_version) {
RETURN_STRING((char *)gearman_version());
}
/* }}} */
/* {{{ proto string gearman_bugreport()
Returns bug report URL string */
PHP_FUNCTION(gearman_bugreport) {
RETURN_STRING((char *)gearman_bugreport());
}
/* }}} */
/* {{{ proto ?string gearman_verbose_name(constant verbose)
Returns string with the name of the given verbose level */
PHP_FUNCTION(gearman_verbose_name) {
zend_long verbose;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l",
&verbose) == FAILURE) {
php_error_docref(NULL, E_WARNING, "Unable to parse parameters.");
RETURN_NULL();
}
if (verbose < 0) {
php_error_docref(NULL, E_WARNING, "Input must be an integer greater than 0.");
RETURN_NULL();
}
RETURN_STRING((char *)gearman_verbose_name(verbose));
}
/* }}} */
PHP_MINIT_FUNCTION(gearman) {
zend_class_entry ce;
INIT_CLASS_ENTRY(ce, "GearmanClient", class_GearmanClient_methods);
gearman_client_ce = zend_register_internal_class(&ce);
gearman_client_ce->create_object = gearman_client_obj_new;
memcpy(&gearman_client_obj_handlers, zend_get_std_object_handlers(), sizeof(gearman_client_obj_handlers));
gearman_client_obj_handlers.offset = XtOffsetOf(gearman_client_obj, std);
gearman_client_obj_handlers.free_obj = gearman_client_free_obj;
INIT_CLASS_ENTRY(ce, "GearmanTask", class_GearmanTask_methods);
gearman_task_ce = zend_register_internal_class(&ce);
gearman_task_ce->create_object = gearman_task_obj_new;
memcpy(&gearman_task_obj_handlers, zend_get_std_object_handlers(), sizeof(gearman_task_obj_handlers));
gearman_task_obj_handlers.offset = XtOffsetOf(gearman_task_obj, std);
gearman_task_obj_handlers.free_obj = gearman_task_free_obj;
INIT_CLASS_ENTRY(ce, "GearmanWorker", class_GearmanWorker_methods);
gearman_worker_ce = zend_register_internal_class(&ce);
gearman_worker_ce->create_object = gearman_worker_obj_new;
memcpy(&gearman_worker_obj_handlers, zend_get_std_object_handlers(), sizeof(gearman_worker_obj_handlers));
gearman_worker_obj_handlers.offset = XtOffsetOf(gearman_worker_obj, std);
INIT_CLASS_ENTRY(ce, "GearmanJob", class_GearmanJob_methods);
gearman_job_ce = zend_register_internal_class(&ce);
gearman_job_ce->create_object = gearman_job_obj_new;
memcpy(&gearman_job_obj_handlers, zend_get_std_object_handlers(), sizeof(gearman_job_obj_handlers));
gearman_job_obj_handlers.offset = XtOffsetOf(gearman_job_obj, std);
/* XXX exception class */
INIT_CLASS_ENTRY(ce, "GearmanException", class_GearmanException_methods)
gearman_exception_ce = zend_register_internal_class_ex(&ce, zend_exception_get_default());
gearman_exception_ce->ce_flags |= ZEND_ACC_FINAL;
zend_declare_property_long(gearman_exception_ce, "code", sizeof("code")-1, 0, ZEND_ACC_PUBLIC);
/* These are automatically generated from gearman_constants.h using
const_gen.sh. Do not remove the CONST_GEN_* comments, this is how the
script locates the correct location to replace. */
/* CONST_GEN_START */
REGISTER_STRING_CONSTANT("GEARMAN_DEFAULT_TCP_HOST",
GEARMAN_DEFAULT_TCP_HOST,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_DEFAULT_TCP_PORT",
GEARMAN_DEFAULT_TCP_PORT,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_DEFAULT_SOCKET_TIMEOUT",
GEARMAN_DEFAULT_SOCKET_TIMEOUT,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_DEFAULT_SOCKET_SEND_SIZE",
GEARMAN_DEFAULT_SOCKET_SEND_SIZE,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_DEFAULT_SOCKET_RECV_SIZE",
GEARMAN_DEFAULT_SOCKET_RECV_SIZE,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_MAX_ERROR_SIZE",
GEARMAN_MAX_ERROR_SIZE,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_PACKET_HEADER_SIZE",
GEARMAN_PACKET_HEADER_SIZE,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_JOB_HANDLE_SIZE",
GEARMAN_JOB_HANDLE_SIZE,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_OPTION_SIZE",
GEARMAN_OPTION_SIZE,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_UNIQUE_SIZE",
GEARMAN_UNIQUE_SIZE,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_MAX_COMMAND_ARGS",
GEARMAN_MAX_COMMAND_ARGS,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_ARGS_BUFFER_SIZE",
GEARMAN_ARGS_BUFFER_SIZE,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_SEND_BUFFER_SIZE",
GEARMAN_SEND_BUFFER_SIZE,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_RECV_BUFFER_SIZE",
GEARMAN_RECV_BUFFER_SIZE,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_WORKER_WAIT_TIMEOUT",
GEARMAN_WORKER_WAIT_TIMEOUT,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_SUCCESS",
GEARMAN_SUCCESS,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_IO_WAIT",
GEARMAN_IO_WAIT,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_SHUTDOWN",
GEARMAN_SHUTDOWN,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_SHUTDOWN_GRACEFUL",
GEARMAN_SHUTDOWN_GRACEFUL,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_ERRNO",
GEARMAN_ERRNO,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_EVENT",
GEARMAN_EVENT,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_TOO_MANY_ARGS",
GEARMAN_TOO_MANY_ARGS,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_NO_ACTIVE_FDS",
GEARMAN_NO_ACTIVE_FDS,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_INVALID_MAGIC",
GEARMAN_INVALID_MAGIC,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_INVALID_COMMAND",
GEARMAN_INVALID_COMMAND,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_INVALID_PACKET",
GEARMAN_INVALID_PACKET,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_UNEXPECTED_PACKET",
GEARMAN_UNEXPECTED_PACKET,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_GETADDRINFO",
GEARMAN_GETADDRINFO,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_NO_SERVERS",
GEARMAN_NO_SERVERS,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_LOST_CONNECTION",
GEARMAN_LOST_CONNECTION,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_MEMORY_ALLOCATION_FAILURE",
GEARMAN_MEMORY_ALLOCATION_FAILURE,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_JOB_EXISTS",
GEARMAN_JOB_EXISTS,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_JOB_QUEUE_FULL",
GEARMAN_JOB_QUEUE_FULL,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_SERVER_ERROR",
GEARMAN_SERVER_ERROR,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_WORK_ERROR",
GEARMAN_WORK_ERROR,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_WORK_DATA",
GEARMAN_WORK_DATA,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_WORK_WARNING",
GEARMAN_WORK_WARNING,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_WORK_STATUS",
GEARMAN_WORK_STATUS,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_WORK_EXCEPTION",
GEARMAN_WORK_EXCEPTION,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_WORK_FAIL",
GEARMAN_WORK_FAIL,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_NOT_CONNECTED",
GEARMAN_NOT_CONNECTED,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COULD_NOT_CONNECT",
GEARMAN_COULD_NOT_CONNECT,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_SEND_IN_PROGRESS",
GEARMAN_SEND_IN_PROGRESS,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_RECV_IN_PROGRESS",
GEARMAN_RECV_IN_PROGRESS,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_NOT_FLUSHING",
GEARMAN_NOT_FLUSHING,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_DATA_TOO_LARGE",
GEARMAN_DATA_TOO_LARGE,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_INVALID_FUNCTION_NAME",
GEARMAN_INVALID_FUNCTION_NAME,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_INVALID_WORKER_FUNCTION",
GEARMAN_INVALID_WORKER_FUNCTION,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_NO_REGISTERED_FUNCTIONS",
GEARMAN_NO_REGISTERED_FUNCTIONS,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_NO_JOBS",
GEARMAN_NO_JOBS,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_ECHO_DATA_CORRUPTION",
GEARMAN_ECHO_DATA_CORRUPTION,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_NEED_WORKLOAD_FN",
GEARMAN_NEED_WORKLOAD_FN,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_PAUSE",
GEARMAN_PAUSE,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_UNKNOWN_STATE",
GEARMAN_UNKNOWN_STATE,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_PTHREAD",
GEARMAN_PTHREAD,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_PIPE_EOF",
GEARMAN_PIPE_EOF,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_QUEUE_ERROR",
GEARMAN_QUEUE_ERROR,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_FLUSH_DATA",
GEARMAN_FLUSH_DATA,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_SEND_BUFFER_TOO_SMALL",
GEARMAN_SEND_BUFFER_TOO_SMALL,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_IGNORE_PACKET",
GEARMAN_IGNORE_PACKET,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_UNKNOWN_OPTION",
GEARMAN_UNKNOWN_OPTION,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_TIMEOUT",
GEARMAN_TIMEOUT,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_MAX_RETURN",
GEARMAN_MAX_RETURN,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_VERBOSE_FATAL",
GEARMAN_VERBOSE_FATAL,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_VERBOSE_ERROR",
GEARMAN_VERBOSE_ERROR,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_VERBOSE_INFO",
GEARMAN_VERBOSE_INFO,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_VERBOSE_DEBUG",
GEARMAN_VERBOSE_DEBUG,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_VERBOSE_CRAZY",
GEARMAN_VERBOSE_CRAZY,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_VERBOSE_MAX",
GEARMAN_VERBOSE_MAX,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_NON_BLOCKING",
GEARMAN_NON_BLOCKING,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_DONT_TRACK_PACKETS",
GEARMAN_DONT_TRACK_PACKETS,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_CON_READY",
GEARMAN_CON_READY,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_CON_PACKET_IN_USE",
GEARMAN_CON_PACKET_IN_USE,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_CON_EXTERNAL_FD",
GEARMAN_CON_EXTERNAL_FD,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_CON_IGNORE_LOST_CONNECTION",
GEARMAN_CON_IGNORE_LOST_CONNECTION,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_CON_CLOSE_AFTER_FLUSH",
GEARMAN_CON_CLOSE_AFTER_FLUSH,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_CON_SEND_STATE_NONE",
GEARMAN_CON_SEND_STATE_NONE,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_CON_RECV_STATE_READ_DATA",
GEARMAN_CON_RECV_STATE_READ_DATA,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_TEXT",
GEARMAN_COMMAND_TEXT,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_CAN_DO",
GEARMAN_COMMAND_CAN_DO,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_CANT_DO",
GEARMAN_COMMAND_CANT_DO,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_RESET_ABILITIES",
GEARMAN_COMMAND_RESET_ABILITIES,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_PRE_SLEEP",
GEARMAN_COMMAND_PRE_SLEEP,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_UNUSED",
GEARMAN_COMMAND_UNUSED,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_NOOP",
GEARMAN_COMMAND_NOOP,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_SUBMIT_JOB",
GEARMAN_COMMAND_SUBMIT_JOB,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_JOB_CREATED",
GEARMAN_COMMAND_JOB_CREATED,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_GRAB_JOB",
GEARMAN_COMMAND_GRAB_JOB,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_NO_JOB",
GEARMAN_COMMAND_NO_JOB,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_JOB_ASSIGN",
GEARMAN_COMMAND_JOB_ASSIGN,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_WORK_STATUS",
GEARMAN_COMMAND_WORK_STATUS,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_WORK_COMPLETE",
GEARMAN_COMMAND_WORK_COMPLETE,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_WORK_FAIL",
GEARMAN_COMMAND_WORK_FAIL,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_GET_STATUS",
GEARMAN_COMMAND_GET_STATUS,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_ECHO_REQ",
GEARMAN_COMMAND_ECHO_REQ,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_ECHO_RES",
GEARMAN_COMMAND_ECHO_RES,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_SUBMIT_JOB_BG",
GEARMAN_COMMAND_SUBMIT_JOB_BG,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_ERROR",
GEARMAN_COMMAND_ERROR,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_STATUS_RES",
GEARMAN_COMMAND_STATUS_RES,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_SUBMIT_JOB_HIGH",
GEARMAN_COMMAND_SUBMIT_JOB_HIGH,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_SET_CLIENT_ID",
GEARMAN_COMMAND_SET_CLIENT_ID,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_CAN_DO_TIMEOUT",
GEARMAN_COMMAND_CAN_DO_TIMEOUT,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_ALL_YOURS",
GEARMAN_COMMAND_ALL_YOURS,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_WORK_EXCEPTION",
GEARMAN_COMMAND_WORK_EXCEPTION,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_OPTION_REQ",
GEARMAN_COMMAND_OPTION_REQ,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_OPTION_RES",
GEARMAN_COMMAND_OPTION_RES,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_WORK_DATA",
GEARMAN_COMMAND_WORK_DATA,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_WORK_WARNING",
GEARMAN_COMMAND_WORK_WARNING,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_GRAB_JOB_UNIQ",
GEARMAN_COMMAND_GRAB_JOB_UNIQ,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_JOB_ASSIGN_UNIQ",
GEARMAN_COMMAND_JOB_ASSIGN_UNIQ,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_SUBMIT_JOB_HIGH_BG",
GEARMAN_COMMAND_SUBMIT_JOB_HIGH_BG,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_SUBMIT_JOB_LOW",
GEARMAN_COMMAND_SUBMIT_JOB_LOW,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_SUBMIT_JOB_LOW_BG",
GEARMAN_COMMAND_SUBMIT_JOB_LOW_BG,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_SUBMIT_JOB_SCHED",
GEARMAN_COMMAND_SUBMIT_JOB_SCHED,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_SUBMIT_JOB_EPOCH",
GEARMAN_COMMAND_SUBMIT_JOB_EPOCH,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_COMMAND_MAX",
GEARMAN_COMMAND_MAX,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_TASK_STATE_NEW",
GEARMAN_TASK_STATE_NEW,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_TASK_STATE_SUBMIT",
GEARMAN_TASK_STATE_SUBMIT,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_TASK_STATE_WORKLOAD",
GEARMAN_TASK_STATE_WORKLOAD,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_TASK_STATE_WORK",
GEARMAN_TASK_STATE_WORK,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_TASK_STATE_CREATED",
GEARMAN_TASK_STATE_CREATED,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_TASK_STATE_DATA",
GEARMAN_TASK_STATE_DATA,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_TASK_STATE_WARNING",
GEARMAN_TASK_STATE_WARNING,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_TASK_STATE_STATUS",
GEARMAN_TASK_STATE_STATUS,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_TASK_STATE_COMPLETE",
GEARMAN_TASK_STATE_COMPLETE,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_TASK_STATE_EXCEPTION",
GEARMAN_TASK_STATE_EXCEPTION,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_TASK_STATE_FAIL",
GEARMAN_TASK_STATE_FAIL,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_TASK_STATE_FINISHED",
GEARMAN_TASK_STATE_FINISHED,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_JOB_PRIORITY_HIGH",
GEARMAN_JOB_PRIORITY_HIGH,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_JOB_PRIORITY_NORMAL",
GEARMAN_JOB_PRIORITY_NORMAL,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_JOB_PRIORITY_LOW",
GEARMAN_JOB_PRIORITY_LOW,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_JOB_PRIORITY_MAX",
GEARMAN_JOB_PRIORITY_MAX,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_CLIENT_ALLOCATED",
GEARMAN_CLIENT_ALLOCATED,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_CLIENT_NON_BLOCKING",
GEARMAN_CLIENT_NON_BLOCKING,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_CLIENT_TASK_IN_USE",
GEARMAN_CLIENT_TASK_IN_USE,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_CLIENT_UNBUFFERED_RESULT",
GEARMAN_CLIENT_UNBUFFERED_RESULT,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_CLIENT_NO_NEW",
GEARMAN_CLIENT_NO_NEW,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_CLIENT_FREE_TASKS",
GEARMAN_CLIENT_FREE_TASKS,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_CLIENT_STATE_IDLE",
GEARMAN_CLIENT_STATE_IDLE,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_CLIENT_STATE_NEW",
GEARMAN_CLIENT_STATE_NEW,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_CLIENT_STATE_SUBMIT",
GEARMAN_CLIENT_STATE_SUBMIT,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_CLIENT_STATE_PACKET",
GEARMAN_CLIENT_STATE_PACKET,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_WORKER_ALLOCATED",
GEARMAN_WORKER_ALLOCATED,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_WORKER_NON_BLOCKING",
GEARMAN_WORKER_NON_BLOCKING,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_WORKER_PACKET_INIT",
GEARMAN_WORKER_PACKET_INIT,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_WORKER_GRAB_JOB_IN_USE",
GEARMAN_WORKER_GRAB_JOB_IN_USE,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_WORKER_PRE_SLEEP_IN_USE",
GEARMAN_WORKER_PRE_SLEEP_IN_USE,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_WORKER_WORK_JOB_IN_USE",
GEARMAN_WORKER_WORK_JOB_IN_USE,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_WORKER_CHANGE",
GEARMAN_WORKER_CHANGE,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_WORKER_GRAB_UNIQ",
GEARMAN_WORKER_GRAB_UNIQ,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_WORKER_TIMEOUT_RETURN",
GEARMAN_WORKER_TIMEOUT_RETURN,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_WORKER_STATE_START",
GEARMAN_WORKER_STATE_START,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_WORKER_STATE_FUNCTION_SEND",
GEARMAN_WORKER_STATE_FUNCTION_SEND,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_WORKER_STATE_CONNECT",
GEARMAN_WORKER_STATE_CONNECT,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_WORKER_STATE_GRAB_JOB_SEND",
GEARMAN_WORKER_STATE_GRAB_JOB_SEND,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_WORKER_STATE_GRAB_JOB_RECV",
GEARMAN_WORKER_STATE_GRAB_JOB_RECV,
CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("GEARMAN_WORKER_STATE_PRE_SLEEP",
GEARMAN_WORKER_STATE_PRE_SLEEP,
CONST_CS | CONST_PERSISTENT);
/* CONST_GEN_STOP */
return SUCCESS;
}
PHP_MSHUTDOWN_FUNCTION(gearman) {
return SUCCESS;
}
PHP_MINFO_FUNCTION(gearman) {
char port_str[6];
php_info_print_table_start();
php_info_print_table_header(2, "gearman support", "enabled");
php_info_print_table_row(2, "extension version", PHP_GEARMAN_VERSION);
php_info_print_table_row(2, "libgearman version", gearman_version());
php_info_print_table_row(2, "Default TCP Host", GEARMAN_DEFAULT_TCP_HOST);
snprintf(port_str, 6, "%u", GEARMAN_DEFAULT_TCP_PORT);
php_info_print_table_row(2, "Default TCP Port", port_str);
php_info_print_table_end();
}
/* Module config struct. */
zend_module_entry gearman_module_entry = {
STANDARD_MODULE_HEADER,
"gearman",
ext_functions,
PHP_MINIT(gearman),
PHP_MSHUTDOWN(gearman),
NULL,
NULL,
PHP_MINFO(gearman),
PHP_GEARMAN_VERSION,
STANDARD_MODULE_PROPERTIES
};
#ifdef COMPILE_DL_GEARMAN
ZEND_GET_MODULE(gearman)
#endif
gearman-2.1.2/php_gearman.h 0000644 0001750 0001750 00000006156 14603537402 015202 0 ustar rasmus rasmus /*
* Gearman PHP Extension
*
* Copyright (C) 2008 James M. Luedke ,
* Eric Day
* All rights reserved.
*
* Use and distribution licensed under the PHP license. See
* the LICENSE file in this directory for full text.
*/
#ifndef __PHP_GEARMAN_H
#define __PHP_GEARMAN_H
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "zend_exceptions.h"
#include "zend_interfaces.h"
#include
#include
#include
/* module version */
#define PHP_GEARMAN_VERSION "2.1.2"
extern zend_module_entry gearman_module_entry;
#define phpext_gearman_ptr &gearman_module_entry
typedef enum {
GEARMAN_OBJ_CREATED = (1 << 0)
} gearman_obj_flags_t;
extern zend_class_entry *gearman_exception_ce;
#define GEARMAN_EXCEPTION(__error, __error_code) { \
zend_throw_exception(gearman_exception_ce, __error, __error_code); \
return; \
}
void *_php_malloc(size_t size, void *arg);
void _php_free(void *ptr, void *arg);
/* backward compat macros */
#ifndef ZVAL_EMPTY_ARRAY
#define ZVAL_EMPTY_ARRAY(value) array_init(value)
#endif
#ifndef RETVAL_EMPTY_ARRAY
#define RETVAL_EMPTY_ARRAY() ZVAL_EMPTY_ARRAY(return_value)
#endif
#ifndef RETURN_EMPTY_ARRAY
#define RETURN_EMPTY_ARRAY() do { RETVAL_EMPTY_ARRAY(); return; } while (0)
#endif
#ifndef IS_MIXED
# define IS_MIXED 0
#endif
#ifndef ZEND_ARG_INFO_WITH_DEFAULT_VALUE
#define ZEND_ARG_INFO_WITH_DEFAULT_VALUE(pass_by_ref, name, default_value) \
ZEND_ARG_INFO(pass_by_ref, name)
#endif
#if PHP_VERSION_ID < 70200
#undef ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX
#define ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, class_name, allow_null) \
static const zend_internal_arg_info name[] = { \
{ (const char*)(zend_uintptr_t)(required_num_args), ( #class_name ), 0, return_reference, allow_null, 0 },
#endif
#ifndef ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX
# define ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(name, return_reference, required_num_args, class_name, allow_null) \
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, class_name, allow_null)
#endif
#ifndef ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX
# define ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(name, return_reference, num_args, type) \
ZEND_BEGIN_ARG_INFO_EX(name, 0, return_reference, num_args)
#endif
#ifndef ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX
# define ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(name, return_reference, required_num_args, class_name, type) \
ZEND_BEGIN_ARG_INFO_EX(name, 0, return_reference, required_num_args)
#endif
#ifndef ZEND_ARG_TYPE_MASK
# define ZEND_ARG_TYPE_MASK(pass_by_ref, name, type_mask, default_value) \
ZEND_ARG_TYPE_INFO(pass_by_ref, name, 0, 0)
#endif
#ifndef ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE
# define ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(pass_by_ref, name, type_hint, allow_null, default_value) \
ZEND_ARG_TYPE_INFO(pass_by_ref, name, type_hint, allow_null)
#endif
#endif /* __PHP_GEARMAN_H */
gearman-2.1.2/php_gearman_client.c 0000644 0001750 0001750 00000127503 14603537402 016533 0 ustar rasmus rasmus /*
* Gearman PHP Extension
*
* Copyright (C) 2008 James M. Luedke ,
* Eric Day
* All rights reserved.
*
* Use and distribution licensed under the PHP license. See
* the LICENSE file in this directory for full text.
*/
#include "php_gearman_task.h"
#include "php_gearman_client.h"
inline gearman_client_obj *gearman_client_fetch_object(zend_object *obj) {
return (gearman_client_obj *)((char*)(obj) - XtOffsetOf(gearman_client_obj, std));
}
static void gearman_client_ctor(INTERNAL_FUNCTION_PARAMETERS) {
gearman_client_obj *client;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
client = Z_GEARMAN_CLIENT_P(return_value);
if (gearman_client_create(&(client->client)) == NULL) {
GEARMAN_EXCEPTION("Memory allocation failure", 0);
}
client->flags |= GEARMAN_CLIENT_OBJ_CREATED;
gearman_client_add_options(&(client->client), GEARMAN_CLIENT_FREE_TASKS);
gearman_client_set_workload_malloc_fn(&(client->client), _php_malloc, NULL);
gearman_client_set_workload_free_fn(&(client->client), _php_free, NULL);
gearman_client_set_task_context_free_fn(&(client->client), _php_task_free);
}
/* {{{ proto false|object gearman_client_create()
Returns a GearmanClient object */
PHP_FUNCTION(gearman_client_create) {
if (object_init_ex(return_value, gearman_client_ce) != SUCCESS) {
php_error_docref(NULL, E_WARNING, "Object creation failure.");
RETURN_FALSE;
}
gearman_client_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
inline zend_object *gearman_client_obj_new(zend_class_entry *ce) {
gearman_client_obj *intern = ecalloc(1,
sizeof(gearman_client_obj) +
zend_object_properties_size(ce));
zend_object_std_init(&(intern->std), ce);
object_properties_init(&intern->std, ce);
array_init(&intern->task_list);
intern->created_tasks = 0;
intern->std.handlers = &gearman_client_obj_handlers;
return &intern->std;
}
/* {{{ proto object GearmanClient::__construct()
Returns a GearmanClient object */
PHP_METHOD(GearmanClient, __construct)
{
return_value = getThis();
gearman_client_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
/* }}} */
/* {{{ proto object GearmanClient::__destruct()
cleans up GearmanClient object */
PHP_METHOD(GearmanClient, __destruct)
{
char *context = NULL;
gearman_client_obj *intern = Z_GEARMAN_CLIENT_P(getThis());
if (!intern) {
return;
}
if (intern->flags & GEARMAN_CLIENT_OBJ_CREATED) {
context = gearman_client_context(&(intern->client));
efree(context);
gearman_client_free(&intern->client);
intern->flags &= ~GEARMAN_CLIENT_OBJ_CREATED;
}
}
/* }}} */
void gearman_client_free_obj(zend_object *object) {
gearman_client_obj *intern = gearman_client_fetch_object(object);
if (!intern) {
return;
}
// Clear Callbacks
zval_dtor(&intern->zworkload_fn);
zval_dtor(&intern->zcreated_fn);
zval_dtor(&intern->zdata_fn);
zval_dtor(&intern->zwarning_fn);
zval_dtor(&intern->zstatus_fn);
zval_dtor(&intern->zcomplete_fn);
zval_dtor(&intern->zexception_fn);
zval_dtor(&intern->zfail_fn);
zval_dtor(&intern->task_list);
zend_object_std_dtor(&intern->std);
}
/* {{{ proto int gearman_client_return_code()
get last gearman_return_t */
PHP_FUNCTION(gearman_client_return_code)
{
gearman_client_obj *obj;
zval *zobj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_client_ce) == FAILURE) {
RETURN_NULL();
}
obj = Z_GEARMAN_CLIENT_P(zobj);
RETURN_LONG(obj->ret);
}
/* }}} */
/* {{{ proto false|string gearman_client_error()
Return an error string for the last error encountered. */
PHP_FUNCTION(gearman_client_error) {
char *error = NULL;
gearman_client_obj *obj;
zval *zobj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_client_ce) == FAILURE) {
RETURN_NULL();
}
obj = Z_GEARMAN_CLIENT_P(zobj);
error = (char *)gearman_client_error(&(obj->client));
if (error) {
RETURN_STRING(error);
}
RETURN_FALSE;
}
/* }}} */
/* {{{ proto int gearman_client_get_errno()
Value of errno in the case of a GEARMAN_ERRNO return value. */
PHP_FUNCTION(gearman_client_get_errno) {
gearman_client_obj *obj;
zval *zobj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_client_ce) == FAILURE) {
RETURN_NULL();
}
obj = Z_GEARMAN_CLIENT_P(zobj);
RETURN_LONG(gearman_client_errno(&(obj->client)));
}
/* }}} */
/* {{{ proto int gearman_client_options()
Get options for a client structure. */
PHP_FUNCTION(gearman_client_options) {
gearman_client_obj *obj;
zval *zobj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_client_ce) == FAILURE) {
RETURN_NULL();
}
obj = Z_GEARMAN_CLIENT_P(zobj);
RETURN_LONG(gearman_client_options(&(obj->client)));
}
/* }}} */
/* {{{ proto bool gearman_client_set_options(constant option)
Set options for a client structure.
NOTE: this is deprecated in gearmand */
PHP_FUNCTION(gearman_client_set_options) {
zend_long options;
gearman_client_obj *obj;
zval *zobj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &zobj, gearman_client_ce, &options) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_CLIENT_P(zobj);
gearman_client_set_options(&(obj->client), options);
RETURN_TRUE;
}
/* }}} */
/* {{{ proto bool GearmanClient::addOptions(constant option)
Set options for a client structure. */
PHP_FUNCTION(gearman_client_add_options) {
zend_long options;
gearman_client_obj *obj;
zval *zobj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &zobj, gearman_client_ce, &options) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_CLIENT_P(zobj);
gearman_client_add_options(&(obj->client), options);
RETURN_TRUE;
}
/* }}} */
/* {{{ proto bool GearmanClient::removeOptions(constant option)
Set options for a client structure. */
PHP_FUNCTION(gearman_client_remove_options) {
zend_long options;
gearman_client_obj *obj;
zval *zobj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &zobj, gearman_client_ce, &options) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_CLIENT_P(zobj);
gearman_client_remove_options(&(obj->client), options);
RETURN_TRUE;
}
/* }}} */
/* {{{ proto int GearmanClient::timeout()
Get current socket I/O activity timeout value */
PHP_FUNCTION(gearman_client_timeout) {
gearman_client_obj *obj;
zval *zobj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_client_ce) == FAILURE) {
RETURN_NULL();
}
obj = Z_GEARMAN_CLIENT_P(zobj);
RETURN_LONG(gearman_client_timeout(&(obj->client)));
}
/* }}} */
/* {{{ proto bool gearman_client_set_timeout(object, constant timeout)
Set timeout for a client structure. */
PHP_FUNCTION(gearman_client_set_timeout) {
zend_long timeout;
gearman_client_obj *obj;
zval *zobj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &zobj, gearman_client_ce, &timeout) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_CLIENT_P(zobj);
gearman_client_set_timeout(&(obj->client), timeout);
RETURN_TRUE;
}
/* }}} */
/* {{{ proto bool gearman_client_add_server(object client [, string host [, int
* port [, bool setupExceptionHandler ]]])
Add a job server to a client. This goes into a list of servers than can be used to run tasks. No socket I/O happens here, it is just added to a list. */
PHP_FUNCTION(gearman_client_add_server) {
char *host = NULL;
size_t host_len = 0;
zend_long port = 0;
zend_bool setupExceptionHandler = 1;
gearman_client_obj *obj;
zval *zobj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|slb",
&zobj,
gearman_client_ce,
&host,
&host_len,
&port,
&setupExceptionHandler) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_CLIENT_P(zobj);
obj->ret = gearman_client_add_server(&(obj->client), host, port);
if (obj->ret != GEARMAN_SUCCESS) {
php_error_docref(NULL, E_WARNING, "%s",
gearman_client_error(&(obj->client)));
RETURN_FALSE;
}
if (setupExceptionHandler && !gearman_client_set_server_option(&(obj->client), "exceptions", (sizeof("exceptions") - 1))) {
GEARMAN_EXCEPTION("Failed to set exception option", 0);
}
RETURN_TRUE;
}
/* }}} */
/* {{{ proto bool gearman_client_add_servers(object client [, string servers [, bool setupExceptionHandler ]])
Add a list of job servers to a client. This goes into a list of servers that can be used to run tasks. No socket I/O happens here, it is just added to a list. */
PHP_FUNCTION(gearman_client_add_servers) {
char *servers = NULL;
size_t servers_len = 0;
zend_bool setupExceptionHandler = 1;
gearman_client_obj *obj;
zval *zobj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|sb",
&zobj,
gearman_client_ce,
&servers,
&servers_len,
&setupExceptionHandler) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_CLIENT_P(zobj);
obj->ret = gearman_client_add_servers(&(obj->client), servers);
if (obj->ret != GEARMAN_SUCCESS) {
php_error_docref(NULL, E_WARNING, "%s",
gearman_client_error(&(obj->client)));
RETURN_FALSE;
}
if (setupExceptionHandler && !gearman_client_set_server_option(&(obj->client), "exceptions", (sizeof("exceptions") - 1))) {
GEARMAN_EXCEPTION("Failed to set exception option", 0);
}
RETURN_TRUE;
}
/* }}} */
/* {{{ proto bool GearmanClient::wait()
Wait for I/O activity on all connections in a client. */
PHP_FUNCTION(gearman_client_wait) {
gearman_client_obj *obj;
zval *zobj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_client_ce) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_CLIENT_P(zobj);
obj->ret = gearman_client_wait(&(obj->client));
if (! PHP_GEARMAN_CLIENT_RET_OK(obj->ret)) {
if (obj->ret != GEARMAN_TIMEOUT) {
php_error_docref(NULL, E_WARNING, "%s",
gearman_client_error(&(obj->client)));
}
RETURN_FALSE;
}
RETURN_TRUE;
}
/* }}} */
/* {{{ proto string gearman_client_do_work_handler(void *add_task_func, object client, string function, zval workload [, string unique ])
Run a task, high/normal/low dependent upon do_work_func */
static void gearman_client_do_work_handler(void* (*do_work_func)(
gearman_client_st *client,
const char *function_name,
const char *unique,
const void *workload,
size_t workload_size,
size_t *result_size,
gearman_return_t *ret_ptr
),
INTERNAL_FUNCTION_PARAMETERS) {
char *function_name;
size_t function_name_len;
char *workload;
size_t workload_len;
char *unique = NULL;
size_t unique_len = 0;
void *result;
size_t result_size = 0;
gearman_client_obj *obj;
zval *zobj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oss|s", &zobj, gearman_client_ce,
&function_name, &function_name_len,
&workload, &workload_len,
&unique, &unique_len) == FAILURE) {
RETURN_EMPTY_STRING();
}
obj = Z_GEARMAN_CLIENT_P(zobj);
result = (char *)(*do_work_func)(
&(obj->client),
function_name,
unique,
workload,
(size_t)workload_len,
&result_size,
&(obj)->ret
);
if (! PHP_GEARMAN_CLIENT_RET_OK(obj->ret)) {
php_error_docref(NULL, E_WARNING, "%s", gearman_client_error(&(obj->client)));
RETURN_EMPTY_STRING();
}
/* NULL results are valid */
if (! result) {
RETURN_EMPTY_STRING();
}
ZVAL_STRINGL(return_value, (char *)result, (long)result_size);
efree(result);
}
/* }}} */
/* {{{ proto string GearmanClient::doNormal(string function, string workload [, string unique ])
Run a single task and return an allocated result. */
PHP_FUNCTION(gearman_client_do_normal) {
gearman_client_do_work_handler(gearman_client_do, INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
/* }}} */
/* {{{ proto string GearmanClient::doHigh(object client, string function, string workload [, string unique ])
Run a high priority task and return an allocated result. */
PHP_FUNCTION(gearman_client_do_high) {
gearman_client_do_work_handler(gearman_client_do_high, INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
/* }}} */
/* {{{ proto string GearmanClient::doLow(object client, string function, string workload [, string unique ])
Run a low priority task and return an allocated result. */
PHP_FUNCTION(gearman_client_do_low) {
gearman_client_do_work_handler(gearman_client_do_low, INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
/* }}} */
/* {{{ proto string gearman_client_do_background_work_handler(void *add_task_func, object client, string function, zval workload [, string unique ])
Run a task in the background, high/normal/low dependent upon do_work_func */
static void gearman_client_do_background_work_handler(gearman_return_t (*do_background_work_func)(
gearman_client_st *client,
const char *function_name,
const char *unique,
const void *workload,
size_t workload_size,
gearman_job_handle_t job_handle
),
INTERNAL_FUNCTION_PARAMETERS) {
char *function_name;
size_t function_name_len;
char *workload;
size_t workload_len;
char *unique = NULL;
size_t unique_len = 0;
zend_string *job_handle;
gearman_client_obj *obj;
zval *zobj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oss|s!", &zobj, gearman_client_ce,
&function_name, &function_name_len,
&workload, &workload_len,
&unique, &unique_len) == FAILURE) {
RETURN_EMPTY_STRING();
}
obj = Z_GEARMAN_CLIENT_P(zobj);
job_handle = zend_string_alloc(GEARMAN_JOB_HANDLE_SIZE-1, 0);
obj->ret = (*do_background_work_func)(
&(obj->client),
(char *)function_name,
(char *)unique,
(void *)workload,
(size_t)workload_len,
job_handle->val
);
ZSTR_LEN(job_handle) = strnlen(ZSTR_VAL(job_handle), GEARMAN_JOB_HANDLE_SIZE-1);
if (! PHP_GEARMAN_CLIENT_RET_OK(obj->ret)) {
php_error_docref(NULL, E_WARNING, "%s",
gearman_client_error(&(obj->client)));
zend_string_release(job_handle);
RETURN_EMPTY_STRING();
}
if (! job_handle) {
zend_string_release(job_handle);
RETURN_EMPTY_STRING();
}
RETURN_STR(job_handle);
}
/* }}} */
/* {{{ proto string GearmanClient::doBackground(string function, string workload [, string unique ])
Run a task in the background. */
PHP_FUNCTION(gearman_client_do_background) {
gearman_client_do_background_work_handler(gearman_client_do_background, INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
/* }}} */
/* {{{ proto string GearmanClient::doHighBackground(string function, string workload [, string unique ])
Run a high priority task in the background. */
PHP_FUNCTION(gearman_client_do_high_background) {
gearman_client_do_background_work_handler(gearman_client_do_high_background, INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
/* }}} */
/* {{{ proto string GearmanClient::doLowBackground(string function, string workload [, string unique ])
Run a low priority task in the background. */
PHP_FUNCTION(gearman_client_do_low_background) {
gearman_client_do_background_work_handler(gearman_client_do_low_background, INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
/* }}} */
/* {{{ proto string GearmanClient::doJobHandle()
Get the job handle for the running task. This should be used between repeated gearman_client_do_normal() and gearman_client_do_high() calls to get information. */
PHP_FUNCTION(gearman_client_do_job_handle) {
gearman_client_obj *obj;
zval *zobj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_client_ce) == FAILURE) {
RETURN_EMPTY_STRING();
}
obj = Z_GEARMAN_CLIENT_P(zobj);
RETURN_STRING((char *)gearman_client_do_job_handle(&(obj->client)));
}
/* }}} */
/* {{{ proto array GearmanClient::doStatus()
Get the status for the running task. This should be used between repeated gearman_client_do() and gearman_client_do_high() calls to get information. */
PHP_FUNCTION(gearman_client_do_status) {
uint32_t numerator;
uint32_t denominator;
gearman_client_obj *obj;
zval *zobj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_client_ce) == FAILURE) {
RETURN_EMPTY_ARRAY();
}
obj = Z_GEARMAN_CLIENT_P(zobj);
gearman_client_do_status(&(obj->client), &numerator, &denominator);
array_init(return_value);
add_next_index_long(return_value, (long) numerator);
add_next_index_long(return_value, (long) denominator);
}
/* }}} */
/* {{{ proto array GearmanClient::jobStatus(string job_handle)
Get the status for a backgound job. */
PHP_FUNCTION(gearman_client_job_status) {
char *job_handle;
size_t job_handle_len;
bool is_known;
bool is_running;
uint32_t numerator;
uint32_t denominator;
gearman_client_obj *obj;
zval *zobj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &zobj, gearman_client_ce,
&job_handle, &job_handle_len) == FAILURE) {
RETURN_EMPTY_ARRAY();
}
obj = Z_GEARMAN_CLIENT_P(zobj);
obj->ret = gearman_client_job_status(&(obj->client), job_handle,
&is_known, &is_running,
&numerator, &denominator);
if (obj->ret != GEARMAN_SUCCESS && obj->ret != GEARMAN_IO_WAIT) {
php_error_docref(NULL, E_WARNING, "%s",
gearman_client_error(&(obj->client)));
}
array_init(return_value);
add_next_index_bool(return_value, is_known);
add_next_index_bool(return_value, is_running);
add_next_index_long(return_value, (long) numerator);
add_next_index_long(return_value, (long) denominator);
}
/* }}} */
/* {{{ proto array GearmanClient::jobStatusByUniqueKey(string unique_key)
Get the status for a backgound job using the unique key passed in during job submission, rather than job handle. */
PHP_FUNCTION(gearman_client_job_status_by_unique_key) {
char *unique_key;
size_t unique_key_len;
gearman_client_obj *obj;
zval *zobj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &zobj, gearman_client_ce,
&unique_key, &unique_key_len) == FAILURE) {
RETURN_EMPTY_ARRAY();
}
obj = Z_GEARMAN_CLIENT_P(zobj);
gearman_status_t status = gearman_client_unique_status(&(obj->client), unique_key, unique_key_len);
gearman_return_t rc = gearman_status_return(status);
if (rc != GEARMAN_SUCCESS && rc != GEARMAN_IO_WAIT) {
php_error_docref(NULL, E_WARNING, "%s",
gearman_client_error(&(obj->client)));
}
array_init(return_value);
add_next_index_bool(return_value, gearman_status_is_known(status));
add_next_index_bool(return_value, gearman_status_is_running(status));
add_next_index_long(return_value, (long) gearman_status_numerator(status));
add_next_index_long(return_value, (long) gearman_status_denominator(status));
}
/* }}} */
/* {{{ proto bool GearmanClient::ping(string workload)
Send data to all job servers to see if they send it back. */
PHP_FUNCTION(gearman_client_ping) {
char *workload;
size_t workload_len;
gearman_client_obj *obj;
zval *zobj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &zobj, gearman_client_ce, &workload, &workload_len) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_CLIENT_P(zobj);
obj->ret = gearman_client_echo(&(obj->client), workload, (size_t)workload_len);
if (obj->ret != GEARMAN_SUCCESS && obj->ret != GEARMAN_IO_WAIT) {
php_error_docref(NULL, E_WARNING, "%s",
gearman_client_error(&(obj->client)));
RETURN_FALSE;
}
RETURN_TRUE;
}
/* }}} */
/* {{{ proto false|object gearman_client_add_task_handler(void *add_task_func, object client, string function, zval workload [, string unique ])
Add a task to be run in parallel, background or not, high/normal/low dependent upon add_task_func. */
static void gearman_client_add_task_handler(gearman_task_st* (*add_task_func)(
gearman_client_st *client,
gearman_task_st *task,
void *context,
const char *function_name,
const char *unique,
const void *workload,
size_t workload_size,
gearman_return_t *ret_ptr),
INTERNAL_FUNCTION_PARAMETERS) {
zval *zworkload;
zval *zdata = NULL;
gearman_task_obj *task;
char *unique;
char *function_name;
size_t unique_len = 0;
size_t function_name_len = 0;
gearman_client_obj *obj;
zval *zobj;
// TODO - the documentation on php.net differs from this
// As found, this doesn't allow for user to pass in context.
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Osz|zs", &zobj, gearman_client_ce,
&function_name, &function_name_len,
&zworkload,
&zdata,
&unique, &unique_len
) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_CLIENT_P(zobj);
if (unique_len == 0) {
unique = NULL;
}
if (Z_TYPE_P(zworkload) != IS_STRING) {
convert_to_string(zworkload);
}
/* get a task object, and prepare it for return */
if (object_init_ex(return_value, gearman_task_ce) != SUCCESS) {
php_error_docref(NULL, E_WARNING, "GearmanTask Object creation failure.");
RETURN_FALSE;
}
task = Z_GEARMAN_TASK_P(return_value);
if (zdata) {
ZVAL_COPY(&task->zdata, zdata);
}
ZVAL_COPY(&task->zworkload, zworkload);
/* need to store a ref to the client for later access to cb's */
ZVAL_COPY(&task->zclient, zobj);
/* add the task */
task->task = (*add_task_func)(
&(obj->client),
task->task,
(void *)task,
function_name,
unique,
Z_STRVAL_P(zworkload),
(size_t) Z_STRLEN_P(zworkload),
&obj->ret
);
if (obj->ret != GEARMAN_SUCCESS) {
php_error_docref(NULL, E_WARNING, "%s",
gearman_client_error(&(obj->client)));
RETURN_FALSE;
}
task->flags |= GEARMAN_TASK_OBJ_CREATED;
task->task_id = ++obj->created_tasks;
// prepend task to list of tasks on client obj
Z_ADDREF_P(return_value);
add_index_zval(&obj->task_list, task->task_id, return_value);
}
/* }}} */
/* {{{ proto false|object GearmanClient::addTask(string function, zval workload [, string unique ])
Add a task to be run in parallel. */
PHP_FUNCTION(gearman_client_add_task) {
gearman_client_add_task_handler(gearman_client_add_task, INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
/* }}} */
/* {{{ proto false|object GearmanClient::addTaskHigh(string function, zval workload [, string unique ])
Add a high priority task to be run in parallel. */
PHP_FUNCTION(gearman_client_add_task_high) {
gearman_client_add_task_handler(gearman_client_add_task_high, INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
/* }}} */
/* {{{ proto false|object GearmanClient::addTaskLow(string function, zval workload [, string unique ])
Add a low priority task to be run in parallel. */
PHP_FUNCTION(gearman_client_add_task_low) {
gearman_client_add_task_handler(gearman_client_add_task_low, INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
/* }}} */
/* {{{ proto false|object GearmanClient::addTaskBackground(string function, zval workload [, string unique ])
Add a background task to be run in parallel. */
PHP_FUNCTION(gearman_client_add_task_background) {
gearman_client_add_task_handler(gearman_client_add_task_background, INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
/* }}} */
/* {{{ proto false|object GearmanClient::addTaskHighBackground(string function, zval workload [, string unique ])
Add a high priority background task to be run in parallel. */
PHP_FUNCTION(gearman_client_add_task_high_background) {
gearman_client_add_task_handler(gearman_client_add_task_high_background, INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
/* }}} */
/* {{{ proto false|object GearmanClient::addTaskLowBackground(string function, zval workload [, string unique ])
Add a low priority background task to be run in parallel. */
PHP_FUNCTION(gearman_client_add_task_low_background) {
gearman_client_add_task_handler(gearman_client_add_task_low_background, INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
/* }}} */
/* {{{ proto bool gearman_client_run_tasks(object client)
Run tasks that have been added in parallel */
PHP_FUNCTION(gearman_client_run_tasks) {
gearman_client_obj *obj;
zval *zobj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_client_ce) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_CLIENT_P(zobj);
obj->ret = gearman_client_run_tasks(&(obj->client));
if (! PHP_GEARMAN_CLIENT_RET_OK(obj->ret)) {
php_error_docref(NULL, E_WARNING, "%s",
gearman_client_error(&(obj->client)));
RETURN_FALSE;
}
RETURN_TRUE;
}
/* }}} */
/* this function is used to request status information from the gearmand
* server. it will then call your predefined status callback, passing
* zdata/context to it */
/* {{{ proto false|object gearman_client_add_task_status(object client, string job_handle [, zval data])
Add task to get the status for a backgound task in parallel. */
PHP_FUNCTION(gearman_client_add_task_status) {
zval *zdata = NULL;
char *job_handle;
size_t job_handle_len = 0;
gearman_client_obj *obj;
zval *zobj;
gearman_task_obj *task;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os|z", &zobj, gearman_client_ce,
&job_handle, &job_handle_len,
&zdata
) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_CLIENT_P(zobj);
/* get a task object, and prepare it for return */
if (object_init_ex(return_value, gearman_task_ce) != SUCCESS) {
php_error_docref(NULL, E_WARNING, "GearmanTask Object creation failure.");
RETURN_FALSE;
}
task = Z_GEARMAN_TASK_P(return_value);
if (zdata) {
ZVAL_COPY(&task->zdata, zdata);
}
/* need to store a ref to the client for later access to cb's */
ZVAL_COPY(&task->zclient, zobj);
/* add the task */
task->task = gearman_client_add_task_status(&(obj->client),
task->task,
(void *)task,
job_handle,
&obj->ret
);
if (obj->ret != GEARMAN_SUCCESS) {
php_error_docref(NULL, E_WARNING, "%s",
gearman_client_error(&(obj->client)));
RETURN_FALSE;
}
task->flags |= GEARMAN_TASK_OBJ_CREATED;
// prepend task to list of tasks on client obj
Z_ADDREF_P(return_value);
add_next_index_zval(&obj->task_list, return_value);
}
/* }}} */
/* {{{ proto bool GearmanClient::setWorkloadCallback(callback function)
Callback function when workload data needs to be sent for a task. */
PHP_FUNCTION(gearman_client_set_workload_callback) {
zval *zworkload_fn;
zend_string *callable = NULL;
gearman_client_obj *obj;
zval *zobj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz", &zobj, gearman_client_ce,
&zworkload_fn
) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_CLIENT_P(zobj);
/* check that the function is callable */
if (! zend_is_callable(zworkload_fn, 0, &callable)) {
php_error_docref(NULL, E_WARNING, "function %s is not callable", callable->val);
zend_string_release(callable);
RETURN_FALSE;
}
zend_string_release(callable);
/* Defining callback again? Clean up old one first */
if (!Z_ISUNDEF(obj->zworkload_fn)) {
zval_dtor(&obj->zworkload_fn);
}
/* store the cb in client object */
ZVAL_COPY(&obj->zworkload_fn, zworkload_fn);
/* set the callback for php */
gearman_client_set_workload_fn(&(obj->client), _php_task_workload_fn);
RETURN_TRUE;
}
/* }}} */
/* {{{ proto bool GearmanClient::setCreatedCallback(callback function)
Callback function when workload data needs to be sent for a task. */
PHP_FUNCTION(gearman_client_set_created_callback) {
zval *zcreated_fn;
zend_string *callable = NULL;
gearman_client_obj *obj;
zval *zobj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz", &zobj, gearman_client_ce,
&zcreated_fn
) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_CLIENT_P(zobj);
/* check that the function is callable */
if (! zend_is_callable(zcreated_fn, 0, &callable)) {
php_error_docref(NULL, E_WARNING, "function %s is not callable", callable->val);
zend_string_release(callable);
RETURN_FALSE;
}
zend_string_release(callable);
/* Defining callback again? Clean up old one first */
if (!Z_ISUNDEF(obj->zcreated_fn)) {
zval_dtor(&obj->zcreated_fn);
}
/* store the cb in client object */
ZVAL_COPY(&obj->zcreated_fn, zcreated_fn);
/* set the callback for php */
gearman_client_set_created_fn(&(obj->client), _php_task_created_fn);
RETURN_TRUE;
}
/* }}} */
/* {{{ proto bool GearmanClient::setDataCallback(callback function)
Callback function when there is a data packet for a task. */
PHP_FUNCTION(gearman_client_set_data_callback) {
zval *zdata_fn;
zend_string *callable = NULL;
gearman_client_obj *obj;
zval *zobj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz", &zobj, gearman_client_ce,
&zdata_fn
) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_CLIENT_P(zobj);
/* check that the function is callable */
if (! zend_is_callable(zdata_fn, 0, &callable)) {
php_error_docref(NULL, E_WARNING, "function %s is not callable", callable->val);
zend_string_release(callable);
RETURN_FALSE;
}
zend_string_release(callable);
/* Defining callback again? Clean up old one first */
if (!Z_ISUNDEF(obj->zdata_fn)) {
zval_dtor(&obj->zdata_fn);
}
/* store the cb in client object */
ZVAL_COPY(&obj->zdata_fn, zdata_fn);
/* set the callback for php */
gearman_client_set_data_fn(&(obj->client), _php_task_data_fn);
RETURN_TRUE;
}
/* }}} */
/* {{{ proto bool GearmanClient::setWarningCallback(callback function)
Callback function when there is a warning packet for a task. */
PHP_FUNCTION(gearman_client_set_warning_callback) {
zval *zwarning_fn;
zend_string *callable = NULL;
gearman_client_obj *obj;
zval *zobj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz", &zobj, gearman_client_ce,
&zwarning_fn
) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_CLIENT_P(zobj);
/* check that the function is callable */
if (! zend_is_callable(zwarning_fn, 0, &callable)) {
php_error_docref(NULL, E_WARNING, "function %s is not callable", callable->val);
zend_string_release(callable);
RETURN_FALSE;
}
zend_string_release(callable);
/* Defining callback again? Clean up old one first */
if (!Z_ISUNDEF(obj->zwarning_fn)) {
zval_dtor(&obj->zwarning_fn);
}
/* store the cb in client object */
ZVAL_COPY(&obj->zwarning_fn, zwarning_fn);
/* set the callback for php */
gearman_client_set_warning_fn(&(obj->client), _php_task_warning_fn);
RETURN_TRUE;
}
/* }}} */
/* {{{ proto bool GearmanClient::setStatusCallback(callback function)
Callback function when there is a status packet for a task. */
PHP_FUNCTION(gearman_client_set_status_callback) {
zval *zstatus_fn;
zend_string *callable = NULL;
gearman_client_obj *obj;
zval *zobj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz", &zobj, gearman_client_ce,
&zstatus_fn
) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_CLIENT_P(zobj);
/* check that the function is callable */
if (!zend_is_callable(zstatus_fn, 0, &callable)) {
php_error_docref(NULL, E_WARNING, "function %s is not callable", callable->val);
zend_string_release(callable);
RETURN_FALSE;
}
zend_string_release(callable);
/* Defining callback again? Clean up old one first */
if (!Z_ISUNDEF(obj->zstatus_fn)) {
zval_dtor(&obj->zstatus_fn);
}
/* store the cb in client object */
ZVAL_COPY(&obj->zstatus_fn, zstatus_fn);
/* set the callback for php */
gearman_client_set_status_fn(&(obj->client), _php_task_status_fn);
RETURN_TRUE;
}
/* }}} */
/* {{{ proto bool GearmanClient::setCompleteCallback(callback function)
Callback function when there is a status packet for a task. */
PHP_FUNCTION(gearman_client_set_complete_callback) {
zval *zcomplete_fn;
zend_string *callable = NULL;
gearman_client_obj *obj;
zval *zobj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz", &zobj, gearman_client_ce,
&zcomplete_fn
) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_CLIENT_P(zobj);
/* check that the function is callable */
if (! zend_is_callable(zcomplete_fn, 0, &callable)) {
php_error_docref(NULL, E_WARNING, "function %s is not callable", callable->val);
zend_string_release(callable);
RETURN_FALSE;
}
zend_string_release(callable);
/* Defining callback again? Clean up old one first */
if (!Z_ISUNDEF(obj->zcomplete_fn)) {
zval_dtor(&obj->zcomplete_fn);
}
/* store the cb in client object */
ZVAL_COPY(&obj->zcomplete_fn, zcomplete_fn);
/* set the callback for php */
gearman_client_set_complete_fn(&(obj->client), _php_task_complete_fn);
RETURN_TRUE;
}
/* }}} */
/* {{{ proto bool GearmanClient::setExceptionCallback(callback function)
Callback function when there is a exception packet for a task. */
PHP_FUNCTION(gearman_client_set_exception_callback) {
zval *zexception_fn;
zend_string *callable = NULL;
gearman_client_obj *obj;
zval *zobj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz", &zobj, gearman_client_ce,
&zexception_fn
) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_CLIENT_P(zobj);
if (!gearman_client_set_server_option(&(obj->client), "exceptions", (sizeof("exceptions") - 1))) {
GEARMAN_EXCEPTION("Failed to set exception option", 0);
}
/* check that the function is callable */
if (! zend_is_callable(zexception_fn, 0, &callable)) {
php_error_docref(NULL, E_WARNING, "function %s is not callable", callable->val);
zend_string_release(callable);
RETURN_FALSE;
}
zend_string_release(callable);
/* Defining callback again? Clean up old one first */
if (!Z_ISUNDEF(obj->zexception_fn)) {
zval_dtor(&obj->zexception_fn);
}
/* store the cb in client object */
ZVAL_COPY(&obj->zexception_fn, zexception_fn);
/* set the callback for php */
gearman_client_set_exception_fn(&(obj->client), _php_task_exception_fn);
RETURN_TRUE;
}
/* }}} */
/* {{{ proto bool GearmanClient::setFailCallback(callback function)
Callback function when there is a fail packet for a task. */
PHP_FUNCTION(gearman_client_set_fail_callback) {
zval *zfail_fn;
zend_string *callable = NULL;
gearman_client_obj *obj;
zval *zobj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz", &zobj, gearman_client_ce,
&zfail_fn
) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_CLIENT_P(zobj);
/* check that the function is callable */
if (! zend_is_callable(zfail_fn, 0, &callable)) {
php_error_docref(NULL, E_WARNING, "function %s is not callable", callable->val);
zend_string_release(callable);
RETURN_FALSE;
}
zend_string_release(callable);
/* Defining callback again? Clean up old one first */
if (!Z_ISUNDEF(obj->zfail_fn)) {
zval_dtor(&obj->zfail_fn);
}
/* store the cb in client object */
ZVAL_COPY(&obj->zfail_fn, zfail_fn);
/* set the callback for php */
gearman_client_set_fail_fn(&(obj->client), _php_task_fail_fn);
RETURN_TRUE;
}
/* }}} */
/* {{{ proto bool GearmanClient::clearCallbacks()
Clear all task callback functions. */
PHP_FUNCTION(gearman_client_clear_callbacks) {
gearman_client_obj *obj;
zval *zobj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_client_ce) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_CLIENT_P(zobj);
gearman_client_clear_fn(&obj->client);
zval_dtor(&obj->zworkload_fn);
ZVAL_UNDEF(&obj->zworkload_fn);
zval_dtor(&obj->zcreated_fn);
ZVAL_UNDEF(&obj->zcreated_fn);
zval_dtor(&obj->zdata_fn);
ZVAL_UNDEF(&obj->zdata_fn);
zval_dtor(&obj->zwarning_fn);
ZVAL_UNDEF(&obj->zwarning_fn);
zval_dtor(&obj->zstatus_fn);
ZVAL_UNDEF(&obj->zstatus_fn);
zval_dtor(&obj->zcomplete_fn);
ZVAL_UNDEF(&obj->zcomplete_fn);
zval_dtor(&obj->zexception_fn);
ZVAL_UNDEF(&obj->zexception_fn);
zval_dtor(&obj->zfail_fn);
ZVAL_UNDEF(&obj->zfail_fn);
RETURN_TRUE;
}
/* }}} */
/* {{{ proto string GearmanClient::context()
Get the application data */
PHP_FUNCTION(gearman_client_context) {
const char *data;
int length = 0;
gearman_client_obj *obj;
zval *zobj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_client_ce) == FAILURE) {
RETURN_EMPTY_STRING();
}
obj = Z_GEARMAN_CLIENT_P(zobj);
data = gearman_client_context(&(obj->client));
if (data) {
length = strlen(data);
}
RETURN_STRINGL(data, length);
}
/* }}} */
/* {{{ proto bool GearmanClient::setContext(string data)
Set the application data */
PHP_FUNCTION(gearman_client_set_context) {
char *data, *old_context;
size_t data_len = 0;
gearman_client_obj *obj;
zval *zobj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &zobj, gearman_client_ce, &data, &data_len) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_CLIENT_P(zobj);
old_context = gearman_client_context(&(obj->client));
efree(old_context);
gearman_client_set_context(&(obj->client), (void*) estrndup(data, data_len));
RETURN_TRUE;
}
/* }}} */
/* {{{ proto bool GearmanClient::enableExceptionHandler()
Enable exception handling to be used by exception callback function
GearmanClient::enableExceptionHandler */
PHP_FUNCTION(gearman_client_enable_exception_handler) {
gearman_client_obj *obj;
zval *zobj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_client_ce) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_CLIENT_P(zobj);
if (!gearman_client_set_server_option(&(obj->client), "exceptions", (sizeof("exceptions") - 1))) {
GEARMAN_EXCEPTION("Failed to set exception option", 0);
}
RETURN_TRUE;
}
/* }}} */
gearman-2.1.2/php_gearman_client.h 0000644 0001750 0001750 00000004146 14603537402 016535 0 ustar rasmus rasmus /*
* Gearman PHP Extension
*
* Copyright (C) 2008 James M. Luedke ,
* Eric Day
* All rights reserved.
*
* Use and distribution licensed under the PHP license. See
* the LICENSE file in this directory for full text.
*/
#ifndef __PHP_GEARMAN_CLIENT_H
#define __PHP_GEARMAN_CLIENT_H
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "zend_exceptions.h"
#include "zend_interfaces.h"
#include "php_gearman.h"
#include
#include
#include
extern zend_class_entry *gearman_client_ce;
extern zend_object_handlers gearman_client_obj_handlers;
void gearman_client_free_obj(zend_object *object);
zend_object *gearman_client_obj_new(zend_class_entry *ce);
typedef enum {
GEARMAN_CLIENT_OBJ_CREATED = (1 << 0)
} gearman_client_obj_flags_t;
typedef struct {
gearman_return_t ret;
gearman_client_obj_flags_t flags;
gearman_client_st client;
/* used for keeping track of task interface callbacks */
zval zworkload_fn;
zval zcreated_fn;
zval zdata_fn;
zval zwarning_fn;
zval zstatus_fn;
zval zcomplete_fn;
zval zexception_fn;
zval zfail_fn;
zend_ulong created_tasks;
zval task_list;
zend_object std;
} gearman_client_obj;
gearman_client_obj *gearman_client_fetch_object(zend_object *obj);
#define Z_GEARMAN_CLIENT_P(zv) gearman_client_fetch_object(Z_OBJ_P((zv)))
/* NOTE: It seems kinda weird that GEARMAN_WORK_FAIL is a valid
* return code, however it is required for a worker to pass status
* back to the client about a failed job, other return codes can
* be passed back but they will cause a docref Warning. Might
* want to think of a better solution XXX */
#define PHP_GEARMAN_CLIENT_RET_OK(__ret) ((__ret) == GEARMAN_SUCCESS || \
(__ret) == GEARMAN_PAUSE || \
(__ret) == GEARMAN_IO_WAIT || \
(__ret) == GEARMAN_WORK_STATUS || \
(__ret) == GEARMAN_WORK_DATA || \
(__ret) == GEARMAN_WORK_EXCEPTION || \
(__ret) == GEARMAN_WORK_WARNING || \
(__ret) == GEARMAN_WORK_FAIL)
#endif /* __PHP_GEARMAN_CLIENT_H */
gearman-2.1.2/const_gen.sh 0000755 0001750 0001750 00000002315 14603537402 015057 0 ustar rasmus rasmus #!/bin/sh
#
# Gearman PHP Extension
#
# Copyright (C) 2008 James M. Luedke ,
# Eric Day
# All rights reserved.
#
# Use and distribution licensed under the PHP license. See
# the LICENSE file in this directory for full text.
if [ "$1" = "" ]
then
header=/usr/local/include/libgearman/constants.h
else
header=$1
fi
if [ ! -e $header ]
then
echo "$header does not exist"
exit 1;
fi
if [ -e php_gearman.c.new ]
then
echo "php_gearman.c.new already exists"
exit 1;
fi
awk 'BEGIN { p= 1; } \
/CONST_GEN_START/ { p= 0; print $0; } \
{ if (p == 1) { print $0; } }' php_gearman.c >> php_gearman.c.new
grep ' GEARMAN' $header | \
sed 's/.*\(GEARMAN[A-Z0-9_]*\).*/\1/' | \
sed 's/\(.*\)/ REGISTER_LONG_CONSTANT("\1",\
\1,\
CONST_CS | CONST_PERSISTENT);/' | \
sed 's/LONG\(.*GEARMAN_DEFAULT_TCP_HOST\)/STRING\1/' | \
sed 's/LONG\(.*GEARMAN_DEFAULT_UDS\)/STRING\1/' | \
sed 's/LONG\(.*GEARMAN_DEFAULT_USER\)/STRING\1/' >> php_gearman.c.new
awk 'BEGIN { p= 0; } \
/CONST_GEN_STOP/ { p= 1; } \
{ if (p == 1) { print $0; } }' php_gearman.c >> php_gearman.c.new
echo "New source file can be found in: php_gearman.c.new"
exit 0
gearman-2.1.2/gearman_arginfo.h 0000644 0001750 0001750 00000135777 14603537402 016054 0 ustar rasmus rasmus /* This is a generated file, edit the .stub.php file instead.
* Stub hash: bf4285b6af333c47f5d7e36723bdede63c5ddcf5 */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_version, 0, 0, IS_STRING, 0)
ZEND_END_ARG_INFO()
#define arginfo_gearman_bugreport arginfo_gearman_version
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_verbose_name, 0, 1, IS_STRING, 1)
ZEND_ARG_TYPE_INFO(0, verbose, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_gearman_client_create, 0, 0, GearmanClient, MAY_BE_FALSE)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_gearman_worker_create, 0, 0, GearmanWorker, MAY_BE_FALSE)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_client_return_code, 0, 1, IS_LONG, 1)
ZEND_ARG_OBJ_INFO(0, obj, GearmanClient, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_gearman_client_error, 0, 1, MAY_BE_NULL|MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_OBJ_INFO(0, obj, GearmanClient, 0)
ZEND_END_ARG_INFO()
#define arginfo_gearman_client_get_errno arginfo_gearman_client_return_code
#define arginfo_gearman_client_options arginfo_gearman_client_return_code
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_client_set_options, 0, 2, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, obj, GearmanClient, 0)
ZEND_ARG_TYPE_INFO(0, option, IS_LONG, 0)
ZEND_END_ARG_INFO()
#define arginfo_gearman_client_add_options arginfo_gearman_client_set_options
#define arginfo_gearman_client_remove_options arginfo_gearman_client_set_options
#define arginfo_gearman_client_timeout arginfo_gearman_client_return_code
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_client_set_timeout, 0, 2, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, obj, GearmanClient, 0)
ZEND_ARG_TYPE_INFO(0, timeout, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_client_add_server, 0, 1, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, obj, GearmanClient, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, host, IS_STRING, 0, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, port, IS_LONG, 0, "0")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, setupExceptionHandler, _IS_BOOL, 0, "true")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_client_add_servers, 0, 1, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, obj, GearmanClient, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, servers, IS_STRING, 0, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, setupExceptionHandler, _IS_BOOL, 0, "true")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_client_wait, 0, 1, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, obj, GearmanClient, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_client_do_normal, 0, 3, IS_STRING, 0)
ZEND_ARG_OBJ_INFO(0, obj, GearmanClient, 0)
ZEND_ARG_TYPE_INFO(0, function, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, workload, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, unique, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()
#define arginfo_gearman_client_do_high arginfo_gearman_client_do_normal
#define arginfo_gearman_client_do_low arginfo_gearman_client_do_normal
#define arginfo_gearman_client_do_background arginfo_gearman_client_do_normal
#define arginfo_gearman_client_do_high_background arginfo_gearman_client_do_normal
#define arginfo_gearman_client_do_low_background arginfo_gearman_client_do_normal
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_client_do_job_handle, 0, 1, IS_STRING, 0)
ZEND_ARG_OBJ_INFO(0, obj, GearmanClient, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_client_do_status, 0, 1, IS_ARRAY, 0)
ZEND_ARG_OBJ_INFO(0, obj, GearmanClient, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_client_job_status, 0, 2, IS_ARRAY, 0)
ZEND_ARG_OBJ_INFO(0, obj, GearmanClient, 0)
ZEND_ARG_TYPE_INFO(0, job_handle, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_client_job_status_by_unique_key, 0, 2, IS_ARRAY, 0)
ZEND_ARG_OBJ_INFO(0, obj, GearmanClient, 0)
ZEND_ARG_TYPE_INFO(0, unique_key, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_client_ping, 0, 2, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, obj, GearmanClient, 0)
ZEND_ARG_TYPE_INFO(0, workload, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_gearman_client_add_task, 0, 3, GearmanTask, MAY_BE_FALSE)
ZEND_ARG_OBJ_INFO(0, obj, GearmanClient, 0)
ZEND_ARG_TYPE_INFO(0, function_name, IS_STRING, 0)
ZEND_ARG_TYPE_MASK(0, workload, MAY_BE_STRING|MAY_BE_LONG|MAY_BE_DOUBLE, NULL)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, context, IS_MIXED, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, unique_key, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()
#define arginfo_gearman_client_add_task_high arginfo_gearman_client_add_task
#define arginfo_gearman_client_add_task_low arginfo_gearman_client_add_task
#define arginfo_gearman_client_add_task_background arginfo_gearman_client_add_task
#define arginfo_gearman_client_add_task_high_background arginfo_gearman_client_add_task
#define arginfo_gearman_client_add_task_low_background arginfo_gearman_client_add_task
#define arginfo_gearman_client_run_tasks arginfo_gearman_client_wait
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_gearman_client_add_task_status, 0, 2, GearmanTask, 0)
ZEND_ARG_OBJ_INFO(0, obj, GearmanClient, 0)
ZEND_ARG_TYPE_INFO(0, job_handle, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, context, IS_MIXED, 1, "null")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_client_set_workload_callback, 0, 2, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, obj, GearmanClient, 0)
ZEND_ARG_TYPE_INFO(0, function, IS_CALLABLE, 0)
ZEND_END_ARG_INFO()
#define arginfo_gearman_client_set_created_callback arginfo_gearman_client_set_workload_callback
#define arginfo_gearman_client_set_data_callback arginfo_gearman_client_set_workload_callback
#define arginfo_gearman_client_set_warning_callback arginfo_gearman_client_set_workload_callback
#define arginfo_gearman_client_set_status_callback arginfo_gearman_client_set_workload_callback
#define arginfo_gearman_client_set_complete_callback arginfo_gearman_client_set_workload_callback
#define arginfo_gearman_client_set_exception_callback arginfo_gearman_client_set_workload_callback
#define arginfo_gearman_client_set_fail_callback arginfo_gearman_client_set_workload_callback
#define arginfo_gearman_client_clear_callbacks arginfo_gearman_client_wait
#define arginfo_gearman_client_context arginfo_gearman_client_do_job_handle
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_client_set_context, 0, 2, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, obj, GearmanClient, 0)
ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0)
ZEND_END_ARG_INFO()
#define arginfo_gearman_client_enable_exception_handler arginfo_gearman_client_wait
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_job_return_code, 0, 1, IS_LONG, 1)
ZEND_ARG_OBJ_INFO(0, obj, GearmanJob, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_job_set_return, 0, 2, _IS_BOOL, 1)
ZEND_ARG_OBJ_INFO(0, obj, GearmanJob, 0)
ZEND_ARG_TYPE_INFO(0, gearman_return_t, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_job_send_data, 0, 2, _IS_BOOL, 1)
ZEND_ARG_OBJ_INFO(0, obj, GearmanJob, 0)
ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_job_send_warning, 0, 2, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, obj, GearmanJob, 0)
ZEND_ARG_TYPE_INFO(0, warning, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_job_send_status, 0, 3, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, obj, GearmanJob, 0)
ZEND_ARG_TYPE_INFO(0, numerator, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, denominator, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_job_send_complete, 0, 2, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, obj, GearmanJob, 0)
ZEND_ARG_TYPE_INFO(0, result, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_job_send_exception, 0, 2, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, obj, GearmanJob, 0)
ZEND_ARG_TYPE_INFO(0, exception, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_job_send_fail, 0, 1, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, obj, GearmanJob, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_gearman_job_handle, 0, 1, MAY_BE_BOOL|MAY_BE_STRING)
ZEND_ARG_OBJ_INFO(0, obj, GearmanJob, 0)
ZEND_END_ARG_INFO()
#define arginfo_gearman_job_function_name arginfo_gearman_job_handle
#define arginfo_gearman_job_unique arginfo_gearman_job_handle
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_job_workload, 0, 1, IS_STRING, 0)
ZEND_ARG_OBJ_INFO(0, obj, GearmanJob, 0)
ZEND_END_ARG_INFO()
#define arginfo_gearman_job_workload_size arginfo_gearman_job_return_code
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_task_return_code, 0, 1, IS_LONG, 1)
ZEND_ARG_OBJ_INFO(0, obj, GearmanTask, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_gearman_task_function_name, 0, 1, MAY_BE_NULL|MAY_BE_BOOL|MAY_BE_STRING)
ZEND_ARG_OBJ_INFO(0, obj, GearmanTask, 0)
ZEND_END_ARG_INFO()
#define arginfo_gearman_task_unique arginfo_gearman_task_function_name
#define arginfo_gearman_task_job_handle arginfo_gearman_task_function_name
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_task_is_known, 0, 1, _IS_BOOL, 1)
ZEND_ARG_OBJ_INFO(0, obj, GearmanTask, 0)
ZEND_END_ARG_INFO()
#define arginfo_gearman_task_is_running arginfo_gearman_task_is_known
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_gearman_task_numerator, 0, 1, MAY_BE_NULL|MAY_BE_BOOL|MAY_BE_LONG)
ZEND_ARG_OBJ_INFO(0, obj, GearmanTask, 0)
ZEND_END_ARG_INFO()
#define arginfo_gearman_task_denominator arginfo_gearman_task_numerator
#define arginfo_gearman_task_data arginfo_gearman_task_function_name
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_gearman_task_data_size, 0, 1, MAY_BE_LONG|MAY_BE_FALSE)
ZEND_ARG_OBJ_INFO(0, obj, GearmanTask, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_gearman_task_send_workload, 0, 2, MAY_BE_LONG|MAY_BE_FALSE)
ZEND_ARG_OBJ_INFO(0, obj, GearmanTask, 0)
ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_gearman_task_recv_data, 0, 2, MAY_BE_BOOL|MAY_BE_ARRAY)
ZEND_ARG_OBJ_INFO(0, obj, GearmanTask, 0)
ZEND_ARG_TYPE_INFO(0, data_len, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_worker_return_code, 0, 1, IS_LONG, 1)
ZEND_ARG_OBJ_INFO(0, obj, GearmanWorker, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_gearman_worker_error, 0, 1, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_ARG_OBJ_INFO(0, obj, GearmanWorker, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_gearman_worker_errno, 0, 1, MAY_BE_LONG|MAY_BE_FALSE)
ZEND_ARG_OBJ_INFO(0, obj, GearmanWorker, 0)
ZEND_END_ARG_INFO()
#define arginfo_gearman_worker_options arginfo_gearman_worker_return_code
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_worker_set_options, 0, 2, _IS_BOOL, 1)
ZEND_ARG_OBJ_INFO(0, obj, GearmanWorker, 0)
ZEND_ARG_TYPE_INFO(0, option, IS_LONG, 0)
ZEND_END_ARG_INFO()
#define arginfo_gearman_worker_add_options arginfo_gearman_worker_set_options
#define arginfo_gearman_worker_remove_options arginfo_gearman_worker_set_options
#define arginfo_gearman_worker_timeout arginfo_gearman_worker_return_code
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_worker_set_timeout, 0, 2, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, obj, GearmanWorker, 0)
ZEND_ARG_TYPE_INFO(0, timeout, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_worker_set_id, 0, 2, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, obj, GearmanWorker, 0)
ZEND_ARG_TYPE_INFO(0, id, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_worker_add_server, 0, 1, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, obj, GearmanWorker, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, host, IS_STRING, 0, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, port, IS_LONG, 0, "0")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, setupExceptionHandler, _IS_BOOL, 0, "true")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_worker_add_servers, 0, 1, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, obj, GearmanWorker, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, servers, IS_STRING, 0, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, setupExceptionHandler, _IS_BOOL, 0, "true")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_worker_wait, 0, 1, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, obj, GearmanWorker, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_worker_register, 0, 2, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, obj, GearmanWorker, 0)
ZEND_ARG_TYPE_INFO(0, function_name, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, timeout, IS_LONG, 0, "0")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_worker_unregister, 0, 2, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, obj, GearmanWorker, 0)
ZEND_ARG_TYPE_INFO(0, function_name, IS_STRING, 0)
ZEND_END_ARG_INFO()
#define arginfo_gearman_worker_unregister_all arginfo_gearman_worker_wait
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_gearman_worker_grab_job, 0, 1, GearmanWorker, MAY_BE_FALSE)
ZEND_ARG_OBJ_INFO(0, obj, GearmanWorker, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_worker_add_function, 0, 3, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, obj, GearmanWorker, 0)
ZEND_ARG_TYPE_INFO(0, function_name, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, function, IS_CALLABLE, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, context, IS_MIXED, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, timeout, IS_LONG, 0, "0")
ZEND_END_ARG_INFO()
#define arginfo_gearman_worker_work arginfo_gearman_worker_wait
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_gearman_worker_ping, 0, 2, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, obj, GearmanWorker, 0)
ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0)
ZEND_END_ARG_INFO()
#define arginfo_gearman_worker_enable_exception_handler arginfo_gearman_worker_wait
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_GearmanClient___construct, 0, 0, 0)
ZEND_END_ARG_INFO()
#define arginfo_class_GearmanClient___destruct arginfo_class_GearmanClient___construct
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_GearmanClient_returnCode, 0, 0, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_GearmanClient_error, 0, 0, MAY_BE_STRING|MAY_BE_FALSE)
ZEND_END_ARG_INFO()
#define arginfo_class_GearmanClient_getErrno arginfo_class_GearmanClient_returnCode
#define arginfo_class_GearmanClient_options arginfo_class_GearmanClient_returnCode
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_GearmanClient_setOptions, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, option, IS_LONG, 0)
ZEND_END_ARG_INFO()
#define arginfo_class_GearmanClient_addOptions arginfo_class_GearmanClient_setOptions
#define arginfo_class_GearmanClient_removeOptions arginfo_class_GearmanClient_setOptions
#define arginfo_class_GearmanClient_timeout arginfo_class_GearmanClient_returnCode
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_GearmanClient_setTimeout, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, timeout, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_GearmanClient_addServer, 0, 0, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, host, IS_STRING, 0, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, port, IS_LONG, 0, "0")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, setupExceptionHandler, _IS_BOOL, 0, "true")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_GearmanClient_addServers, 0, 0, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, servers, IS_STRING, 0, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, setupExceptionHandler, _IS_BOOL, 0, "true")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_GearmanClient_wait, 0, 0, _IS_BOOL, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_GearmanClient_doNormal, 0, 2, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, function, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, workload, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, unique, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()
#define arginfo_class_GearmanClient_doHigh arginfo_class_GearmanClient_doNormal
#define arginfo_class_GearmanClient_dolow arginfo_class_GearmanClient_doNormal
#define arginfo_class_GearmanClient_doBackground arginfo_class_GearmanClient_doNormal
#define arginfo_class_GearmanClient_doHighBackground arginfo_class_GearmanClient_doNormal
#define arginfo_class_GearmanClient_doLowBackground arginfo_class_GearmanClient_doNormal
#define arginfo_class_GearmanClient_doJobHandle arginfo_gearman_version
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_GearmanClient_doStatus, 0, 0, IS_ARRAY, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_GearmanClient_jobStatus, 0, 1, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO(0, job_handle, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_GearmanClient_jobStatusByUniqueKey, 0, 1, IS_ARRAY, 0)
ZEND_ARG_TYPE_INFO(0, unique_key, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_GearmanClient_ping, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, workload, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_TYPE_MASK_EX(arginfo_class_GearmanClient_addTask, 0, 2, GearmanTask, MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, function_name, IS_STRING, 0)
ZEND_ARG_TYPE_MASK(0, workload, MAY_BE_STRING|MAY_BE_LONG|MAY_BE_DOUBLE, NULL)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, context, IS_MIXED, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, unique_key, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()
#define arginfo_class_GearmanClient_addTaskHigh arginfo_class_GearmanClient_addTask
#define arginfo_class_GearmanClient_addTaskLow arginfo_class_GearmanClient_addTask
#define arginfo_class_GearmanClient_addTaskBackground arginfo_class_GearmanClient_addTask
#define arginfo_class_GearmanClient_addTaskHighBackground arginfo_class_GearmanClient_addTask
#define arginfo_class_GearmanClient_addTaskLowBackground arginfo_class_GearmanClient_addTask
#define arginfo_class_GearmanClient_runTasks arginfo_class_GearmanClient_wait
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_class_GearmanClient_addTaskStatus, 0, 1, GearmanTask, 0)
ZEND_ARG_TYPE_INFO(0, job_handle, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, context, IS_MIXED, 1, "null")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_GearmanClient_setWorkloadCallback, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, function, IS_CALLABLE, 0)
ZEND_END_ARG_INFO()
#define arginfo_class_GearmanClient_setCreatedCallback arginfo_class_GearmanClient_setWorkloadCallback
#define arginfo_class_GearmanClient_setDataCallback arginfo_class_GearmanClient_setWorkloadCallback
#define arginfo_class_GearmanClient_setWarningCallback arginfo_class_GearmanClient_setWorkloadCallback
#define arginfo_class_GearmanClient_setStatusCallback arginfo_class_GearmanClient_setWorkloadCallback
#define arginfo_class_GearmanClient_setCompleteCallback arginfo_class_GearmanClient_setWorkloadCallback
#define arginfo_class_GearmanClient_setExceptionCallback arginfo_class_GearmanClient_setWorkloadCallback
#define arginfo_class_GearmanClient_setFailCallback arginfo_class_GearmanClient_setWorkloadCallback
#define arginfo_class_GearmanClient_clearCallbacks arginfo_class_GearmanClient_wait
#define arginfo_class_GearmanClient_context arginfo_gearman_version
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_GearmanClient_setContext, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0)
ZEND_END_ARG_INFO()
#define arginfo_class_GearmanClient_enableExceptionHandler arginfo_class_GearmanClient_wait
#define arginfo_class_GearmanJob___destruct arginfo_class_GearmanClient___construct
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_GearmanJob_returnCode, 0, 0, IS_LONG, 1)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_GearmanJob_setReturn, 0, 1, _IS_BOOL, 1)
ZEND_ARG_TYPE_INFO(0, gearman_return_t, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_GearmanJob_sendData, 0, 1, _IS_BOOL, 1)
ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_GearmanJob_sendWarning, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, warning, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_GearmanJob_sendStatus, 0, 2, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, numerator, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, denominator, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_GearmanJob_sendComplete, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, result, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_GearmanJob_sendException, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, exception, IS_STRING, 0)
ZEND_END_ARG_INFO()
#define arginfo_class_GearmanJob_sendFail arginfo_class_GearmanClient_wait
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_GearmanJob_handle, 0, 0, MAY_BE_BOOL|MAY_BE_STRING)
ZEND_END_ARG_INFO()
#define arginfo_class_GearmanJob_functionName arginfo_class_GearmanJob_handle
#define arginfo_class_GearmanJob_unique arginfo_class_GearmanJob_handle
#define arginfo_class_GearmanJob_workload arginfo_gearman_version
#define arginfo_class_GearmanJob_workloadSize arginfo_class_GearmanJob_returnCode
#define arginfo_class_GearmanTask___construct arginfo_class_GearmanClient___construct
#define arginfo_class_GearmanTask_returnCode arginfo_class_GearmanClient_returnCode
#define arginfo_class_GearmanTask_functionName arginfo_class_GearmanJob_handle
#define arginfo_class_GearmanTask_unique arginfo_class_GearmanJob_handle
#define arginfo_class_GearmanTask_jobHandle arginfo_class_GearmanJob_handle
#define arginfo_class_GearmanTask_isKnown arginfo_class_GearmanClient_wait
#define arginfo_class_GearmanTask_isRunning arginfo_class_GearmanClient_wait
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_GearmanTask_taskNumerator, 0, 0, MAY_BE_BOOL|MAY_BE_LONG)
ZEND_END_ARG_INFO()
#define arginfo_class_GearmanTask_taskDenominator arginfo_class_GearmanTask_taskNumerator
#define arginfo_class_GearmanTask_data arginfo_class_GearmanJob_handle
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_GearmanTask_dataSize, 0, 0, MAY_BE_LONG|MAY_BE_FALSE)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_GearmanTask_sendWorkload, 0, 1, MAY_BE_LONG|MAY_BE_FALSE)
ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_class_GearmanTask_recvData, 0, 1, MAY_BE_BOOL|MAY_BE_ARRAY)
ZEND_ARG_TYPE_INFO(0, data_len, IS_LONG, 0)
ZEND_END_ARG_INFO()
#define arginfo_class_GearmanWorker___construct arginfo_class_GearmanClient___construct
#define arginfo_class_GearmanWorker___destruct arginfo_class_GearmanClient___construct
#define arginfo_class_GearmanWorker_returnCode arginfo_class_GearmanJob_returnCode
#define arginfo_class_GearmanWorker_error arginfo_class_GearmanClient_error
#define arginfo_class_GearmanWorker_getErrno arginfo_class_GearmanTask_dataSize
#define arginfo_class_GearmanWorker_options arginfo_class_GearmanJob_returnCode
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_GearmanWorker_setOptions, 0, 1, _IS_BOOL, 1)
ZEND_ARG_TYPE_INFO(0, option, IS_LONG, 0)
ZEND_END_ARG_INFO()
#define arginfo_class_GearmanWorker_addOptions arginfo_class_GearmanWorker_setOptions
#define arginfo_class_GearmanWorker_removeOptions arginfo_class_GearmanWorker_setOptions
#define arginfo_class_GearmanWorker_timeout arginfo_class_GearmanJob_returnCode
#define arginfo_class_GearmanWorker_setTimeout arginfo_class_GearmanClient_setTimeout
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_GearmanWorker_setId, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, id, IS_STRING, 0)
ZEND_END_ARG_INFO()
#define arginfo_class_GearmanWorker_addServer arginfo_class_GearmanClient_addServer
#define arginfo_class_GearmanWorker_addServers arginfo_class_GearmanClient_addServers
#define arginfo_class_GearmanWorker_wait arginfo_class_GearmanClient_wait
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_GearmanWorker_register, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, function_name, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, timeout, IS_LONG, 0, "0")
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_GearmanWorker_unregister, 0, 1, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, function_name, IS_STRING, 0)
ZEND_END_ARG_INFO()
#define arginfo_class_GearmanWorker_unregisterAll arginfo_class_GearmanClient_wait
#define arginfo_class_GearmanWorker_grabJob arginfo_gearman_worker_create
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_GearmanWorker_addFunction, 0, 2, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, function_name, IS_STRING, 0)
ZEND_ARG_TYPE_INFO(0, function, IS_CALLABLE, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, context, IS_MIXED, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, timeout, IS_LONG, 0, "0")
ZEND_END_ARG_INFO()
#define arginfo_class_GearmanWorker_work arginfo_class_GearmanClient_wait
#define arginfo_class_GearmanWorker_ping arginfo_class_GearmanClient_setContext
#define arginfo_class_GearmanWorker_enableExceptionHandler arginfo_class_GearmanClient_wait
ZEND_FUNCTION(gearman_version);
ZEND_FUNCTION(gearman_bugreport);
ZEND_FUNCTION(gearman_verbose_name);
ZEND_FUNCTION(gearman_client_create);
ZEND_FUNCTION(gearman_worker_create);
ZEND_FUNCTION(gearman_client_return_code);
ZEND_FUNCTION(gearman_client_error);
ZEND_FUNCTION(gearman_client_get_errno);
ZEND_FUNCTION(gearman_client_options);
ZEND_FUNCTION(gearman_client_set_options);
ZEND_FUNCTION(gearman_client_add_options);
ZEND_FUNCTION(gearman_client_remove_options);
ZEND_FUNCTION(gearman_client_timeout);
ZEND_FUNCTION(gearman_client_set_timeout);
ZEND_FUNCTION(gearman_client_add_server);
ZEND_FUNCTION(gearman_client_add_servers);
ZEND_FUNCTION(gearman_client_wait);
ZEND_FUNCTION(gearman_client_do_normal);
ZEND_FUNCTION(gearman_client_do_high);
ZEND_FUNCTION(gearman_client_do_low);
ZEND_FUNCTION(gearman_client_do_background);
ZEND_FUNCTION(gearman_client_do_high_background);
ZEND_FUNCTION(gearman_client_do_low_background);
ZEND_FUNCTION(gearman_client_do_job_handle);
ZEND_FUNCTION(gearman_client_do_status);
ZEND_FUNCTION(gearman_client_job_status);
ZEND_FUNCTION(gearman_client_job_status_by_unique_key);
ZEND_FUNCTION(gearman_client_ping);
ZEND_FUNCTION(gearman_client_add_task);
ZEND_FUNCTION(gearman_client_add_task_high);
ZEND_FUNCTION(gearman_client_add_task_low);
ZEND_FUNCTION(gearman_client_add_task_background);
ZEND_FUNCTION(gearman_client_add_task_high_background);
ZEND_FUNCTION(gearman_client_add_task_low_background);
ZEND_FUNCTION(gearman_client_run_tasks);
ZEND_FUNCTION(gearman_client_add_task_status);
ZEND_FUNCTION(gearman_client_set_workload_callback);
ZEND_FUNCTION(gearman_client_set_created_callback);
ZEND_FUNCTION(gearman_client_set_data_callback);
ZEND_FUNCTION(gearman_client_set_warning_callback);
ZEND_FUNCTION(gearman_client_set_status_callback);
ZEND_FUNCTION(gearman_client_set_complete_callback);
ZEND_FUNCTION(gearman_client_set_exception_callback);
ZEND_FUNCTION(gearman_client_set_fail_callback);
ZEND_FUNCTION(gearman_client_clear_callbacks);
ZEND_FUNCTION(gearman_client_context);
ZEND_FUNCTION(gearman_client_set_context);
ZEND_FUNCTION(gearman_client_enable_exception_handler);
ZEND_FUNCTION(gearman_job_return_code);
ZEND_FUNCTION(gearman_job_set_return);
ZEND_FUNCTION(gearman_job_send_data);
ZEND_FUNCTION(gearman_job_send_warning);
ZEND_FUNCTION(gearman_job_send_status);
ZEND_FUNCTION(gearman_job_send_complete);
ZEND_FUNCTION(gearman_job_send_exception);
ZEND_FUNCTION(gearman_job_send_fail);
ZEND_FUNCTION(gearman_job_handle);
ZEND_FUNCTION(gearman_job_function_name);
ZEND_FUNCTION(gearman_job_unique);
ZEND_FUNCTION(gearman_job_workload);
ZEND_FUNCTION(gearman_job_workload_size);
ZEND_FUNCTION(gearman_task_return_code);
ZEND_FUNCTION(gearman_task_function_name);
ZEND_FUNCTION(gearman_task_unique);
ZEND_FUNCTION(gearman_task_job_handle);
ZEND_FUNCTION(gearman_task_is_known);
ZEND_FUNCTION(gearman_task_is_running);
ZEND_FUNCTION(gearman_task_numerator);
ZEND_FUNCTION(gearman_task_denominator);
ZEND_FUNCTION(gearman_task_data);
ZEND_FUNCTION(gearman_task_data_size);
ZEND_FUNCTION(gearman_task_send_workload);
ZEND_FUNCTION(gearman_task_recv_data);
ZEND_FUNCTION(gearman_worker_return_code);
ZEND_FUNCTION(gearman_worker_error);
ZEND_FUNCTION(gearman_worker_errno);
ZEND_FUNCTION(gearman_worker_options);
ZEND_FUNCTION(gearman_worker_set_options);
ZEND_FUNCTION(gearman_worker_add_options);
ZEND_FUNCTION(gearman_worker_remove_options);
ZEND_FUNCTION(gearman_worker_timeout);
ZEND_FUNCTION(gearman_worker_set_timeout);
ZEND_FUNCTION(gearman_worker_set_id);
ZEND_FUNCTION(gearman_worker_add_server);
ZEND_FUNCTION(gearman_worker_add_servers);
ZEND_FUNCTION(gearman_worker_wait);
ZEND_FUNCTION(gearman_worker_register);
ZEND_FUNCTION(gearman_worker_unregister);
ZEND_FUNCTION(gearman_worker_unregister_all);
ZEND_FUNCTION(gearman_worker_grab_job);
ZEND_FUNCTION(gearman_worker_add_function);
ZEND_FUNCTION(gearman_worker_work);
ZEND_FUNCTION(gearman_worker_ping);
ZEND_FUNCTION(gearman_worker_enable_exception_handler);
ZEND_METHOD(GearmanClient, __construct);
ZEND_METHOD(GearmanClient, __destruct);
ZEND_METHOD(GearmanJob, __destruct);
ZEND_METHOD(GearmanTask, __construct);
ZEND_METHOD(GearmanWorker, __construct);
ZEND_METHOD(GearmanWorker, __destruct);
static const zend_function_entry ext_functions[] = {
ZEND_FE(gearman_version, arginfo_gearman_version)
ZEND_FE(gearman_bugreport, arginfo_gearman_bugreport)
ZEND_FE(gearman_verbose_name, arginfo_gearman_verbose_name)
ZEND_FE(gearman_client_create, arginfo_gearman_client_create)
ZEND_FE(gearman_worker_create, arginfo_gearman_worker_create)
ZEND_FE(gearman_client_return_code, arginfo_gearman_client_return_code)
ZEND_FE(gearman_client_error, arginfo_gearman_client_error)
ZEND_FE(gearman_client_get_errno, arginfo_gearman_client_get_errno)
ZEND_FE(gearman_client_options, arginfo_gearman_client_options)
ZEND_FE(gearman_client_set_options, arginfo_gearman_client_set_options)
ZEND_FE(gearman_client_add_options, arginfo_gearman_client_add_options)
ZEND_FE(gearman_client_remove_options, arginfo_gearman_client_remove_options)
ZEND_FE(gearman_client_timeout, arginfo_gearman_client_timeout)
ZEND_FE(gearman_client_set_timeout, arginfo_gearman_client_set_timeout)
ZEND_FE(gearman_client_add_server, arginfo_gearman_client_add_server)
ZEND_FE(gearman_client_add_servers, arginfo_gearman_client_add_servers)
ZEND_FE(gearman_client_wait, arginfo_gearman_client_wait)
ZEND_FE(gearman_client_do_normal, arginfo_gearman_client_do_normal)
ZEND_FE(gearman_client_do_high, arginfo_gearman_client_do_high)
ZEND_FE(gearman_client_do_low, arginfo_gearman_client_do_low)
ZEND_FE(gearman_client_do_background, arginfo_gearman_client_do_background)
ZEND_FE(gearman_client_do_high_background, arginfo_gearman_client_do_high_background)
ZEND_FE(gearman_client_do_low_background, arginfo_gearman_client_do_low_background)
ZEND_FE(gearman_client_do_job_handle, arginfo_gearman_client_do_job_handle)
ZEND_FE(gearman_client_do_status, arginfo_gearman_client_do_status)
ZEND_FE(gearman_client_job_status, arginfo_gearman_client_job_status)
ZEND_FE(gearman_client_job_status_by_unique_key, arginfo_gearman_client_job_status_by_unique_key)
ZEND_FE(gearman_client_ping, arginfo_gearman_client_ping)
ZEND_FE(gearman_client_add_task, arginfo_gearman_client_add_task)
ZEND_FE(gearman_client_add_task_high, arginfo_gearman_client_add_task_high)
ZEND_FE(gearman_client_add_task_low, arginfo_gearman_client_add_task_low)
ZEND_FE(gearman_client_add_task_background, arginfo_gearman_client_add_task_background)
ZEND_FE(gearman_client_add_task_high_background, arginfo_gearman_client_add_task_high_background)
ZEND_FE(gearman_client_add_task_low_background, arginfo_gearman_client_add_task_low_background)
ZEND_FE(gearman_client_run_tasks, arginfo_gearman_client_run_tasks)
ZEND_FE(gearman_client_add_task_status, arginfo_gearman_client_add_task_status)
ZEND_FE(gearman_client_set_workload_callback, arginfo_gearman_client_set_workload_callback)
ZEND_FE(gearman_client_set_created_callback, arginfo_gearman_client_set_created_callback)
ZEND_FE(gearman_client_set_data_callback, arginfo_gearman_client_set_data_callback)
ZEND_FE(gearman_client_set_warning_callback, arginfo_gearman_client_set_warning_callback)
ZEND_FE(gearman_client_set_status_callback, arginfo_gearman_client_set_status_callback)
ZEND_FE(gearman_client_set_complete_callback, arginfo_gearman_client_set_complete_callback)
ZEND_FE(gearman_client_set_exception_callback, arginfo_gearman_client_set_exception_callback)
ZEND_FE(gearman_client_set_fail_callback, arginfo_gearman_client_set_fail_callback)
ZEND_FE(gearman_client_clear_callbacks, arginfo_gearman_client_clear_callbacks)
ZEND_FE(gearman_client_context, arginfo_gearman_client_context)
ZEND_FE(gearman_client_set_context, arginfo_gearman_client_set_context)
ZEND_FE(gearman_client_enable_exception_handler, arginfo_gearman_client_enable_exception_handler)
ZEND_FE(gearman_job_return_code, arginfo_gearman_job_return_code)
ZEND_FE(gearman_job_set_return, arginfo_gearman_job_set_return)
ZEND_FE(gearman_job_send_data, arginfo_gearman_job_send_data)
ZEND_FE(gearman_job_send_warning, arginfo_gearman_job_send_warning)
ZEND_FE(gearman_job_send_status, arginfo_gearman_job_send_status)
ZEND_FE(gearman_job_send_complete, arginfo_gearman_job_send_complete)
ZEND_FE(gearman_job_send_exception, arginfo_gearman_job_send_exception)
ZEND_FE(gearman_job_send_fail, arginfo_gearman_job_send_fail)
ZEND_FE(gearman_job_handle, arginfo_gearman_job_handle)
ZEND_FE(gearman_job_function_name, arginfo_gearman_job_function_name)
ZEND_FE(gearman_job_unique, arginfo_gearman_job_unique)
ZEND_FE(gearman_job_workload, arginfo_gearman_job_workload)
ZEND_FE(gearman_job_workload_size, arginfo_gearman_job_workload_size)
ZEND_FE(gearman_task_return_code, arginfo_gearman_task_return_code)
ZEND_FE(gearman_task_function_name, arginfo_gearman_task_function_name)
ZEND_FE(gearman_task_unique, arginfo_gearman_task_unique)
ZEND_FE(gearman_task_job_handle, arginfo_gearman_task_job_handle)
ZEND_FE(gearman_task_is_known, arginfo_gearman_task_is_known)
ZEND_FE(gearman_task_is_running, arginfo_gearman_task_is_running)
ZEND_FE(gearman_task_numerator, arginfo_gearman_task_numerator)
ZEND_FE(gearman_task_denominator, arginfo_gearman_task_denominator)
ZEND_FE(gearman_task_data, arginfo_gearman_task_data)
ZEND_FE(gearman_task_data_size, arginfo_gearman_task_data_size)
ZEND_FE(gearman_task_send_workload, arginfo_gearman_task_send_workload)
ZEND_FE(gearman_task_recv_data, arginfo_gearman_task_recv_data)
ZEND_FE(gearman_worker_return_code, arginfo_gearman_worker_return_code)
ZEND_FE(gearman_worker_error, arginfo_gearman_worker_error)
ZEND_FE(gearman_worker_errno, arginfo_gearman_worker_errno)
ZEND_FE(gearman_worker_options, arginfo_gearman_worker_options)
ZEND_FE(gearman_worker_set_options, arginfo_gearman_worker_set_options)
ZEND_FE(gearman_worker_add_options, arginfo_gearman_worker_add_options)
ZEND_FE(gearman_worker_remove_options, arginfo_gearman_worker_remove_options)
ZEND_FE(gearman_worker_timeout, arginfo_gearman_worker_timeout)
ZEND_FE(gearman_worker_set_timeout, arginfo_gearman_worker_set_timeout)
ZEND_FE(gearman_worker_set_id, arginfo_gearman_worker_set_id)
ZEND_FE(gearman_worker_add_server, arginfo_gearman_worker_add_server)
ZEND_FE(gearman_worker_add_servers, arginfo_gearman_worker_add_servers)
ZEND_FE(gearman_worker_wait, arginfo_gearman_worker_wait)
ZEND_FE(gearman_worker_register, arginfo_gearman_worker_register)
ZEND_FE(gearman_worker_unregister, arginfo_gearman_worker_unregister)
ZEND_FE(gearman_worker_unregister_all, arginfo_gearman_worker_unregister_all)
ZEND_FE(gearman_worker_grab_job, arginfo_gearman_worker_grab_job)
ZEND_FE(gearman_worker_add_function, arginfo_gearman_worker_add_function)
ZEND_FE(gearman_worker_work, arginfo_gearman_worker_work)
ZEND_FE(gearman_worker_ping, arginfo_gearman_worker_ping)
ZEND_FE(gearman_worker_enable_exception_handler, arginfo_gearman_worker_enable_exception_handler)
ZEND_FE_END
};
static const zend_function_entry class_GearmanClient_methods[] = {
ZEND_ME(GearmanClient, __construct, arginfo_class_GearmanClient___construct, ZEND_ACC_PUBLIC)
ZEND_ME(GearmanClient, __destruct, arginfo_class_GearmanClient___destruct, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(returnCode, gearman_client_return_code, arginfo_class_GearmanClient_returnCode, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(error, gearman_client_error, arginfo_class_GearmanClient_error, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(getErrno, gearman_client_get_errno, arginfo_class_GearmanClient_getErrno, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(options, gearman_client_options, arginfo_class_GearmanClient_options, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(setOptions, gearman_client_set_options, arginfo_class_GearmanClient_setOptions, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(addOptions, gearman_client_add_options, arginfo_class_GearmanClient_addOptions, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(removeOptions, gearman_client_remove_options, arginfo_class_GearmanClient_removeOptions, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(timeout, gearman_client_timeout, arginfo_class_GearmanClient_timeout, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(setTimeout, gearman_client_set_timeout, arginfo_class_GearmanClient_setTimeout, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(addServer, gearman_client_add_server, arginfo_class_GearmanClient_addServer, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(addServers, gearman_client_add_servers, arginfo_class_GearmanClient_addServers, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(wait, gearman_client_wait, arginfo_class_GearmanClient_wait, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(doNormal, gearman_client_do_normal, arginfo_class_GearmanClient_doNormal, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(doHigh, gearman_client_do_high, arginfo_class_GearmanClient_doHigh, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(dolow, gearman_client_do_low, arginfo_class_GearmanClient_dolow, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(doBackground, gearman_client_do_background, arginfo_class_GearmanClient_doBackground, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(doHighBackground, gearman_client_do_high_background, arginfo_class_GearmanClient_doHighBackground, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(doLowBackground, gearman_client_do_low_background, arginfo_class_GearmanClient_doLowBackground, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(doJobHandle, gearman_client_do_job_handle, arginfo_class_GearmanClient_doJobHandle, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(doStatus, gearman_client_do_status, arginfo_class_GearmanClient_doStatus, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(jobStatus, gearman_client_job_status, arginfo_class_GearmanClient_jobStatus, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(jobStatusByUniqueKey, gearman_client_job_status_by_unique_key, arginfo_class_GearmanClient_jobStatusByUniqueKey, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(ping, gearman_client_ping, arginfo_class_GearmanClient_ping, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(addTask, gearman_client_add_task, arginfo_class_GearmanClient_addTask, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(addTaskHigh, gearman_client_add_task_high, arginfo_class_GearmanClient_addTaskHigh, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(addTaskLow, gearman_client_add_task_low, arginfo_class_GearmanClient_addTaskLow, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(addTaskBackground, gearman_client_add_task_background, arginfo_class_GearmanClient_addTaskBackground, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(addTaskHighBackground, gearman_client_add_task_high_background, arginfo_class_GearmanClient_addTaskHighBackground, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(addTaskLowBackground, gearman_client_add_task_low_background, arginfo_class_GearmanClient_addTaskLowBackground, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(runTasks, gearman_client_run_tasks, arginfo_class_GearmanClient_runTasks, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(addTaskStatus, gearman_client_add_task_status, arginfo_class_GearmanClient_addTaskStatus, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(setWorkloadCallback, gearman_client_set_workload_callback, arginfo_class_GearmanClient_setWorkloadCallback, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(setCreatedCallback, gearman_client_set_created_callback, arginfo_class_GearmanClient_setCreatedCallback, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(setDataCallback, gearman_client_set_data_callback, arginfo_class_GearmanClient_setDataCallback, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(setWarningCallback, gearman_client_set_warning_callback, arginfo_class_GearmanClient_setWarningCallback, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(setStatusCallback, gearman_client_set_status_callback, arginfo_class_GearmanClient_setStatusCallback, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(setCompleteCallback, gearman_client_set_complete_callback, arginfo_class_GearmanClient_setCompleteCallback, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(setExceptionCallback, gearman_client_set_exception_callback, arginfo_class_GearmanClient_setExceptionCallback, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(setFailCallback, gearman_client_set_fail_callback, arginfo_class_GearmanClient_setFailCallback, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(clearCallbacks, gearman_client_clear_callbacks, arginfo_class_GearmanClient_clearCallbacks, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(context, gearman_client_context, arginfo_class_GearmanClient_context, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(setContext, gearman_client_set_context, arginfo_class_GearmanClient_setContext, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(enableExceptionHandler, gearman_client_enable_exception_handler, arginfo_class_GearmanClient_enableExceptionHandler, ZEND_ACC_PUBLIC)
ZEND_FE_END
};
static const zend_function_entry class_GearmanJob_methods[] = {
ZEND_ME(GearmanJob, __destruct, arginfo_class_GearmanJob___destruct, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(returnCode, gearman_job_return_code, arginfo_class_GearmanJob_returnCode, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(setReturn, gearman_job_set_return, arginfo_class_GearmanJob_setReturn, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(sendData, gearman_job_send_data, arginfo_class_GearmanJob_sendData, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(sendWarning, gearman_job_send_warning, arginfo_class_GearmanJob_sendWarning, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(sendStatus, gearman_job_send_status, arginfo_class_GearmanJob_sendStatus, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(sendComplete, gearman_job_send_complete, arginfo_class_GearmanJob_sendComplete, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(sendException, gearman_job_send_exception, arginfo_class_GearmanJob_sendException, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(sendFail, gearman_job_send_fail, arginfo_class_GearmanJob_sendFail, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(handle, gearman_job_handle, arginfo_class_GearmanJob_handle, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(functionName, gearman_job_function_name, arginfo_class_GearmanJob_functionName, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(unique, gearman_job_unique, arginfo_class_GearmanJob_unique, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(workload, gearman_job_workload, arginfo_class_GearmanJob_workload, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(workloadSize, gearman_job_workload_size, arginfo_class_GearmanJob_workloadSize, ZEND_ACC_PUBLIC)
ZEND_FE_END
};
static const zend_function_entry class_GearmanTask_methods[] = {
ZEND_ME(GearmanTask, __construct, arginfo_class_GearmanTask___construct, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(returnCode, gearman_task_return_code, arginfo_class_GearmanTask_returnCode, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(functionName, gearman_task_function_name, arginfo_class_GearmanTask_functionName, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(unique, gearman_task_unique, arginfo_class_GearmanTask_unique, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(jobHandle, gearman_task_job_handle, arginfo_class_GearmanTask_jobHandle, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(isKnown, gearman_task_is_known, arginfo_class_GearmanTask_isKnown, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(isRunning, gearman_task_is_running, arginfo_class_GearmanTask_isRunning, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(taskNumerator, gearman_task_numerator, arginfo_class_GearmanTask_taskNumerator, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(taskDenominator, gearman_task_denominator, arginfo_class_GearmanTask_taskDenominator, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(data, gearman_task_data, arginfo_class_GearmanTask_data, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(dataSize, gearman_task_data_size, arginfo_class_GearmanTask_dataSize, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(sendWorkload, gearman_task_send_workload, arginfo_class_GearmanTask_sendWorkload, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(recvData, gearman_task_recv_data, arginfo_class_GearmanTask_recvData, ZEND_ACC_PUBLIC)
ZEND_FE_END
};
static const zend_function_entry class_GearmanWorker_methods[] = {
ZEND_ME(GearmanWorker, __construct, arginfo_class_GearmanWorker___construct, ZEND_ACC_PUBLIC)
ZEND_ME(GearmanWorker, __destruct, arginfo_class_GearmanWorker___destruct, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(returnCode, gearman_worker_return_code, arginfo_class_GearmanWorker_returnCode, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(error, gearman_worker_error, arginfo_class_GearmanWorker_error, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(getErrno, gearman_worker_errno, arginfo_class_GearmanWorker_getErrno, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(options, gearman_worker_options, arginfo_class_GearmanWorker_options, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(setOptions, gearman_worker_set_options, arginfo_class_GearmanWorker_setOptions, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(addOptions, gearman_worker_add_options, arginfo_class_GearmanWorker_addOptions, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(removeOptions, gearman_worker_remove_options, arginfo_class_GearmanWorker_removeOptions, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(timeout, gearman_worker_timeout, arginfo_class_GearmanWorker_timeout, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(setTimeout, gearman_worker_set_timeout, arginfo_class_GearmanWorker_setTimeout, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(setId, gearman_worker_set_id, arginfo_class_GearmanWorker_setId, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(addServer, gearman_worker_add_server, arginfo_class_GearmanWorker_addServer, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(addServers, gearman_worker_add_servers, arginfo_class_GearmanWorker_addServers, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(wait, gearman_worker_wait, arginfo_class_GearmanWorker_wait, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(register, gearman_worker_register, arginfo_class_GearmanWorker_register, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(unregister, gearman_worker_unregister, arginfo_class_GearmanWorker_unregister, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(unregisterAll, gearman_worker_unregister_all, arginfo_class_GearmanWorker_unregisterAll, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(grabJob, gearman_worker_grab_job, arginfo_class_GearmanWorker_grabJob, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(addFunction, gearman_worker_add_function, arginfo_class_GearmanWorker_addFunction, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(work, gearman_worker_work, arginfo_class_GearmanWorker_work, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(ping, gearman_worker_ping, arginfo_class_GearmanWorker_ping, ZEND_ACC_PUBLIC)
ZEND_ME_MAPPING(enableExceptionHandler, gearman_worker_enable_exception_handler, arginfo_class_GearmanWorker_enableExceptionHandler, ZEND_ACC_PUBLIC)
ZEND_FE_END
};
static const zend_function_entry class_GearmanException_methods[] = {
ZEND_FE_END
};
gearman-2.1.2/gearman.stub.php 0000644 0001750 0001750 00000044014 14603537402 015642 0 ustar rasmus rasmus ,
* Eric Day
* All rights reserved.
*
* Use and distribution licensed under the PHP license. See
* the LICENSE file in this directory for full text.
*/
#include "php_gearman_job.h"
inline gearman_job_obj *gearman_job_fetch_object(zend_object *obj) {
return (gearman_job_obj *)((char*)(obj) - XtOffsetOf(gearman_job_obj, std));
}
/* {{{ proto object GearmanJob::__destruct()
cleans up GearmanJob object */
PHP_METHOD(GearmanJob, __destruct) {
gearman_job_obj *intern = Z_GEARMAN_JOB_P(getThis());
if (!intern) {
return;
}
if (intern->flags & GEARMAN_JOB_OBJ_CREATED) {
gearman_job_free(intern->job);
intern->flags &= ~GEARMAN_JOB_OBJ_CREATED;
}
}
/* }}} */
zend_object *gearman_job_obj_new(zend_class_entry *ce) {
gearman_job_obj *intern = ecalloc(1,
sizeof(gearman_job_obj) +
zend_object_properties_size(ce));
zend_object_std_init(&(intern->std), ce);
object_properties_init(&intern->std, ce);
intern->std.handlers = &gearman_job_obj_handlers;
return &intern->std;
}
/* {{{ proto int gearman_job_return_code()
get last gearman_return_t */
PHP_FUNCTION(gearman_job_return_code) {
gearman_job_obj *obj;
zval *zobj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_job_ce) == FAILURE) {
RETURN_NULL();
}
obj = Z_GEARMAN_JOB_P(zobj);
RETURN_LONG(obj->ret);
}
/* }}} */
/* {{{ proto bool gearman_job_set_return(int gearman_return_t)
This function will set a return value of a job */
PHP_FUNCTION(gearman_job_set_return) {
zval *zobj;
gearman_job_obj *obj;
gearman_return_t ret;
zend_long ret_val;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &zobj, gearman_job_ce, &ret_val) == FAILURE) {
RETURN_NULL();
}
obj = Z_GEARMAN_JOB_P(zobj);
ret = ret_val;
/* make sure its a valid gearman_return_t */
if (ret < GEARMAN_SUCCESS || ret > GEARMAN_MAX_RETURN) {
php_error_docref(NULL, E_WARNING,
"Invalid gearman_return_t: %d", ret);
RETURN_FALSE;
}
obj->ret = ret;
RETURN_TRUE;
}
/* }}} */
/* {{{ proto bool gearman_job_send_data(object job, string data)
Send data for a running job. */
PHP_FUNCTION(gearman_job_send_data) {
zval *zobj;
gearman_job_obj *obj;
char *data;
size_t data_len;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &zobj, gearman_job_ce,
&data, &data_len) == FAILURE) {
RETURN_NULL();
}
obj = Z_GEARMAN_JOB_P(zobj);
/* make sure worker initialized a job */
if (obj->job == NULL) {
RETURN_FALSE;
}
obj->ret = gearman_job_send_data(obj->job, data, data_len);
if (obj->ret != GEARMAN_SUCCESS && obj->ret != GEARMAN_IO_WAIT) {
php_error_docref(NULL, E_WARNING, "%s",
gearman_job_error(obj->job));
RETURN_FALSE;
}
RETURN_TRUE;
}
/* }}} */
/* {{{ proto bool gearman_job_send_warning(object job, string warning)
Send warning for a running job. */
PHP_FUNCTION(gearman_job_send_warning) {
zval *zobj;
gearman_job_obj *obj;
char *warning = NULL;
size_t warning_len = 0;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &zobj, gearman_job_ce,
&warning, &warning_len) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_JOB_P(zobj);
/* make sure worker initialized a job */
if (obj->job == NULL) {
RETURN_FALSE;
}
obj->ret = gearman_job_send_warning(obj->job, (void *) warning,
(size_t) warning_len);
if (obj->ret != GEARMAN_SUCCESS && obj->ret != GEARMAN_IO_WAIT) {
php_error_docref(NULL, E_WARNING, "%s",
gearman_job_error(obj->job));
RETURN_FALSE;
}
RETURN_TRUE;
}
/* }}} */
/* {{{ proto bool gearman_job_send_status(object job, int numerator, int denominator)
Send status information for a running job. */
PHP_FUNCTION(gearman_job_send_status) {
zval *zobj;
gearman_job_obj *obj;
zend_long numerator, denominator;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll", &zobj, gearman_job_ce,
&numerator, &denominator) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_JOB_P(zobj);
obj->ret = gearman_job_send_status(obj->job, (uint32_t)numerator,
(uint32_t)denominator);
if (obj->ret != GEARMAN_SUCCESS && obj->ret != GEARMAN_IO_WAIT) {
php_error_docref(NULL, E_WARNING, "%s",
gearman_job_error(obj->job));
RETURN_FALSE;
}
RETURN_TRUE;
}
/* }}} */
/* {{{ proto bool gearman_job_send_complete(object job, string result)
Send result and complete status for a job. */
PHP_FUNCTION(gearman_job_send_complete) {
zval *zobj;
gearman_job_obj *obj;
char *result;
size_t result_len;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &zobj, gearman_job_ce,
&result, &result_len) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_JOB_P(zobj);
obj->ret = gearman_job_send_complete(obj->job, result, result_len);
if (obj->ret != GEARMAN_SUCCESS && obj->ret != GEARMAN_IO_WAIT) {
php_error_docref(NULL, E_WARNING, "%s",
gearman_job_error(obj->job));
RETURN_FALSE;
}
RETURN_TRUE;
}
/* }}} */
/* {{{ proto bool gearman_job_send_exception(object job, string exception)
Send exception for a running job. */
PHP_FUNCTION(gearman_job_send_exception) {
zval *zobj;
gearman_job_obj *obj;
char *exception;
size_t exception_len;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &zobj, gearman_job_ce,
&exception, &exception_len) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_JOB_P(zobj);
obj->ret= gearman_job_send_exception(obj->job, exception, exception_len);
if (obj->ret != GEARMAN_SUCCESS && obj->ret != GEARMAN_IO_WAIT) {
php_error_docref(NULL, E_WARNING, "%s",
gearman_job_error(obj->job));
RETURN_FALSE;
}
RETURN_TRUE;
}
/* }}} */
/* {{{ proto bool gearman_job_send_fail(object job)
Send fail status for a job. */
PHP_FUNCTION(gearman_job_send_fail) {
zval *zobj;
gearman_job_obj *obj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_job_ce) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_JOB_P(zobj);
obj->ret = gearman_job_send_fail(obj->job);
if (obj->ret != GEARMAN_SUCCESS && obj->ret != GEARMAN_IO_WAIT) {
php_error_docref(NULL, E_WARNING, "%s",
gearman_job_error(obj->job));
RETURN_FALSE;
}
RETURN_TRUE;
}
/* }}} */
/* {{{ proto false|string gearman_job_handle(object job)
Return job handle. */
PHP_FUNCTION(gearman_job_handle) {
zval *zobj;
gearman_job_obj *obj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_job_ce) == FAILURE) {
RETURN_NULL();
}
obj = Z_GEARMAN_JOB_P(zobj);
/* make sure worker initialized a job */
if (obj->job == NULL) {
RETURN_FALSE;
}
RETURN_STRING((char *)gearman_job_handle(obj->job));
}
/* }}} */
/* {{{ proto false|string gearman_job_function_name(object job)
Return the function name associated with a job. */
PHP_FUNCTION(gearman_job_function_name) {
zval *zobj;
gearman_job_obj *obj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_job_ce) == FAILURE) {
RETURN_NULL();
}
obj = Z_GEARMAN_JOB_P(zobj);
/* make sure worker initialized a job */
if (obj->job == NULL) {
RETURN_FALSE;
}
RETURN_STRING((char *)gearman_job_function_name(obj->job));
}
/* }}} */
/* {{{ proto false|string gearman_job_unique(object job)
Get the unique ID associated with a job. */
PHP_FUNCTION(gearman_job_unique) {
zval *zobj;
gearman_job_obj *obj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_job_ce) == FAILURE) {
RETURN_NULL();
}
obj = Z_GEARMAN_JOB_P(zobj);
/* make sure worker initialized a job */
if (obj->job == NULL) {
RETURN_FALSE;
}
RETURN_STRING((char *)gearman_job_unique(obj->job));
}
/* }}} */
/* {{{ proto string gearman_job_workload(object job)
Returns the workload for a job. */
PHP_FUNCTION(gearman_job_workload) {
zval *zobj;
gearman_job_obj *obj;
const uint8_t *workload;
size_t workload_len;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_job_ce) == FAILURE) {
RETURN_NULL();
}
obj = Z_GEARMAN_JOB_P(zobj);
workload = gearman_job_workload(obj->job);
workload_len = gearman_job_workload_size(obj->job);
RETURN_STRINGL((char *)workload, (long) workload_len);
}
/* }}} */
/* {{{ proto int gearman_job_workload_size(object job)
Returns size of the workload for a job. */
PHP_FUNCTION(gearman_job_workload_size) {
zval *zobj;
gearman_job_obj *obj;
size_t workload_len;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_job_ce) == FAILURE) {
RETURN_NULL();
}
obj = Z_GEARMAN_JOB_P(zobj);
workload_len = gearman_job_workload_size(obj->job);
RETURN_LONG((long) workload_len);
}
/* }}} */
gearman-2.1.2/php_gearman_job.h 0000644 0001750 0001750 00000002221 14603537402 016021 0 ustar rasmus rasmus /*
* Gearman PHP Extension
*
* Copyright (C) 2008 James M. Luedke ,
* Eric Day
* All rights reserved.
*
* Use and distribution licensed under the PHP license. See
* the LICENSE file in this directory for full text.
*/
#ifndef __PHP_GEARMAN_JOB_H
#define __PHP_GEARMAN_JOB_H
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "zend_exceptions.h"
#include "zend_interfaces.h"
#include "php_gearman.h"
#include
#include
#include
extern zend_class_entry *gearman_job_ce;
extern zend_object_handlers gearman_job_obj_handlers;
zend_object *gearman_job_obj_new(zend_class_entry *ce);
typedef enum {
GEARMAN_JOB_OBJ_CREATED = (1 << 0)
} gearman_job_obj_flags_t;
typedef struct {
gearman_return_t ret;
gearman_job_obj_flags_t flags;
gearman_job_st *job;
zend_object std;
} gearman_job_obj;
gearman_job_obj *gearman_job_fetch_object(zend_object *obj);
#define Z_GEARMAN_JOB_P(zv) gearman_job_fetch_object(Z_OBJ_P((zv)))
#endif /* __PHP_GEARMAN_JOB_H */
gearman-2.1.2/php_gearman_task.c 0000644 0001750 0001750 00000030554 14603537402 016216 0 ustar rasmus rasmus /*
* Gearman PHP Extension
*
* Copyright (C) 2008 James M. Luedke ,
* Eric Day
* All rights reserved.
*
* Use and distribution licensed under the PHP license. See
* the LICENSE file in this directory for full text.
*/
#include "php_gearman_task.h"
inline gearman_task_obj *gearman_task_fetch_object(zend_object *obj) {
return (gearman_task_obj *)((char*)(obj) - XtOffsetOf(gearman_task_obj, std));
}
inline zend_object *gearman_task_obj_new(zend_class_entry *ce) {
gearman_task_obj *intern = ecalloc(1,
sizeof(gearman_task_obj) +
zend_object_properties_size(ce));
zend_object_std_init(&(intern->std), ce);
object_properties_init(&intern->std, ce);
intern->task_id = 0;
intern->std.handlers = &gearman_task_obj_handlers;
return &intern->std;
}
/* this function will be used to call our user defined task callbacks */
gearman_return_t _php_task_cb_fn(gearman_task_obj *task, gearman_client_obj *client, zval zcall) {
gearman_return_t ret;
zval ztask, argv[2], retval;
uint32_t param_count;
ZVAL_OBJ(&ztask, &task->std);
ZVAL_COPY_VALUE(&argv[0], &ztask);
if (Z_ISUNDEF(task->zdata)) {
param_count = 1;
} else {
ZVAL_COPY_VALUE(&argv[1], &task->zdata);
param_count = 2;
}
if (call_user_function(EG(function_table), NULL, &zcall, &retval, param_count, argv) != SUCCESS) {
php_error_docref(NULL,
E_WARNING,
"Could not call the function %s",
( Z_ISUNDEF(zcall) || Z_TYPE(zcall) != IS_STRING) ? "[undefined]" : Z_STRVAL(zcall)
);
ret = 0;
} else {
if (Z_ISUNDEF(retval)) {
ret = 0;
} else {
if (Z_TYPE(retval) != IS_LONG) {
convert_to_long(&retval);
}
ret = Z_LVAL(retval);
}
}
return ret;
}
void _php_task_free(gearman_task_st *task, void *context) {
gearman_task_obj *task_obj= (gearman_task_obj *) context;
gearman_client_obj *cli_obj = Z_GEARMAN_CLIENT_P(&task_obj->zclient);
task_obj->flags &= ~GEARMAN_TASK_OBJ_CREATED;
zend_hash_index_del(Z_ARRVAL(cli_obj->task_list), task_obj->task_id);
}
/* TODO: clean this up a bit, Macro? */
gearman_return_t _php_task_workload_fn(gearman_task_st *task) {
gearman_task_obj *task_obj = (gearman_task_obj *) gearman_task_context(task);
gearman_client_obj *client_obj = Z_GEARMAN_CLIENT_P(&task_obj->zclient);
return _php_task_cb_fn(task_obj, client_obj, client_obj->zworkload_fn);
}
gearman_return_t _php_task_created_fn(gearman_task_st *task) {
gearman_task_obj *task_obj = (gearman_task_obj *) gearman_task_context(task);
gearman_client_obj *client_obj = Z_GEARMAN_CLIENT_P(&task_obj->zclient);
return _php_task_cb_fn(task_obj, client_obj, client_obj->zcreated_fn);
}
gearman_return_t _php_task_data_fn(gearman_task_st *task) {
gearman_task_obj *task_obj = (gearman_task_obj *) gearman_task_context(task);
gearman_client_obj *client_obj = Z_GEARMAN_CLIENT_P(&task_obj->zclient);
return _php_task_cb_fn(task_obj, client_obj, client_obj->zdata_fn);
}
gearman_return_t _php_task_warning_fn(gearman_task_st *task) {
gearman_task_obj *task_obj = (gearman_task_obj *) gearman_task_context(task);
gearman_client_obj *client_obj = Z_GEARMAN_CLIENT_P(&task_obj->zclient);
return _php_task_cb_fn(task_obj, client_obj, client_obj->zwarning_fn);
}
gearman_return_t _php_task_status_fn(gearman_task_st *task) {
gearman_task_obj *task_obj = (gearman_task_obj *) gearman_task_context(task);
gearman_client_obj *client_obj = Z_GEARMAN_CLIENT_P(&task_obj->zclient);
return _php_task_cb_fn(task_obj, client_obj, client_obj->zstatus_fn);
}
gearman_return_t _php_task_complete_fn(gearman_task_st *task) {
gearman_task_obj *task_obj = (gearman_task_obj *) gearman_task_context(task);
gearman_client_obj *client_obj = Z_GEARMAN_CLIENT_P(&task_obj->zclient);
return _php_task_cb_fn(task_obj, client_obj, client_obj->zcomplete_fn);
}
gearman_return_t _php_task_exception_fn(gearman_task_st *task) {
gearman_task_obj *task_obj = (gearman_task_obj *) gearman_task_context(task);
gearman_client_obj *client_obj = Z_GEARMAN_CLIENT_P(&task_obj->zclient);
return _php_task_cb_fn(task_obj, client_obj, client_obj->zexception_fn);
}
gearman_return_t _php_task_fail_fn(gearman_task_st *task) {
gearman_task_obj *task_obj = (gearman_task_obj *) gearman_task_context(task);
gearman_client_obj *client_obj = Z_GEARMAN_CLIENT_P(&task_obj->zclient);
return _php_task_cb_fn(task_obj, client_obj, client_obj->zfail_fn);
}
/* {{{ proto object GearmanTask::__construct()
Returns a task object */
PHP_METHOD(GearmanTask, __construct) {
}
void gearman_task_free_obj(zend_object *object) {
gearman_task_obj *intern = gearman_task_fetch_object(object);
if (!intern) {
return;
}
zval_dtor(&intern->zworkload);
zval_dtor(&intern->zdata);
zval_dtor(&intern->zclient);
zend_object_std_dtor(&intern->std);
}
/* {{{ proto int gearman_task_return_code()
get last gearman_return_t */
PHP_FUNCTION(gearman_task_return_code) {
zval *zobj;
gearman_task_obj *obj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_task_ce) == FAILURE) {
RETURN_NULL();
}
obj = Z_GEARMAN_TASK_P(zobj);
RETURN_LONG(obj->ret);
}
/* }}} */
/* {{{ proto false|string gearman_task_function_name(object task)
Returns function name associated with a task. */
PHP_FUNCTION(gearman_task_function_name) {
zval *zobj;
gearman_task_obj *obj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_task_ce) == FAILURE) {
RETURN_NULL();
}
obj = Z_GEARMAN_TASK_P(zobj);
if (obj->flags & GEARMAN_TASK_OBJ_CREATED) {
RETURN_STRING((char *)gearman_task_function_name(obj->task));
}
RETURN_FALSE;
}
/* }}} */
/* {{{ proto false|string gearman_task_unique(object task)
Returns unique identifier for a task. */
PHP_FUNCTION(gearman_task_unique) {
zval *zobj;
gearman_task_obj *obj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_task_ce) == FAILURE) {
RETURN_NULL();
}
obj = Z_GEARMAN_TASK_P(zobj);
if (obj->flags & GEARMAN_TASK_OBJ_CREATED) {
RETURN_STRING((char *)gearman_task_unique(obj->task));
}
RETURN_FALSE;
}
/* }}} */
/* {{{ proto false|string gearman_task_job_handle(object task)
Returns job handle for a task. */
PHP_FUNCTION(gearman_task_job_handle) {
zval *zobj;
gearman_task_obj *obj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_task_ce) == FAILURE) {
RETURN_NULL();
}
obj = Z_GEARMAN_TASK_P(zobj);
if (obj->flags & GEARMAN_TASK_OBJ_CREATED) {
RETURN_STRING((char *)gearman_task_job_handle(obj->task));
}
RETURN_FALSE;
}
/* }}} */
/* {{{ proto bool gearman_task_is_known(object task)
Get status on whether a task is known or not */
PHP_FUNCTION(gearman_task_is_known) {
zval *zobj;
gearman_task_obj *obj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_task_ce) == FAILURE) {
RETURN_NULL();
}
obj = Z_GEARMAN_TASK_P(zobj);
if (obj->flags & GEARMAN_TASK_OBJ_CREATED) {
RETURN_BOOL(gearman_task_is_known(obj->task));
}
RETURN_FALSE;
}
/* }}} */
/* {{{ proto bool gearman_task_is_running(object task)
Get status on whether a task is running or not */
PHP_FUNCTION(gearman_task_is_running) {
zval *zobj;
gearman_task_obj *obj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_task_ce) == FAILURE) {
RETURN_NULL();
}
obj = Z_GEARMAN_TASK_P(zobj);
if (obj->flags & GEARMAN_TASK_OBJ_CREATED) {
RETURN_BOOL(gearman_task_is_running(obj->task));
}
RETURN_FALSE;
}
/* }}} */
/* {{{ proto false|int gearman_task_numerator(object task)
Returns the numerator of percentage complete for a task. */
PHP_FUNCTION(gearman_task_numerator) {
zval *zobj;
gearman_task_obj *obj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_task_ce) == FAILURE) {
RETURN_NULL();
}
obj = Z_GEARMAN_TASK_P(zobj);
if (obj->flags & GEARMAN_TASK_OBJ_CREATED) {
RETURN_LONG(gearman_task_numerator(obj->task));
}
RETURN_FALSE;
}
/* }}} */
/* {{{ proto false|int gearman_task_denominator(object task)
Returns the denominator of percentage complete for a task. */
PHP_FUNCTION(gearman_task_denominator) {
zval *zobj;
gearman_task_obj *obj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_task_ce) == FAILURE) {
RETURN_NULL();
}
obj = Z_GEARMAN_TASK_P(zobj);
if (obj->flags & GEARMAN_TASK_OBJ_CREATED) {
RETURN_LONG(gearman_task_denominator(obj->task));
}
RETURN_FALSE;
}
/* }}} */
/* {{{ proto false|string gearman_task_data(object task)
Get data being returned for a task. */
PHP_FUNCTION(gearman_task_data) {
zval *zobj;
gearman_task_obj *obj;
const uint8_t *data;
size_t data_len;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_task_ce) == FAILURE) {
RETURN_NULL();
}
obj = Z_GEARMAN_TASK_P(zobj);
if (obj->flags & GEARMAN_TASK_OBJ_CREATED &&
!gearman_client_has_option(&Z_GEARMAN_CLIENT_P(&obj->zclient)->client, GEARMAN_CLIENT_UNBUFFERED_RESULT)) {
data = gearman_task_data(obj->task);
data_len = gearman_task_data_size(obj->task);
RETURN_STRINGL((char *)data, (long) data_len);
}
RETURN_FALSE;
}
/* }}} */
/* {{{ proto false|int gearman_task_data_size(object task)
Get data size being returned for a task. */
PHP_FUNCTION(gearman_task_data_size) {
zval *zobj;
gearman_task_obj *obj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_task_ce) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_TASK_P(zobj);
if (obj->flags & GEARMAN_TASK_OBJ_CREATED) {
RETURN_LONG(gearman_task_data_size(obj->task));
}
RETURN_FALSE;
}
/* }}} */
/* {{{ proto false|int gearman_task_send_workload(object task, string data)
NOT-TESTED Send packet data for a task. */
PHP_FUNCTION(gearman_task_send_workload) {
zval *zobj;
gearman_task_obj *obj;
char *data;
size_t data_len;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &zobj, gearman_task_ce,
&data, &data_len) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_TASK_P(zobj);
if (!(obj->flags & GEARMAN_TASK_OBJ_CREATED)) {
RETURN_FALSE;
}
/* XXX verify that i am doing this correctly */
data_len = gearman_task_send_workload(obj->task, data, data_len, &obj->ret);
if (obj->ret != GEARMAN_SUCCESS)
{
php_error_docref(NULL, E_WARNING, "%s",
gearman_client_error(&Z_GEARMAN_CLIENT_P(&obj->zclient)->client));
RETURN_FALSE;
}
RETURN_LONG(data_len);
}
/* }}} */
/* {{{ proto false|array gearman_task_recv_data(object task, long buffer_size)
NOT-TESTED Read work or result data into a buffer for a task. */
PHP_FUNCTION(gearman_task_recv_data) {
zval *zobj;
gearman_task_obj *obj;
char *data_buffer;
zend_long data_buffer_size;
size_t data_len;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &zobj, gearman_task_ce,
&data_buffer_size) == FAILURE) {
RETURN_NULL();
}
obj = Z_GEARMAN_TASK_P(zobj);
if (!(obj->flags & GEARMAN_TASK_OBJ_CREATED)) {
RETURN_FALSE;
}
data_buffer= (char *) emalloc(data_buffer_size);
data_len= gearman_task_recv_data(obj->task, data_buffer, data_buffer_size,
&obj->ret);
if (obj->ret != GEARMAN_SUCCESS &&
!gearman_client_has_option(&Z_GEARMAN_CLIENT_P(&obj->zclient)->client, GEARMAN_CLIENT_UNBUFFERED_RESULT)) {
php_error_docref(NULL, E_WARNING, "%s",
gearman_client_error(&Z_GEARMAN_CLIENT_P(&obj->zclient)->client));
RETURN_FALSE;
}
array_init(return_value);
add_next_index_long(return_value, (long)data_len);
add_next_index_stringl(return_value, (char *)data_buffer,
(long)data_len);
}
/* }}} */
gearman-2.1.2/php_gearman_task.h 0000644 0001750 0001750 00000003734 14603537402 016223 0 ustar rasmus rasmus /*
* Gearman PHP Extension
*
* Copyright (C) 2008 James M. Luedke ,
* Eric Day
* All rights reserved.
*
* Use and distribution licensed under the PHP license. See
* the LICENSE file in this directory for full text.
*/
#ifndef __PHP_GEARMAN_TASK_H
#define __PHP_GEARMAN_TASK_H
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "zend_exceptions.h"
#include "zend_interfaces.h"
#include "php_gearman.h"
#include "php_gearman_client.h"
#include
#include
#include
void gearman_task_free_obj(zend_object *object);
zend_object *gearman_task_obj_new(zend_class_entry *ce);
extern zend_class_entry *gearman_task_ce;
extern zend_object_handlers gearman_task_obj_handlers;
typedef enum {
GEARMAN_TASK_OBJ_CREATED = (1 << 0),
} gearman_task_obj_flags_t;
typedef struct {
gearman_return_t ret;
gearman_task_obj_flags_t flags;
gearman_task_st *task;
zval zclient;
zval zdata;
zval zworkload;
zend_ulong task_id;
zend_object std;
} gearman_task_obj;
gearman_task_obj *gearman_task_fetch_object(zend_object *obj);
#define Z_GEARMAN_TASK_P(zv) gearman_task_fetch_object(Z_OBJ_P((zv)))
gearman_return_t _php_task_cb_fn(gearman_task_obj *task, gearman_client_obj *client, zval zcall);
void _php_task_free(gearman_task_st *task, void *context);
gearman_return_t _php_task_workload_fn(gearman_task_st *task);
gearman_return_t _php_task_created_fn(gearman_task_st *task);
gearman_return_t _php_task_data_fn(gearman_task_st *task);
gearman_return_t _php_task_warning_fn(gearman_task_st *task);
gearman_return_t _php_task_status_fn(gearman_task_st *task);
gearman_return_t _php_task_complete_fn(gearman_task_st *task);
gearman_return_t _php_task_exception_fn(gearman_task_st *task);
gearman_return_t _php_task_fail_fn(gearman_task_st *task);
#endif /* __PHP_GEARMAN_TASK_H */
gearman-2.1.2/php_gearman_worker.c 0000644 0001750 0001750 00000057314 14603537402 016570 0 ustar rasmus rasmus /*
* Gearman PHP Extension
*
* Copyright (C) 2008 James M. Luedke ,
* Eric Day
* All rights reserved.
*
* Use and distribution licensed under the PHP license. See
* the LICENSE file in this directory for full text.
*/
#include "php_gearman_worker.h"
gearman_worker_obj *gearman_worker_fetch_object(zend_object *obj) {
return (gearman_worker_obj *)((char*)(obj) - XtOffsetOf(gearman_worker_obj, std));
}
/* {{{ proto object gearman_worker_ctor()
Initialize a worker object. */
static void gearman_worker_ctor(INTERNAL_FUNCTION_PARAMETERS) {
gearman_worker_obj *worker;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
worker = Z_GEARMAN_WORKER_P(return_value);
if (gearman_worker_create(&(worker->worker)) == NULL) {
zval_dtor(return_value);
GEARMAN_EXCEPTION("Memory allocation failure", 0);
}
worker->flags |= GEARMAN_WORKER_OBJ_CREATED;
gearman_worker_set_workload_malloc_fn(&(worker->worker), _php_malloc, NULL);
gearman_worker_set_workload_free_fn(&(worker->worker), _php_free, NULL);
}
/* }}} */
/* {{{ proto object gearman_worker_create()
Returns a worker object */
PHP_FUNCTION(gearman_worker_create) {
if (object_init_ex(return_value, gearman_worker_ce) != SUCCESS) {
php_error_docref(NULL, E_WARNING,
"GearmanWorker Object creation failure.");
RETURN_FALSE;
}
gearman_worker_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
/* }}} */
/* {{{ proto object GearmanWorker::__construct()
Returns a worker object */
PHP_METHOD(GearmanWorker, __construct) {
return_value = getThis();
gearman_worker_ctor(INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
/* }}} */
/* {{{ proto object GearmanWorker::__destruct()
Destroys a worker object */
PHP_METHOD(GearmanWorker, __destruct) {
gearman_worker_obj *intern = Z_GEARMAN_WORKER_P(getThis());
if (!intern) {
return;
}
if (intern->flags & GEARMAN_WORKER_OBJ_CREATED) {
gearman_worker_free(&(intern->worker));
intern->flags &= ~GEARMAN_WORKER_OBJ_CREATED;
}
zval_dtor(&intern->cb_list);
}
/* }}} */
static inline void cb_list_dtor(zval *zv) {
gearman_worker_cb_obj *worker_cb = Z_PTR_P(zv);
zval_dtor(&worker_cb->zname);
zval_dtor(&worker_cb->zdata);
zval_dtor(&worker_cb->zcall);
efree(worker_cb);
}
zend_object *gearman_worker_obj_new(zend_class_entry *ce) {
gearman_worker_obj *intern = ecalloc(1,
sizeof(gearman_worker_obj) +
zend_object_properties_size(ce));
zend_object_std_init(&(intern->std), ce);
object_properties_init(&intern->std, ce);
array_init(&intern->cb_list);
zend_hash_init(Z_ARRVAL(intern->cb_list), 0, NULL, cb_list_dtor, 0);
intern->std.handlers = &gearman_worker_obj_handlers;
return &intern->std;
}
/* {{{ proto int gearman_worker_return_code()
get last gearman_return_t */
PHP_FUNCTION(gearman_worker_return_code) {
gearman_worker_obj *obj;
zval *zobj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_worker_ce) == FAILURE) {
RETURN_NULL();
}
obj = Z_GEARMAN_WORKER_P(zobj);
RETURN_LONG(obj->ret);
}
/* }}} */
/* {{{ proto string|false gearman_worker_error(object worker)
Return an error string for the last error encountered. */
PHP_FUNCTION(gearman_worker_error) {
char *error;
zval *zobj;
gearman_worker_obj *obj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_worker_ce) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_WORKER_P(zobj);
error = (char *)gearman_worker_error(&(obj->worker));
if (error) {
RETURN_STRING(error);
}
RETURN_FALSE;
}
/* }}} */
/* {{{ proto int gearman_worker_errno(object worker)
Value of errno in the case of a GEARMAN_ERRNO return value. */
PHP_FUNCTION(gearman_worker_errno) {
zval *zobj;
gearman_worker_obj *obj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_worker_ce) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_WORKER_P(zobj);
RETURN_LONG(gearman_worker_errno(&(obj->worker)));
}
/* }}} */
/* {{{ proto int gearman_worker_options(object worker)
Get options for a worker structure. */
PHP_FUNCTION(gearman_worker_options) {
zval *zobj;
gearman_worker_obj *obj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_worker_ce) == FAILURE) {
RETURN_NULL();
}
obj = Z_GEARMAN_WORKER_P(zobj);
RETURN_LONG(gearman_worker_options(&(obj->worker)));
}
/* }}} */
/* {{{ proto true gearman_worker_set_options(object worker, constant option)
Set options for a worker structure. */
PHP_FUNCTION(gearman_worker_set_options) {
zval *zobj;
gearman_worker_obj *obj;
zend_long options;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &zobj, gearman_worker_ce, &options) == FAILURE) {
RETURN_NULL();
}
obj = Z_GEARMAN_WORKER_P(zobj);
gearman_worker_set_options(&(obj->worker), options);
RETURN_TRUE;
}
/* }}} */
/* {{{ proto true gearman_worker_add_options(object worker, constant option)
Set options for a worker structure. */
PHP_FUNCTION(gearman_worker_add_options) {
zval *zobj;
gearman_worker_obj *obj;
zend_long options;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &zobj, gearman_worker_ce, &options) == FAILURE) {
RETURN_NULL();
}
obj = Z_GEARMAN_WORKER_P(zobj);
gearman_worker_add_options(&(obj->worker), options);
RETURN_TRUE;
}
/* }}} */
/* {{{ proto true gearman_worker_remove_options(object worker, constant option)
Set options for a worker structure. */
PHP_FUNCTION(gearman_worker_remove_options) {
zval *zobj;
gearman_worker_obj *obj;
zend_long options;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &zobj, gearman_worker_ce, &options) == FAILURE) {
RETURN_NULL();
}
obj = Z_GEARMAN_WORKER_P(zobj);
gearman_worker_remove_options(&(obj->worker), options);
RETURN_TRUE;
}
/* }}} */
/* {{{ proto int gearman_worker_timeout(object worker)
Get timeout for a worker structure. */
PHP_FUNCTION(gearman_worker_timeout) {
zval *zobj;
gearman_worker_obj *obj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_worker_ce) == FAILURE) {
RETURN_NULL();
}
obj = Z_GEARMAN_WORKER_P(zobj);
RETURN_LONG(gearman_worker_timeout(&(obj->worker)));
}
/* }}} */
/* {{{ proto true gearman_worker_set_timeout(object worker, constant timeout)
Set timeout for a worker structure. */
PHP_FUNCTION(gearman_worker_set_timeout) {
zval *zobj;
gearman_worker_obj *obj;
zend_long timeout;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &zobj, gearman_worker_ce, &timeout) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_WORKER_P(zobj);
gearman_worker_set_timeout(&(obj->worker), timeout);
RETURN_TRUE;
}
/* }}} */
/* {{{ proto bool gearman_worker_set_id(object worker, string id)
Set id for a worker structure. */
PHP_FUNCTION(gearman_worker_set_id) {
zval *zobj;
gearman_worker_obj *obj;
char *id;
size_t id_len;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &zobj, gearman_worker_ce,
&id, &id_len) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_WORKER_P(zobj);
if(gearman_failed(gearman_worker_set_identifier(&(obj->worker), id, id_len))) {
RETURN_FALSE;
}
RETURN_TRUE;
}
/* }}} */
/* {{{ proto bool gearman_worker_add_server(object worker [, string host [, int port [, bool setupExceptionHandler = true]]])
Add a job server to a worker. This goes into a list of servers than can be used to run tasks. No socket I/O happens here, it is just added to a list. */
PHP_FUNCTION(gearman_worker_add_server) {
zval *zobj;
gearman_worker_obj *obj;
char *host = NULL;
size_t host_len = 0;
zend_long port = 0;
zend_bool setupExceptionHandler = 1;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|slb", &zobj,
gearman_worker_ce,
&host, &host_len,
&port,
&setupExceptionHandler
) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_WORKER_P(zobj);
obj->ret = gearman_worker_add_server(&obj->worker, host, port);
if (obj->ret != GEARMAN_SUCCESS) {
php_error_docref(NULL, E_WARNING, "%s",
gearman_worker_error(&obj->worker));
RETURN_FALSE;
}
if (setupExceptionHandler && !gearman_worker_set_server_option(&(obj->worker), "exceptions", (sizeof("exceptions") - 1))) {
GEARMAN_EXCEPTION("Failed to set exception option", 0);
}
RETURN_TRUE;
}
/* }}} */
/* {{{ proto bool gearman_worker_add_servers(object worker [, string servers [, bool setupExceptionHandler = true]])
Add a list of job servers to a worker. This goes into a list of servers that can be used to run tasks. No socket I/O happens here, it is just added to a list. */
PHP_FUNCTION(gearman_worker_add_servers) {
zval *zobj;
gearman_worker_obj *obj;
char *servers = NULL;
size_t servers_len = 0;
zend_bool setupExceptionHandler = 1;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|sb", &zobj,
gearman_worker_ce,
&servers,
&servers_len,
&setupExceptionHandler
) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_WORKER_P(zobj);
obj->ret = gearman_worker_add_servers(&obj->worker, servers);
if (obj->ret != GEARMAN_SUCCESS) {
php_error_docref(NULL, E_WARNING, "%s",
gearman_worker_error(&obj->worker));
RETURN_FALSE;
}
if (setupExceptionHandler && !gearman_worker_set_server_option(&(obj->worker), "exceptions", (sizeof("exceptions") - 1))) {
GEARMAN_EXCEPTION("Failed to set exception option", 0);
}
RETURN_TRUE;
}
/* }}} */
/* {{{ proto bool gearman_worker_wait(object worker)
Wait for I/O activity on all connections in a worker. */
PHP_FUNCTION(gearman_worker_wait) {
zval *zobj;
gearman_worker_obj *obj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_worker_ce) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_WORKER_P(zobj);
obj->ret = gearman_worker_wait(&(obj->worker));
if (! PHP_GEARMAN_CLIENT_RET_OK(obj->ret)) {
if (obj->ret != GEARMAN_TIMEOUT) {
php_error_docref(NULL, E_WARNING, "%s",
gearman_worker_error(&(obj->worker)));
}
RETURN_FALSE;
}
RETURN_TRUE;
}
/* }}} */
/* {{{ proto bool gearman_worker_register(object worker, string function [, int timeout ])
Register function with job servers with an optional timeout. The timeout specifies how many seconds the server will wait before marking a job as failed. If timeout is zero, there is no timeout. */
PHP_FUNCTION(gearman_worker_register) {
zval *zobj;
gearman_worker_obj *obj;
char *function_name;
size_t function_name_len;
zend_long timeout = 0;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os|l", &zobj, gearman_worker_ce,
&function_name, &function_name_len,
&timeout
) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_WORKER_P(zobj);
obj->ret = gearman_worker_register(&(obj->worker), function_name, timeout);
if (obj->ret != GEARMAN_SUCCESS) {
php_error_docref(NULL, E_WARNING, "%s",
gearman_worker_error(&(obj->worker)));
RETURN_FALSE;
}
RETURN_TRUE;
}
/* }}} */
/* {{{ proto bool gearman_worker_unregister(object worker, string function)
Unregister function with job servers. */
PHP_FUNCTION(gearman_worker_unregister) {
zval *zobj;
gearman_worker_obj *obj;
char *function_name;
size_t function_name_len;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &zobj, gearman_worker_ce,
&function_name, &function_name_len
) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_WORKER_P(zobj);
obj->ret = gearman_worker_unregister(&(obj->worker), function_name);
if (obj->ret != GEARMAN_SUCCESS) {
php_error_docref(NULL, E_WARNING, "%s",
gearman_worker_error(&(obj->worker)));
RETURN_FALSE;
}
RETURN_TRUE;
}
/* }}} */
/* {{{ proto bool gearman_worker_unregister_all(object worker)
Unregister all functions with job servers. */
PHP_FUNCTION(gearman_worker_unregister_all) {
zval *zobj;
gearman_worker_obj *obj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_worker_ce) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_WORKER_P(zobj);
obj->ret= gearman_worker_unregister_all(&(obj->worker));
if (obj->ret != GEARMAN_SUCCESS) {
php_error_docref(NULL, E_WARNING, "%s",
gearman_worker_error(&(obj->worker)));
RETURN_FALSE;
}
RETURN_TRUE;
}
/* }}} */
/* {{{ proto false|object gearman_worker_grab_job(obect worker)
Get a job from one of the job servers.
Note: EXPERIMENTAL - This is undocumented on php.net and needs a test*/
PHP_FUNCTION(gearman_worker_grab_job) {
zval *zobj;
gearman_worker_obj *obj;
gearman_job_obj *job;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_worker_ce) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_WORKER_P(zobj);
object_init_ex(return_value, gearman_job_ce);
job = Z_GEARMAN_JOB_P(return_value);
job->job = gearman_worker_grab_job(&(obj->worker), NULL, &obj->ret);
if (obj->ret != GEARMAN_SUCCESS && obj->ret != GEARMAN_IO_WAIT) {
php_error_docref(NULL, E_WARNING, "%s",
gearman_worker_error(&(obj->worker)));
zval_dtor(return_value);
RETURN_FALSE;
}
job->flags |= GEARMAN_JOB_OBJ_CREATED;
}
/* *job is passed in via gearman, need to convert that into a zval that
* is accessable in the user_defined php callback function */
static void *_php_worker_function_callback(gearman_job_st *job,
void *context,
size_t *result_size,
gearman_return_t *ret_ptr) {
zval zjob, message;
gearman_job_obj *jobj;
gearman_worker_cb_obj *worker_cb = (gearman_worker_cb_obj *)context;
char *result = NULL;
uint32_t param_count;
/* cb vars */
zval argv[2], retval;
/* first create our job object that will be passed to the callback */
if (object_init_ex(&zjob, gearman_job_ce) != SUCCESS) {
php_error_docref(NULL, E_WARNING, "Failed to create gearman_job_ce object.");
return result;
}
jobj = Z_GEARMAN_JOB_P(&zjob);
jobj->job = job;
ZVAL_COPY_VALUE(&argv[0], &zjob);
if (Z_ISUNDEF(worker_cb->zdata)) {
param_count = 1;
ZVAL_NULL(&argv[1]);
} else {
ZVAL_COPY(&argv[1], &worker_cb->zdata);
param_count = 2;
}
jobj->ret = GEARMAN_SUCCESS;
if (call_user_function(EG(function_table), NULL, &worker_cb->zcall, &retval, param_count, argv) != SUCCESS) {
php_error_docref(NULL,
E_WARNING,
"Could not call the function %s",
( Z_ISUNDEF(worker_cb->zcall) || Z_TYPE(worker_cb->zcall) != IS_STRING) ? "[undefined]" : Z_STRVAL(worker_cb->zcall)
);
jobj->ret = GEARMAN_WORK_FAIL;
}
*ret_ptr = jobj->ret;
if (EG(exception)) {
*ret_ptr = GEARMAN_WORK_EXCEPTION;
ZVAL_STRING(&message, "Unable to add worker function");
jobj->ret = gearman_job_send_exception(jobj->job, Z_STRVAL(message), Z_STRLEN(message));
if (jobj->ret != GEARMAN_SUCCESS && jobj->ret != GEARMAN_IO_WAIT) {
php_error_docref(NULL, E_WARNING, "Unable to add worker function: %s",
gearman_job_error(jobj->job));
}
}
if (Z_ISUNDEF(retval)) {
result = NULL;
*result_size = 0;
} else {
if (Z_TYPE(retval) != IS_STRING) {
convert_to_string(&retval);
}
result = estrndup(Z_STRVAL(retval), Z_STRLEN(retval));
*result_size = Z_STRLEN(retval);
zval_dtor(&retval);
}
if (!Z_ISUNDEF(argv[0])) {
zval_dtor(&argv[0]);
}
if (!Z_ISUNDEF(argv[1])) {
zval_dtor(&argv[1]);
}
return result;
}
/* }}} */
/* {{{ proto bool gearman_worker_add_function(object worker, zval function_name, zval callback [, zval data [, int timeout]])
Register and add callback function for worker. */
PHP_FUNCTION(gearman_worker_add_function) {
zval *zobj = NULL;
gearman_worker_obj *obj;
gearman_worker_cb_obj *worker_cb;
zval *zname, *zcall, *zdata = NULL;
zend_long timeout = 0;
zend_string *callable = NULL;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ozz|zl", &zobj, gearman_worker_ce,
&zname,
&zcall,
&zdata,
&timeout
) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_WORKER_P(zobj);
/* check that the function name is a string */
if (Z_TYPE_P(zname) != IS_STRING) {
php_error_docref(NULL, E_WARNING, "Function name must be a string");
RETURN_FALSE;
}
/* check that the function can be called */
if (!zend_is_callable(zcall, 0, &callable)) {
php_error_docref(NULL, E_WARNING, "Function '%s' is not a valid callback", ZSTR_VAL(callable));
zend_string_release(callable);
RETURN_FALSE;
}
zend_string_release(callable);
/* create a new worker cb */
worker_cb = emalloc(sizeof(gearman_worker_cb_obj));
// Name of the callback function
ZVAL_COPY(&worker_cb->zname, zname);
// Reference to the callback function
ZVAL_COPY(&worker_cb->zcall, zcall);
// Additional data passed along to the callback function
if (zdata) {
ZVAL_COPY(&worker_cb->zdata,zdata);
} else {
ZVAL_NULL(&worker_cb->zdata);
}
// Add the worker_cb to the list
zend_hash_next_index_insert_ptr(Z_ARRVAL(obj->cb_list), worker_cb);
/* add the function */
/* NOTE: _php_worker_function_callback is a wrapper that calls
* the function defined by gearman_worker_add_function */
obj->ret = gearman_worker_add_function(&(obj->worker),
Z_STRVAL(worker_cb->zname),
(uint32_t)timeout,
_php_worker_function_callback,
(void *)worker_cb
);
if (obj->ret != GEARMAN_SUCCESS) {
php_error_docref(NULL, E_WARNING, "Unable to add function to Gearman Worker: %s %s",
gearman_worker_error(&(obj->worker)), gearman_strerror(obj->ret));
RETURN_FALSE;
}
RETURN_TRUE;
}
/* }}} */
/* {{{ proto bool gearman_worker_work(object worker)
Wait for a job and call the appropriate callback function when it gets one. */
PHP_FUNCTION(gearman_worker_work) {
zval *zobj = NULL;
gearman_worker_obj *obj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_worker_ce) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_WORKER_P(zobj);
obj->ret = gearman_worker_work(&(obj->worker));
if (obj->ret != GEARMAN_SUCCESS && obj->ret != GEARMAN_IO_WAIT &&
obj->ret != GEARMAN_WORK_FAIL && obj->ret != GEARMAN_TIMEOUT &&
obj->ret != GEARMAN_WORK_EXCEPTION && obj->ret != GEARMAN_NO_JOBS) {
php_error_docref(NULL, E_WARNING, "%s",
gearman_worker_error(&(obj->worker)));
RETURN_FALSE;
}
if (obj->ret != GEARMAN_SUCCESS) {
RETURN_FALSE;
}
RETURN_TRUE;
}
/* }}} */
/* {{{ proto bool gearman_worker_ping(object worker, string data)
Send data to all job servers to see if they echo it back. */
PHP_FUNCTION(gearman_worker_ping) {
zval *zobj;
gearman_worker_obj *obj;
char *workload;
size_t workload_len;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &zobj, gearman_worker_ce,
&workload, &workload_len) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_WORKER_P(zobj);
obj->ret = gearman_worker_echo(&(obj->worker), workload, (size_t)workload_len);
if (obj->ret != GEARMAN_SUCCESS && obj->ret != GEARMAN_IO_WAIT) {
php_error_docref(NULL, E_WARNING, "%s",
gearman_worker_error(&(obj->worker)));
RETURN_FALSE;
}
RETURN_TRUE;
}
/* }}} */
/* {{{ proto bool GearmanWorker::enableExceptionHandler()
Enable exception handling to be used by exception callback function
GearmanWorker::enableExceptionHandler */
PHP_FUNCTION(gearman_worker_enable_exception_handler) {
gearman_worker_obj *obj;
zval *zobj;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &zobj, gearman_worker_ce) == FAILURE) {
RETURN_FALSE;
}
obj = Z_GEARMAN_WORKER_P(zobj);
if (!gearman_worker_set_server_option(&(obj->worker), "exceptions", (sizeof("exceptions") - 1))) {
GEARMAN_EXCEPTION("Failed to set exception option", 0);
}
RETURN_TRUE;
}
/* }}} */
gearman-2.1.2/php_gearman_worker.h 0000644 0001750 0001750 00000002736 14603537402 016573 0 ustar rasmus rasmus /*
* Gearman PHP Extension
*
* Copyright (C) 2008 James M. Luedke ,
* Eric Day
* All rights reserved.
*
* Use and distribution licensed under the PHP license. See
* the LICENSE file in this directory for full text.
*/
#ifndef __PHP_GEARMAN_WORKER_H
#define __PHP_GEARMAN_WORKER_H
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "zend_exceptions.h"
#include "zend_interfaces.h"
#include "php_gearman.h"
#include "php_gearman_job.h"
#include "php_gearman_client.h"
#include
#include
#include
extern zend_class_entry *gearman_worker_ce;
extern zend_object_handlers gearman_worker_obj_handlers;
zend_object *gearman_worker_obj_new(zend_class_entry *ce);
typedef struct {
zval zname; /* name associated with callback */
zval zcall; /* name of callback */
zval zdata; /* data passed to callback via worker */
} gearman_worker_cb_obj;
typedef enum {
GEARMAN_WORKER_OBJ_CREATED = (1 << 0)
} gearman_worker_obj_flags_t;
typedef struct {
gearman_return_t ret;
gearman_worker_obj_flags_t flags;
gearman_worker_st worker;
zval cb_list;
zend_object std;
} gearman_worker_obj;
gearman_worker_obj *gearman_worker_fetch_object(zend_object *obj);
#define Z_GEARMAN_WORKER_P(zv) gearman_worker_fetch_object(Z_OBJ_P((zv)))
#endif /* __PHP_GEARMAN_WORKER_H */
gearman-2.1.2/tests/gearman_001.phpt 0000644 0001750 0001750 00000000315 14603537402 016570 0 ustar rasmus rasmus --TEST--
Check for gearman presence
--SKIPIF--
--FILE--
--EXPECT--
gearman extension is available
gearman-2.1.2/tests/gearman_002.phpt 0000644 0001750 0001750 00000000425 14603537402 016573 0 ustar rasmus rasmus --TEST--
gearman_worker_set_id()
--SKIPIF--
--FILE--
setId('test');
$worker = gearman_worker_create();
gearman_worker_set_id($worker, 'test');
echo "OK";
?>
--EXPECT--
OK
gearman-2.1.2/tests/connect.inc 0000644 0001750 0001750 00000000150 14603537402 016022 0 ustar rasmus rasmus
--FILE--
--EXPECT--
gearman extension is available
gearman-2.1.2/tests/gearman_002.phpt 0000644 0001750 0001750 00000000425 14603537402 016573 0 ustar rasmus rasmus --TEST--
gearman_worker_set_id()
--SKIPIF--
--FILE--
setId('test');
$worker = gearman_worker_create();
gearman_worker_set_id($worker, 'test');
echo "OK";
?>
--EXPECT--
OK
gearman-2.1.2/tests/gearman_client_001.phpt 0000644 0001750 0001750 00000000754 14603537402 020135 0 ustar rasmus rasmus --TEST--
new GearmanClient(), gearman_client_create()
--SKIPIF--
--FILE--
--EXPECT--
GearmanClient() (OO) class: GearmanClient
gearman_client_create() (Procedural) class: GearmanClient
OK
gearman-2.1.2/tests/gearman_client_002.phpt 0000644 0001750 0001750 00000000767 14603537402 020142 0 ustar rasmus rasmus --TEST--
GearmanClient::returnCode(), gearman_client_return_code()
--SKIPIF--
--FILE--
returnCode() . PHP_EOL;
$client2 = gearman_client_create();
print "gearman_client_return_code (Procedural): " . gearman_client_return_code($client2) . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanClient::returnCode (OO): 0
gearman_client_return_code (Procedural): 0
OK
gearman-2.1.2/tests/gearman_client_003.phpt 0000644 0001750 0001750 00000000713 14603537402 020132 0 ustar rasmus rasmus --TEST--
GearmanClient::error(), gearman_client_error()
--SKIPIF--
--FILE--
error() . "'\n";
$client2 = gearman_client_create();
print "gearman_client_error (Procedural): '" . gearman_client_error($client2) . "'\n";
print "OK";
?>
--EXPECT--
GearmanClient::error (OO): ''
gearman_client_error (Procedural): ''
OK
gearman-2.1.2/tests/gearman_client_004.phpt 0000644 0001750 0001750 00000000747 14603537402 020142 0 ustar rasmus rasmus --TEST--
GearmanClient::getErrno(), gearman_client_get_errno()
--SKIPIF--
--FILE--
getErrno() . PHP_EOL;
$client2 = gearman_client_create();
print "gearman_client_get_errno (Procedural): " . gearman_client_get_errno($client2) . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanClient::getErrno (OO): 0
gearman_client_get_errno (Procedural): 0
OK
gearman-2.1.2/tests/gearman_client_005.phpt 0000644 0001750 0001750 00000001040 14603537402 020126 0 ustar rasmus rasmus --TEST--
GearmanClient::options(), gearman_client_options()
--SKIPIF--
--FILE--
setOptions(32);
print "GearmanClient::options (OO): " . $client->options() . PHP_EOL;
$client2 = gearman_client_create();
gearman_client_set_options($client2, 32);
print "gearman_client_options (Procedural): " . gearman_client_options($client2) . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanClient::options (OO): 32
gearman_client_options (Procedural): 32
OK
gearman-2.1.2/tests/gearman_client_006.phpt 0000644 0001750 0001750 00000002204 14603537402 020132 0 ustar rasmus rasmus --TEST--
GearmanClient::setOptions(), gearman_client_set_options()
--SKIPIF--
--FILE--
setOptions(32);
print "GearmanClient::options (OO): " . $client->options() . PHP_EOL;
print "GearmanClient::setOptions (OO): " . ($client->setOptions(GEARMAN_CLIENT_NON_BLOCKING) ? 'Success' : 'Failure') . PHP_EOL;
print "GearmanClient::options (OO): " . $client->options() . PHP_EOL;
$client2 = gearman_client_create();
gearman_client_set_options($client2, 32);
print "gearman_client_options (Procedural): " . gearman_client_options($client2) . PHP_EOL;
print "gearman_client_set_options (Procedural): " . (gearman_client_set_options($client2, GEARMAN_CLIENT_NON_BLOCKING) ? 'Success' : 'Failure') . PHP_EOL;
print "gearman_client_options (Procedural): " . gearman_client_options($client2) . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanClient::options (OO): 32
GearmanClient::setOptions (OO): Success
GearmanClient::options (OO): 2
gearman_client_options (Procedural): 32
gearman_client_set_options (Procedural): Success
gearman_client_options (Procedural): 2
OK
gearman-2.1.2/tests/gearman_client_007.phpt 0000644 0001750 0001750 00000002262 14603537402 020137 0 ustar rasmus rasmus --TEST--
GearmanClient::addOptions(), gearman_client_add_options()
--SKIPIF--
--FILE--
setOptions(GEARMAN_CLIENT_NON_BLOCKING);
print "GearmanClient::options (OO): " . $client->options() . PHP_EOL;
print "GearmanClient::addOptions (OO): " . ($client->addOptions(GEARMAN_CLIENT_FREE_TASKS) ? 'Success' : 'Failure') . PHP_EOL;
print "GearmanClient::options (OO): " . $client->options() . PHP_EOL;
$client2 = gearman_client_create();
gearman_client_set_options($client2, GEARMAN_CLIENT_NON_BLOCKING);
print "gearman_client_options (Procedural): " . gearman_client_options($client2) . PHP_EOL;
print "gearman_client_add_options (Procedural): " . (gearman_client_add_options($client2, GEARMAN_CLIENT_FREE_TASKS) ? 'Success' : 'Failure') . PHP_EOL;
print "gearman_client_options (Procedural): " . gearman_client_options($client2) . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanClient::options (OO): 2
GearmanClient::addOptions (OO): Success
GearmanClient::options (OO): 34
gearman_client_options (Procedural): 2
gearman_client_add_options (Procedural): Success
gearman_client_options (Procedural): 34
OK
gearman-2.1.2/tests/gearman_client_008.phpt 0000644 0001750 0001750 00000002230 14603537402 020133 0 ustar rasmus rasmus --TEST--
GearmanClient::removeOptions(), gearman_client_remove_options()
--SKIPIF--
--FILE--
setOptions(32);
print "GearmanClient::options (OO): " . $client->options() . PHP_EOL;
print "GearmanClient::removeOptions (OO): " . ($client->removeOptions(GEARMAN_CLIENT_FREE_TASKS) ? 'Success' : 'Failure') . PHP_EOL;
print "GearmanClient::options (OO): " . $client->options() . PHP_EOL;
$client2 = gearman_client_create();
gearman_client_set_options($client2, 32);
print "gearman_client_options (Procedural): " . gearman_client_options($client2) . PHP_EOL;
print "gearman_client_remove_options (Procedural): " . (gearman_client_remove_options($client2, GEARMAN_CLIENT_FREE_TASKS) ? 'Success' : 'Failure') . PHP_EOL;
print "gearman_client_options (Procedural): " . gearman_client_options($client2) . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanClient::options (OO): 32
GearmanClient::removeOptions (OO): Success
GearmanClient::options (OO): 0
gearman_client_options (Procedural): 32
gearman_client_remove_options (Procedural): Success
gearman_client_options (Procedural): 0
OK
gearman-2.1.2/tests/gearman_client_009.phpt 0000644 0001750 0001750 00000000735 14603537402 020144 0 ustar rasmus rasmus --TEST--
GearmanClient::timeout(), gearman_client_timeout()
--SKIPIF--
--FILE--
timeout() . PHP_EOL;
$client2 = gearman_client_create();
print "gearman_client_timeout (Procedural): " . gearman_client_timeout($client2) . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanClient::timeout (OO): -1
gearman_client_timeout (Procedural): -1
OK
gearman-2.1.2/tests/gearman_client_010.phpt 0000644 0001750 0001750 00000002015 14603537402 020125 0 ustar rasmus rasmus --TEST--
GearmanClient::setTimeout(), gearman_client_set_timeout()
--SKIPIF--
--FILE--
timeout() . PHP_EOL;
print "GearmanClient::setTimeout (OO): " . ($client->setTimeout(3) ? 'Success' : 'Failure') . PHP_EOL;
print "GearmanClient::timeout (OO): " . $client->timeout() . PHP_EOL;
$client2 = gearman_client_create();
print "gearman_client_timeout (Procedural): " . gearman_client_timeout($client2) . PHP_EOL;
print "gearman_client_set_timeout (Procedural): " . (gearman_client_set_timeout($client2, 3) ? 'Success' : 'Failure') . PHP_EOL;
print "gearman_client_timeout (Procedural): " . gearman_client_timeout($client2) . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanClient::timeout (OO): -1
GearmanClient::setTimeout (OO): Success
GearmanClient::timeout (OO): 3
gearman_client_timeout (Procedural): -1
gearman_client_set_timeout (Procedural): Success
gearman_client_timeout (Procedural): 3
OK
gearman-2.1.2/tests/gearman_client_011.phpt 0000644 0001750 0001750 00000001675 14603537402 020141 0 ustar rasmus rasmus --TEST--
GearmanClient::context(), GearmanClient::setContext(), gearman_client_context(), gearman_client_set_context()
--SKIPIF--
--FILE--
setContext('context1_context1_context1_context1') ? 'Success' : 'Failure') . PHP_EOL;
print "GearmanClient::context (OO): " . $client->context() . PHP_EOL;
$client2 = gearman_client_create();
print "gearman_client_set_context (Procedural): " . (gearman_client_set_context($client2, 'context2_context2') ? 'Success' : 'Failure') . PHP_EOL;
print "gearman_client_context (Procedural): " . gearman_client_context($client2) . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanClient::setContext(OO): Success
GearmanClient::context (OO): context1_context1_context1_context1
gearman_client_set_context (Procedural): Success
gearman_client_context (Procedural): context2_context2
OK
gearman-2.1.2/tests/gearman_client_012.phpt 0000644 0001750 0001750 00000002065 14603537402 020134 0 ustar rasmus rasmus --TEST--
GearmanClient::addServer(), gearman_client_add_server()
--SKIPIF--
--FILE--
addServer('localhost') ? 'Success' : 'Failure') . PHP_EOL;
print "GearmanClient::addServer(OO), explicit port: " . ($client->addServer('localhost', 4730) ? 'Success' : 'Failure') . PHP_EOL;
$client2 = gearman_client_create();
print "gearman_client_add_server (Procedural), implicit port: " . (gearman_client_add_server($client2, 'localhost') ? 'Success' : 'Failure') . PHP_EOL;
print "gearman_client_add_server (Procedural): explicit port" . (gearman_client_add_server($client2, 'localhost', 4730) ? 'Success' : 'Failure') . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanClient::addServer(OO), implicit port: Success
GearmanClient::addServer(OO), explicit port: Success
gearman_client_add_server (Procedural), implicit port: Success
gearman_client_add_server (Procedural): explicit portSuccess
OK
gearman-2.1.2/tests/gearman_client_013.phpt 0000644 0001750 0001750 00000001214 14603537402 020130 0 ustar rasmus rasmus --TEST--
GearmanClient::addServers(), gearman_client_add_servers()
--SKIPIF--
--FILE--
addServers('localhost,localhost:4730') ? 'Success' : 'Failure') . PHP_EOL;
$client2 = gearman_client_create();
print "gearman_client_add_servers (Procedural): " . (gearman_client_add_servers($client2, 'localhost,localhost:4730') ? 'Success' : 'Failure') . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanClient::addServer(OO): Success
gearman_client_add_servers (Procedural): Success
OK
gearman-2.1.2/tests/gearman_client_014.phpt 0000644 0001750 0001750 00000001172 14603537402 020134 0 ustar rasmus rasmus --TEST--
GearmanClient::wait(), gearman_client_wait()
--SKIPIF--
--FILE--
addServer('localhost', 4730);
print "Placeholder for GearmanClient::wait function" . PHP_EOL;
/*
print "GearmanClient::wait (OO): " . ($client->wait() ? 'Success' : 'Failure') . PHP_EOL;
*/
$client2 = gearman_client_create();
/*
print "gearman_client_wait (Procedural): " . (gearman_client_wait($client2) ? 'Success' : 'Failure') . PHP_EOL;
*/
print "OK";
?>
--EXPECT--
Placeholder for GearmanClient::wait function
OK
gearman-2.1.2/tests/gearman_client_015.phpt 0000644 0001750 0001750 00000001641 14603537402 020136 0 ustar rasmus rasmus --TEST--
GearmanClient::doJobHandle(), gearman_client_do_job_handle()
--SKIPIF--
--FILE--
addServer('localhost', 4730);
$job_handle = $client->doBackground("test_doJobHandle", "test_doJobHandle");
print "GearmanClient::doJobHandle() (OO): "
. ($job_handle == $client->doJobHandle() ? 'Success' : 'Failure') . PHP_EOL;
$client2 = gearman_client_create();
gearman_client_add_server($client2, 'localhost', 4730);
$job_handle = gearman_client_do_background($client2, "test_do_job_handle", "test_do_job_handle");
print "gearman_client_do_job_handle() (Procedural): "
. ($job_handle == gearman_client_do_job_handle($client2) ? 'Success' : 'Failure') . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanClient::doJobHandle() (OO): Success
gearman_client_do_job_handle() (Procedural): Success
OK
gearman-2.1.2/tests/gearman_client_016.phpt 0000644 0001750 0001750 00000003126 14603537402 020137 0 ustar rasmus rasmus --TEST--
GearmanClient::doStatus(), gearman_client_do_status()
--SKIPIF--
--FILE--
addOptions(GEARMAN_CLIENT_NON_BLOCKING);
$client->addServer('localhost', 4730);
# Note: Still need to figure out why doNormal is blocking despite
# GEARMAN_CLIENT_NON_BLOCKING
#$job_handle = $client->doNormal($job_name . "_OO", "test_doStatus");
list($numerator, $denominator) = $client->doStatus();
print "GearmanClient::doStatus() (OO): " . PHP_EOL
. " Numerator is 0: " . ($numerator == 0 ? 'Success' : 'Failure') .
PHP_EOL
. " Denominator is 0: " . ($denominator == 0 ? 'Success' : 'Failure') .
PHP_EOL;
$client2 = gearman_client_create();
gearman_client_add_options($client2, GEARMAN_CLIENT_NON_BLOCKING);
gearman_client_add_server($client2, 'localhost', 4730);
# Note: Still need to figure out why doNormal is blocking despite
# GEARMAN_CLIENT_NON_BLOCKING
#$job_handle = gearman_client_do_normal->($client2, $job_name . "_procedural", "test_doStatus");
list($numerator, $denominator) = gearman_client_do_status($client2);
print "gearman_client_do_status() (Procedural): " . PHP_EOL
. " Numerator is 0: " . ($numerator == 0 ? 'Success' : 'Failure') .
PHP_EOL
. " Denominator is 0: " . ($denominator == 0 ? 'Success' : 'Failure') .
PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanClient::doStatus() (OO):
Numerator is 0: Success
Denominator is 0: Success
gearman_client_do_status() (Procedural):
Numerator is 0: Success
Denominator is 0: Success
OK
gearman-2.1.2/tests/gearman_client_017.phpt 0000644 0001750 0001750 00000003512 14603537402 020137 0 ustar rasmus rasmus --TEST--
GearmanClient::jobStatus(), gearman_client_job_status()
--SKIPIF--
--FILE--
addServer('localhost', 4730);
$job_handle = $client->doBackground($job_name . "_OO", "test_jobStatus");
list($is_known, $is_running, $numerator, $denominator) = $client->jobStatus($job_handle);
print "GearmanClient::jobStatus() (OO): " . PHP_EOL
. " is_known is true: " . ($is_known === true ? 'Success' : 'Failure') .
PHP_EOL
. " is_running is false: " . ($is_running=== false ? 'Success' : 'Failure') .
PHP_EOL
. " Numerator is 0: " . ($numerator == 0 ? 'Success' : 'Failure') .
PHP_EOL
. " Denominator is 0: " . ($denominator == 0 ? 'Success' : 'Failure') .
PHP_EOL;
$client2 = gearman_client_create();
gearman_client_add_server($client2, 'localhost', 4730);
$job_handle = gearman_client_do_background($client2, $job_name .
"_procedural", "test_jobStatus");
list($is_known, $is_running, $numerator, $denominator) =
gearman_client_job_status($client2, $job_handle);
print "gearman_client_job_status() (Procedural): " . PHP_EOL
. " is_known is true: " . ($is_known === true ? 'Success' : 'Failure') .
PHP_EOL
. " is_running is false: " . ($is_running === false ? 'Success' : 'Failure') .
PHP_EOL
. " Numerator is 0: " . ($numerator == 0 ? 'Success' : 'Failure') .
PHP_EOL
. " Denominator is 0: " . ($denominator == 0 ? 'Success' : 'Failure') .
PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanClient::jobStatus() (OO):
is_known is true: Success
is_running is false: Success
Numerator is 0: Success
Denominator is 0: Success
gearman_client_job_status() (Procedural):
is_known is true: Success
is_running is false: Success
Numerator is 0: Success
Denominator is 0: Success
OK
gearman-2.1.2/tests/gearman_client_018.phpt 0000644 0001750 0001750 00000004321 14603537402 020137 0 ustar rasmus rasmus --TEST--
GearmanClient::jobStatusByUniqueKey(), gearman_client_job_status_by_unique_key()
--SKIPIF--
--FILE--
addServer('localhost', 4730);
$oo_key = $job_name . "_oo";
$client->doBackground($job_name . "_OO", "test_jobStatusByUniqueKey");
list($is_known, $is_running, $numerator, $denominator) =
$client->jobStatusByUniqueKey($oo_key);
print "GearmanClient::doStatus() (OO): " . PHP_EOL
/*
Note: This is returning falso, while jobStatus returns true.
Looks to be across multiple versions of libgearman (1.0.2 and 1.1.2 checked)
. " is_known is true: " . ($is_known === true ? 'Success' : 'Failure') .
PHP_EOL
*/
. " is_running is false: " . ($is_running=== false ? 'Success' : 'Failure') .
PHP_EOL
. " Numerator is 0: " . ($numerator == 0 ? 'Success' : 'Failure') .
PHP_EOL
. " Denominator is 0: " . ($denominator == 0 ? 'Success' : 'Failure') .
PHP_EOL;
$client2 = gearman_client_create();
gearman_client_add_server($client2, 'localhost', 4730);
$procedural_key = $job_name . "_procedural";
$job_handle = gearman_client_do_background($client2, $job_name .
"_procedural", "test_jobStatusByUniqueKey");
list($is_known, $is_running, $numerator, $denominator) =
gearman_client_job_status_by_unique_key($client2, $procedural_key);
print "gearman_client_job_status_by_unique_key() (Procedural): " . PHP_EOL
/*
Note: This is returning falso, while jobStatus returns true.
Looks to be across multiple versions of libgearman (1.0.2 and 1.1.2 checked)
. " is_known is true: " . ($is_known === true ? 'Success' : 'Failure') .
PHP_EOL
*/
. " is_running is false: " . ($is_running === false ? 'Success' : 'Failure') .
PHP_EOL
. " Numerator is 0: " . ($numerator == 0 ? 'Success' : 'Failure') .
PHP_EOL
. " Denominator is 0: " . ($denominator == 0 ? 'Success' : 'Failure') .
PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanClient::doStatus() (OO):
is_running is false: Success
Numerator is 0: Success
Denominator is 0: Success
gearman_client_job_status_by_unique_key() (Procedural):
is_running is false: Success
Numerator is 0: Success
Denominator is 0: Success
OK
gearman-2.1.2/tests/gearman_client_019.phpt 0000644 0001750 0001750 00000001241 14603537402 020136 0 ustar rasmus rasmus --TEST--
GearmanClient::ping(), gearman_client_ping()
--SKIPIF--
--FILE--
addServer('localhost', 4730);
print "GearmanClient::ping (OO): " . ($client->ping('oo data') ? 'Success' : 'Failure') . PHP_EOL;
$client2 = gearman_client_create();
gearman_client_add_server($client2, 'localhost', 4730);
print "gearman_client_ping (Procedural): "
. (gearman_client_ping($client2,'procedural data') ? 'Success' : 'Failure') . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanClient::ping (OO): Success
gearman_client_ping (Procedural): Success
OK
gearman-2.1.2/tests/gearman_client_020.phpt 0000644 0001750 0001750 00000004342 14603537402 020133 0 ustar rasmus rasmus --TEST--
GearmanClient::clearCallbacks(), gearman_client_clear_callbacks()
--SKIPIF--
--FILE--
addServer('localhost', 4730);
print "GearmanClient::clearCallbacks (OO) (No callbacks set): " . ($client->clearCallbacks() ? 'Success' : 'Failure') . PHP_EOL;
$client->setWorkloadCallback(function($task, $context){});
$client->setCreatedCallback(function($task, $context){});
$client->setDataCallback(function($task, $context){});
$client->setWarningCallback(function($task, $context){});
$client->setStatusCallback(function($task, $context){});
$client->setCompleteCallback(function($task, $context){});
$client->setExceptionCallback(function($task, $context){});
$client->setFailCallback(function($task, $context){});
print "GearmanClient::clearCallbacks (OO) (Callbacks set): " . ($client->clearCallbacks() ? 'Success' : 'Failure') . PHP_EOL;
$client2 = gearman_client_create();
gearman_client_add_server($client2, 'localhost', 4730);
print "gearman_client_clear_callbacks (Procedural) (No callbacks set: "
. (gearman_client_clear_callbacks($client2) ? 'Success' : 'Failure') . PHP_EOL;
gearman_client_set_workload_callback($client2, function($task, $context){});
gearman_client_set_created_callback($client2, function($task, $context){});
gearman_client_set_data_callback($client2, function($task, $context){});
gearman_client_set_warning_callback($client2, function($task, $context){});
gearman_client_set_status_callback($client2, function($task, $context){});
gearman_client_set_complete_callback($client2, function($task, $context){});
gearman_client_set_exception_callback($client2, function($task, $context){});
gearman_client_set_fail_callback($client2, function($task, $context){});
print "gearman_client_clear_callbacks (Procedural) (Callbacks set: "
. (gearman_client_clear_callbacks($client2) ? 'Success' : 'Failure') . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanClient::clearCallbacks (OO) (No callbacks set): Success
GearmanClient::clearCallbacks (OO) (Callbacks set): Success
gearman_client_clear_callbacks (Procedural) (No callbacks set: Success
gearman_client_clear_callbacks (Procedural) (Callbacks set: Success
OK
gearman-2.1.2/tests/gearman_client_021.phpt 0000644 0001750 0001750 00000005030 14603537402 020127 0 ustar rasmus rasmus --TEST--
GearmanClient::enableExceptionHandler(),gearman_client_enable_exception_handler()
--SKIPIF--
--FILE--
addServers('localhost:4731,localhost', false);
// Enabling the exception handler, which will attempt to connect to
// the server and in doing so throw an exception since we can't
// connect to a server that doesn't exist
try {
$client->enableExceptionHandler();
} catch (Exception $e) {
print "Exception 1 caught: " . $e->getMessage() . PHP_EOL;
}
// Test 2: GearmanClient::addServers, Exception callback enabled (by default).
// Here, we don't give the second param, so the exception handler is enabled
// upon calling addServers instead of later in enableExceptionHandler
$client2 = new GearmanClient();
try {
$client2->addServers('localhost:4731,localhost');
} catch (Exception $e) {
print "Exception 2 caught: " . $e->getMessage() . PHP_EOL;
}
// Test 3: GearmanClient::addServers, Also, when we explicitly enable in addServers
$client3 = new GearmanClient();
try {
$client3->addServers('localhost:4731,localhost', true);
} catch (Exception $e) {
print "Exception 3 caught: " . $e->getMessage() . PHP_EOL;
}
// Now, do the same as above but with addServer (singular)
// Test 4: GearmanClient::addServer, Exception callback disabled
$client4 = new GearmanClient();
$client4->addServer('localhost', 4731, false);
try {
$client4->enableExceptionHandler();
} catch (Exception $e) {
print "Exception 4 caught: " . $e->getMessage() . PHP_EOL;
}
// Test 5: GearmanClient::addServer, default
$client5 = new GearmanClient();
try {
$client5->addServer('localhost', 4731);
} catch (Exception $e) {
print "Exception 5 caught: " . $e->getMessage() . PHP_EOL;
}
// Test 6: GearmanClient::addServer, explicitly set enableExceptionHandler
$client6 = new GearmanClient();
try {
$client6->addServer('localhost', 4731, true);
} catch (Exception $e) {
print "Exception 6 caught: " . $e->getMessage() . PHP_EOL;
}
print "OK";
?>
--EXPECTF--
Exception 1 caught: Failed to set exception option
Exception 2 caught: Failed to set exception option
Exception 3 caught: Failed to set exception option
Exception 4 caught: Failed to set exception option
Exception 5 caught: Failed to set exception option
Exception 6 caught: Failed to set exception option
OK
gearman-2.1.2/tests/gearman_client_022.phpt 0000644 0001750 0001750 00000000462 14603537402 020134 0 ustar rasmus rasmus --TEST--
unserialize(serialize(GearmanClient))
--SKIPIF--
--FILE--
--EXPECT--
012345
OK
gearman-2.1.2/tests/gearman_client_integration_test_001.phpt 0000644 0001750 0001750 00000004032 14603537402 023570 0 ustar rasmus rasmus --TEST--
--SKIPIF--
--FILE--
0) {
// Parent. This should be the Worker
$worker = new GearmanWorker();
$worker->addServer($host, $port);
print "addFunction: " . var_export(
$worker->addFunction(
$job_name,
function($job) {
print "workload: " . var_export($job->workload(), true) . PHP_EOL;
}
),
true
) . PHP_EOL;
for($i=0; $i<6; $i++) {
$worker->work();
}
print "unregister: " . var_export($worker->unregister($job_name), true) . PHP_EOL;
// Wait for child
$exit_status = 0;
if (pcntl_wait($exit_status) <= 0) {
print "pcntl_wait exited with error" . PHP_EOL;
} else if (!pcntl_wifexited($exit_status)) {
print "child exited with error" . PHP_EOL;
}
print "OK" . PHP_EOL;
} else {
// Child. This is the Client
$client = new GearmanClient();
$client->addServer($host, $port);
$job_types = ['doNormal', 'doHigh', 'doLow'];
foreach ($job_types as $job_type) {
$unique_key = "{$job_name}_{$job_type}";
$workload = "Workload for $job_type";
$handle = $client->$job_type($job_name, $workload, $unique_key);
}
// Background jobs can run into a race condition if they complete out of
// order
$job_types = ['doBackground', 'doHighBackground', 'doLowBackground'];
foreach ($job_types as $job_type) {
$unique_key = "{$job_name}_{$job_type}";
$workload = "Workload for $job_type";
$handle = $client->$job_type($job_name, $workload, $unique_key);
do {
usleep(10000);
list($is_known, $is_running, $numerator, $denominator) =
$client->jobStatus($handle);
} while ($is_known === true || $is_running === true);
}
}
?>
--EXPECT--
addFunction: true
workload: 'Workload for doNormal'
workload: 'Workload for doHigh'
workload: 'Workload for doLow'
workload: 'Workload for doBackground'
workload: 'Workload for doHighBackground'
workload: 'Workload for doLowBackground'
unregister: true
OK
gearman-2.1.2/tests/gearman_client_integration_test_002.phpt 0000644 0001750 0001750 00000002462 14603537402 023576 0 ustar rasmus rasmus --TEST--
GearmanClient::setStatusCallback(), gearman_client_set_status_callback(),
GearmanClient::addTaskStatus(), gearman_client_add_task_status(),
GearmanClient::runTasks(), gearman_client_run_tasks()
--SKIPIF--
--FILE--
addServer('localhost');
$handle = $client->doBackground("reverse", "Hello World!");
$client->setStatusCallback("reverse_status");
$oo_context = "context passed in through OO";
$client->addTaskStatus($handle, $oo_context);
// Should print within reverse_status
$client->runTasks();
$client2 = gearman_client_create();
gearman_client_add_server($client2, 'localhost', 4730);
$handle = gearman_client_do_background($client2, "reverse", "Hello World!");
gearman_client_set_status_callback($client2, "reverse_status");
$procedural_context = "context passed in through procedural";
gearman_client_add_task_status($client2, $handle, $procedural_context);
gearman_client_run_tasks($client2);
print "OK";
?>
--EXPECT--
In reverse_status context is 'context passed in through OO'
In reverse_status context is 'context passed in through procedural'
OK
gearman-2.1.2/tests/gearman_job_001.phpt 0000644 0001750 0001750 00000000411 14603537402 017417 0 ustar rasmus rasmus --TEST--
new GearmanJob()
--SKIPIF--
--FILE--
--EXPECT--
GearmanJob() (OO) class: GearmanJob
OK
gearman-2.1.2/tests/gearman_job_002.phpt 0000644 0001750 0001750 00000002522 14603537402 017425 0 ustar rasmus rasmus --TEST--
GearmanJob::returnCode(), gearman_job_return_code(),
GearmanJob::setReturn(), gearman_job_set_return()
--SKIPIF--
--FILE--
returnCode() . PHP_EOL;
print "GearmanJob::setReturn with value GEARMAN_TIMEOUT (OO): "
. ($job->setReturn(GEARMAN_TIMEOUT) ? 'Success' : 'Failure')
. PHP_EOL;
print "GearmanJob::returnCode matches GEARMAN_TIMEOUT (OO): "
. ($job->returnCode() == GEARMAN_TIMEOUT ? 'Success' : 'Failure') . PHP_EOL;
$job2 = new GearmanJob();
print "gearman_job_return_code (Procedural): " . gearman_job_return_code($job2) . PHP_EOL;
print "gearman_job_set_return with value GEARMAN_TIMEOUT (Procedural): "
. (gearman_job_set_return($job2, GEARMAN_TIMEOUT) ? 'Success' : 'Failure')
. PHP_EOL;
print "gearman_job_return_code matches GEARMAN_TIMEOUT (OO): "
. (gearman_job_return_code($job2) == GEARMAN_TIMEOUT ? 'Success' : 'Failure') . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanJob::returnCode (OO): 0
GearmanJob::setReturn with value GEARMAN_TIMEOUT (OO): Success
GearmanJob::returnCode matches GEARMAN_TIMEOUT (OO): Success
gearman_job_return_code (Procedural): 0
gearman_job_set_return with value GEARMAN_TIMEOUT (Procedural): Success
gearman_job_return_code matches GEARMAN_TIMEOUT (OO): Success
OK
gearman-2.1.2/tests/gearman_job_003.phpt 0000644 0001750 0001750 00000000446 14603537402 017431 0 ustar rasmus rasmus --TEST--
unserialize(serialize(GearmanJob))
--SKIPIF--
--FILE--
--EXPECT--
012345
OK
gearman-2.1.2/tests/gearman_job_integration_test_001.phpt 0000644 0001750 0001750 00000002631 14603537402 023067 0 ustar rasmus rasmus --TEST--
Test GearmanJob::sendData()
--SKIPIF--
--FILE--
0) {
// Parent. This is the worker
$worker = new GearmanWorker();
$worker->addServer($host, $port);
$worker->addFunction(
$job_name,
function($job, $data) {
print "GearmanJob::sendData (OO): "
. ($job->sendData("{'foo': 'bar'}") === true ? 'Success' : 'Failure')
. PHP_EOL;
}
);
$worker->work();
$worker->unregister($job_name);
// Wait for child
$exit_status = 0;
if (pcntl_wait($exit_status) <= 0) {
print "pcntl_wait exited with error" . PHP_EOL;
} else if (!pcntl_wifexited($exit_status)) {
print "child exited with error" . PHP_EOL;
}
} else {
//Child. This is the client. Don't echo anything here
$client = new GearmanClient();
if ($client->addServer($host, $port) !== true) {
exit(1); // error
};
$tasks = [];
$tasks[] = $client->addTask($job_name, "normal");
$client->runTasks();
if ($client->returnCode() != GEARMAN_SUCCESS) {
exit(2); // error
}
exit(0);
}
print "Done";
--EXPECTF--
Start
GearmanJob::sendData (OO): Success
Done
gearman-2.1.2/tests/gearman_job_integration_test_002.phpt 0000644 0001750 0001750 00000002645 14603537402 023075 0 ustar rasmus rasmus --TEST--
Test GearmanJob::sendWarning()
--SKIPIF--
--FILE--
0) {
// Parent. This is the worker
$worker = new GearmanWorker();
$worker->addServer($host, $port);
$worker->addFunction(
$job_name,
function($job, $data) {
print "GearmanJob::sendWarning (OO): "
. ($job->sendWarning("Warning string") === true ? 'Success' : 'Failure')
. PHP_EOL;
}
);
$worker->work();
$worker->unregister($job_name);
// Wait for child
$exit_status = 0;
if (pcntl_wait($exit_status) <= 0) {
print "pcntl_wait exited with error" . PHP_EOL;
} else if (!pcntl_wifexited($exit_status)) {
print "child exited with error" . PHP_EOL;
}
} else {
//Child. This is the client. Don't echo anything here
$client = new GearmanClient();
if ($client->addServer($host, $port) !== true) {
exit(1); // error
};
$tasks = [];
$tasks[] = $client->addTask($job_name, "normal");
$client->runTasks();
if ($client->returnCode() != GEARMAN_SUCCESS) {
exit(2); // error
}
exit(0);
}
print "Done";
--EXPECTF--
Start
GearmanJob::sendWarning (OO): Success
Done
gearman-2.1.2/tests/gearman_job_integration_test_003.phpt 0000644 0001750 0001750 00000002622 14603537402 023071 0 ustar rasmus rasmus --TEST--
Test GearmanJob::sendStatus
--SKIPIF--
--FILE--
0) {
// Parent. This is the worker
$worker = new GearmanWorker();
$worker->addServer($host, $port);
$worker->addFunction(
$job_name,
function($job, $data) {
print "GearmanJob::sendStatus (OO): "
. ($job->sendStatus(1,2) === true ? 'Success' : 'Failure')
. PHP_EOL;
}
);
$worker->work();
$worker->unregister($job_name);
// Wait for child
$exit_status = 0;
if (pcntl_wait($exit_status) <= 0) {
print "pcntl_wait exited with error" . PHP_EOL;
} else if (!pcntl_wifexited($exit_status)) {
print "child exited with error" . PHP_EOL;
}
} else {
//Child. This is the client. Don't echo anything here
$client = new GearmanClient();
if ($client->addServer($host, $port) !== true) {
exit(1); // error
};
$tasks = [];
$tasks[] = $client->addTask($job_name, "normal");
$client->runTasks();
if ($client->returnCode() != GEARMAN_SUCCESS) {
exit(2); // error
}
exit(0);
}
print "Done";
--EXPECTF--
Start
GearmanJob::sendStatus (OO): Success
Done
gearman-2.1.2/tests/gearman_job_integration_test_004.phpt 0000644 0001750 0001750 00000002653 14603537402 023076 0 ustar rasmus rasmus --TEST--
Test GearmanJob::sendComplete()
--SKIPIF--
--FILE--
0) {
// Parent. This is the worker
$worker = new GearmanWorker();
$worker->addServer($host, $port);
$worker->addFunction(
$job_name,
function($job, $data) {
print "GearmanJob::sendComplete (OO): "
. ($job->sendComplete("Job is complete.") === true ? 'Success' : 'Failure')
. PHP_EOL;
}
);
$worker->work();
$worker->unregister($job_name);
// Wait for child
$exit_status = 0;
if (pcntl_wait($exit_status) <= 0) {
print "pcntl_wait exited with error" . PHP_EOL;
} else if (!pcntl_wifexited($exit_status)) {
print "child exited with error" . PHP_EOL;
}
} else {
//Child. This is the client. Don't echo anything here
$client = new GearmanClient();
if ($client->addServer($host, $port) !== true) {
exit(1); // error
};
$tasks = [];
$tasks[] = $client->addTask($job_name, "normal");
$client->runTasks();
if ($client->returnCode() != GEARMAN_SUCCESS) {
exit(2); // error
}
exit(0);
}
print "Done";
--EXPECTF--
Start
GearmanJob::sendComplete (OO): Success
Done
gearman-2.1.2/tests/gearman_job_integration_test_005.phpt 0000644 0001750 0001750 00000002672 14603537402 023100 0 ustar rasmus rasmus --TEST--
Test GearmanJob::sendException()
--SKIPIF--
--FILE--
0) {
// Parent. This is the worker
$worker = new GearmanWorker();
$worker->addServer($host, $port);
$worker->addFunction(
$job_name,
function($job, $data) {
print "GearmanJob::sendException (OO): "
. ($job->sendException("Sending exception from job.") === true ? 'Success' : 'Failure')
. PHP_EOL;
}
);
$worker->work();
$worker->unregister($job_name);
// Wait for child
$exit_status = 0;
if (pcntl_wait($exit_status) <= 0) {
print "pcntl_wait exited with error" . PHP_EOL;
} else if (!pcntl_wifexited($exit_status)) {
print "child exited with error" . PHP_EOL;
}
} else {
//Child. This is the client. Don't echo anything here
$client = new GearmanClient();
if ($client->addServer($host, $port) !== true) {
exit(1); // error
};
$tasks = [];
$tasks[] = $client->addTask($job_name, "normal");
$client->runTasks();
if ($client->returnCode() != GEARMAN_SUCCESS) {
exit(2); // error
}
exit(0);
}
print "Done";
--EXPECTF--
Start
GearmanJob::sendException (OO): Success
Done
gearman-2.1.2/tests/gearman_job_integration_test_006.phpt 0000644 0001750 0001750 00000002611 14603537402 023072 0 ustar rasmus rasmus --TEST--
Test GearmanJob::sendFail()
--SKIPIF--
--FILE--
0) {
// Parent. This is the worker
$worker = new GearmanWorker();
$worker->addServer($host, $port);
$worker->addFunction(
$job_name,
function($job, $data) {
print "GearmanJob::sendFail (OO): "
. ($job->sendFail() === true ? 'Success' : 'Failure')
. PHP_EOL;
}
);
$worker->work();
$worker->unregister($job_name);
// Wait for child
$exit_status = 0;
if (pcntl_wait($exit_status) <= 0) {
print "pcntl_wait exited with error" . PHP_EOL;
} else if (!pcntl_wifexited($exit_status)) {
print "child exited with error" . PHP_EOL;
}
} else {
//Child. This is the client. Don't echo anything here
$client = new GearmanClient();
if ($client->addServer($host, $port) !== true) {
exit(1); // error
};
$tasks = [];
$tasks[] = $client->addTask($job_name, "normal");
$client->runTasks();
if ($client->returnCode() != GEARMAN_SUCCESS) {
exit(2); // error
}
exit(0);
}
print "Done";
--EXPECTF--
Start
GearmanJob::sendFail (OO): Success
Done
gearman-2.1.2/tests/gearman_job_integration_test_007.phpt 0000644 0001750 0001750 00000002631 14603537402 023075 0 ustar rasmus rasmus --TEST--
Test GearmanJob::handle()
--SKIPIF--
--FILE--
0) {
// Parent. This is the worker
$worker = new GearmanWorker();
$worker->addServer($host, $port);
$worker->addFunction(
$job_name,
function($job, $data) {
print "GearmanJob::handle (OO): "
. (preg_match('/^(.*):(.*):(.*)$/',$job->handle()) ? 'Success' : 'Failure')
. PHP_EOL;
}
);
$worker->work();
$worker->unregister($job_name);
// Wait for child
$exit_status = 0;
if (pcntl_wait($exit_status) <= 0) {
print "pcntl_wait exited with error" . PHP_EOL;
} else if (!pcntl_wifexited($exit_status)) {
print "child exited with error" . PHP_EOL;
}
} else {
//Child. This is the client. Don't echo anything here
$client = new GearmanClient();
if ($client->addServer($host, $port) !== true) {
exit(1); // error
};
$tasks = [];
$tasks[] = $client->addTask($job_name, "normal");
$client->runTasks();
if ($client->returnCode() != GEARMAN_SUCCESS) {
exit(2); // error
}
exit(0);
}
print "Done";
--EXPECTF--
Start
GearmanJob::handle (OO): Success
Done
gearman-2.1.2/tests/gearman_job_integration_test_008.phpt 0000644 0001750 0001750 00000002664 14603537402 023104 0 ustar rasmus rasmus --TEST--
Test GearmanJob::functionName()
--SKIPIF--
--FILE--
0) {
// Parent. This is the worker
$worker = new GearmanWorker();
$worker->addServer($host, $port);
$worker->addFunction(
$job_name,
function($job, $data) {
global $job_name;
print "GearmanJob::functionName (OO): "
. ($job->functionName() == $job_name ? 'Success' : 'Failure')
. PHP_EOL;
}
);
$worker->work();
$worker->unregister($job_name);
// Wait for child
$exit_status = 0;
if (pcntl_wait($exit_status) <= 0) {
print "pcntl_wait exited with error" . PHP_EOL;
} else if (!pcntl_wifexited($exit_status)) {
print "child exited with error" . PHP_EOL;
}
} else {
//Child. This is the client. Don't echo anything here
$client = new GearmanClient();
if ($client->addServer($host, $port) !== true) {
exit(1); // error
};
$tasks = [];
$tasks[] = $client->addTask($job_name, "normal");
$client->runTasks();
if ($client->returnCode() != GEARMAN_SUCCESS) {
exit(2); // error
}
exit(0);
}
print "Done";
--EXPECTF--
Start
GearmanJob::functionName (OO): Success
Done
gearman-2.1.2/tests/gearman_job_integration_test_009.phpt 0000644 0001750 0001750 00000002643 14603537402 023102 0 ustar rasmus rasmus --TEST--
Test GearmanJob::unique()
--SKIPIF--
--FILE--
0) {
// Parent. This is the worker
$worker = new GearmanWorker();
$worker->addServer($host, $port);
$worker->addFunction(
$job_name,
function($job, $data) {
print "GearmanJob::unique (OO): "
. (preg_match('/^(.*)-(.*)-(.*)-(.*)-(.*)$/',$job->unique()) ? 'Success' : 'Failure')
. PHP_EOL;
}
);
$worker->work();
$worker->unregister($job_name);
// Wait for child
$exit_status = 0;
if (pcntl_wait($exit_status) <= 0) {
print "pcntl_wait exited with error" . PHP_EOL;
} else if (!pcntl_wifexited($exit_status)) {
print "child exited with error" . PHP_EOL;
}
} else {
//Child. This is the client. Don't echo anything here
$client = new GearmanClient();
if ($client->addServer($host, $port) !== true) {
exit(1); // error
};
$tasks = [];
$tasks[] = $client->addTask($job_name, "normal");
$client->runTasks();
if ($client->returnCode() != GEARMAN_SUCCESS) {
exit(2); // error
}
exit(0);
}
print "Done";
--EXPECTF--
Start
GearmanJob::unique (OO): Success
Done
gearman-2.1.2/tests/gearman_job_integration_test_010.phpt 0000644 0001750 0001750 00000003031 14603537402 023062 0 ustar rasmus rasmus --TEST--
Test GearmanJob::workload(), GearmanJob::workloadSize()
--SKIPIF--
--FILE--
0) {
// Parent. This is the worker
$worker = new GearmanWorker();
$worker->addServer($host, $port);
$worker->addFunction(
$job_name,
function($job, $data) {
print "GearmanJob::workload (OO): "
. $job->workload()
. PHP_EOL;
print "GearmanJob::workloadSize (OO): "
. $job->workloadSize()
. PHP_EOL;
}
);
$worker->work();
$worker->unregister($job_name);
// Wait for child
$exit_status = 0;
if (pcntl_wait($exit_status) <= 0) {
print "pcntl_wait exited with error" . PHP_EOL;
} else if (!pcntl_wifexited($exit_status)) {
print "child exited with error" . PHP_EOL;
}
} else {
//Child. This is the client. Don't echo anything here
$client = new GearmanClient();
if ($client->addServer($host, $port) !== true) {
exit(1); // error
};
$tasks = [];
$tasks[] = $client->addTask($job_name, "normal");
$client->runTasks();
if ($client->returnCode() != GEARMAN_SUCCESS) {
exit(2); // error
}
exit(0);
}
print "Done";
--EXPECTF--
Start
GearmanJob::workload (OO): normal
GearmanJob::workloadSize (OO): 6
Done
gearman-2.1.2/tests/gearman_task_001.phpt 0000644 0001750 0001750 00000001446 14603537402 017620 0 ustar rasmus rasmus --TEST--
GearmanTask::functionName, gearman_task_function_name
--SKIPIF--
--FILE--
addServer('localhost', 4730);
$task = $client->addTask("GearmanTaskFunction", "normal");
print "GearmanTask::functionName (OO): " . $task->functionName() . PHP_EOL;
$client2 = gearman_client_create();
gearman_client_add_server($client2, 'localhost', 4730);
$task2 = gearman_client_add_task($client2, "GearmanTaskFunction2", "normal");
print "gearman_client_function_name (Procedural): "
. gearman_task_function_name($task2) . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanTask::functionName (OO): GearmanTaskFunction
gearman_client_function_name (Procedural): GearmanTaskFunction2
OK
gearman-2.1.2/tests/gearman_task_002.phpt 0000644 0001750 0001750 00000001643 14603537402 017620 0 ustar rasmus rasmus --TEST--
GearmanTask::unique, gearman_task_unique
--SKIPIF--
--FILE--
addServer('localhost', 4730);
$task = $client->addTask("GearmanTaskFunction", "normal");
print "GearmanTask::unique (OO): "
. (preg_match('/^(.*)-(.*)-(.*)-(.*)-(.*)$/', $task->unique())
? 'String matches' : 'String does not match')
. PHP_EOL;
$client2 = gearman_client_create();
gearman_client_add_server($client2, 'localhost', 4730);
$task2 = gearman_client_add_task($client2, "GearmanTaskFunction2", "normal");
print "gearman_client_unique (Procedural): "
. (preg_match('/^(.*)-(.*)-(.*)-(.*)-(.*)$/', gearman_task_unique($task))
? 'String matches' : 'String does not match')
. PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanTask::unique (OO): String matches
gearman_client_unique (Procedural): String matches
OK
gearman-2.1.2/tests/gearman_task_003.phpt 0000644 0001750 0001750 00000002136 14603537402 017617 0 ustar rasmus rasmus --TEST--
GearmanTask::jobHandle(), gearman_task_job_handle()
--SKIPIF--
--FILE--
addServer('localhost', 4730);
$client->setCreatedCallback(function ($task) {
print "GearmanTask::jobHandle (OO): "
. (preg_match('/^(.*):(.*):(.*)$/', $task->jobHandle())
? 'String matches' : 'String does not match')
. PHP_EOL;
});
$client->addTaskBackground("GearmanTaskFunction", "normal");
$client->runTasks();
$client2 = gearman_client_create();
gearman_client_add_server($client2, 'localhost', 4730);
gearman_client_set_created_callback($client2, function ($task) {
print "gearman_task_job_handle (Procedural): "
. (preg_match('/^(.*):(.*):(.*)$/', $task->jobHandle())
? 'String matches' : 'String does not match')
. PHP_EOL;
});
gearman_client_add_task_background($client2, "GearmanTaskFunction2", "normal");
gearman_client_run_tasks($client2);
print "OK";
?>
--EXPECT--
GearmanTask::jobHandle (OO): String matches
gearman_task_job_handle (Procedural): String matches
OK
gearman-2.1.2/tests/gearman_task_004.phpt 0000644 0001750 0001750 00000004131 14603537402 017615 0 ustar rasmus rasmus --TEST--
GearmanTask::is_known(), gearman_task_is_known(),
GearmanTask::is_running(), gearman_task_is_running(),
GearmanTask::numerator(), gearman_task_numerator(),
GearmanTask::denominator(), gearman_task_denominator()
--SKIPIF--
--FILE--
addServer('localhost', 4730);
$client->setCreatedCallback(function ($task) {
print "GearmanTask::isKnown (OO): "
. ($task->isKnown() === true ? 'Success' : 'Failure') . PHP_EOL;
print "GearmanTask::isRunning (OO): "
. ($task->isRunning() === false ? 'Success' : 'Failure') . PHP_EOL;
print "GearmanTask::taskNumerator (OO): "
. ($task->taskNumerator() == 0 ? 'Success' : 'Failure') . PHP_EOL;
print "GearmanTask::taskDenominator (OO): "
. ($task->taskDenominator() == 0 ? 'Success' : 'Failure') . PHP_EOL;
});
$client->addTaskBackground("GearmanTaskFunction", "normal");
$client->runTasks();
$client2 = gearman_client_create();
gearman_client_add_server($client2, 'localhost', 4730);
gearman_client_set_created_callback($client2, function ($task) {
print "gearman_task_is_known (Procedural): "
. (gearman_task_is_known($task) === true ? 'Success' : 'Failure') . PHP_EOL;
print "gearman_task_is_running (Procedural): "
. (gearman_task_is_running($task) === false ? 'Success' : 'Failure') . PHP_EOL;
print "gearman_task_numerator (Procedural): "
. (gearman_task_numerator($task) == 0 ? 'Success' : 'Failure') . PHP_EOL;
print "gearman_task_denominator (Procedural): "
. (gearman_task_denominator($task) == 0 ? 'Success' : 'Failure') . PHP_EOL;
});
gearman_client_add_task_background($client2, "GearmanTaskFunction2", "normal");
gearman_client_run_tasks($client2);
print "OK";
?>
--EXPECT--
GearmanTask::isKnown (OO): Success
GearmanTask::isRunning (OO): Success
GearmanTask::taskNumerator (OO): Success
GearmanTask::taskDenominator (OO): Success
gearman_task_is_known (Procedural): Success
gearman_task_is_running (Procedural): Success
gearman_task_numerator (Procedural): Success
gearman_task_denominator (Procedural): Success
OK
gearman-2.1.2/tests/gearman_task_005.phpt 0000644 0001750 0001750 00000002466 14603537402 017627 0 ustar rasmus rasmus --TEST--
GearmanTask::data(), gearman_task_data(),
GearmanTask::dataSize(), gearman_task_data_size()
--SKIPIF--
--FILE--
addServer('localhost', 4730);
$client->setCreatedCallback(function ($task) {
print "GearmanTask::data (OO): "
. ($task->data() === '' ? 'Success' : 'Failure') . PHP_EOL;
print "GearmanTask::dataSize (OO): "
. ($task->dataSize() == 0 ? 'Success' : 'Failure') . PHP_EOL;
});
$client->addTaskBackground("GearmanTaskFunction", "normal", "OO data");
$client->runTasks();
$client2 = gearman_client_create();
gearman_client_add_server($client2, 'localhost', 4730);
gearman_client_set_created_callback($client2, function ($task) {
print "gearman_task_data (Procedural): "
. (gearman_task_data($task) === '' ? 'Success' : 'Failure') . PHP_EOL;
print "gearman_task_data_size (Procedural): "
. (gearman_task_data_size($task) == 0 ? 'Success' : 'Failure') . PHP_EOL;
});
gearman_client_add_task_background($client2, "GearmanTaskFunction2", "normal");
gearman_client_run_tasks($client2);
print "OK";
?>
--EXPECT--
GearmanTask::data (OO): Success
GearmanTask::dataSize (OO): Success
gearman_task_data (Procedural): Success
gearman_task_data_size (Procedural): Success
OK
gearman-2.1.2/tests/gearman_task_006.phpt 0000644 0001750 0001750 00000000455 14603537402 017624 0 ustar rasmus rasmus --TEST--
unserialize(serialize(GearmanTask))
--SKIPIF--
--FILE--
--EXPECT--
012345
OK
gearman-2.1.2/tests/gearman_tasks_integration_test_001.phpt 0000644 0001750 0001750 00000003705 14603537402 023445 0 ustar rasmus rasmus --TEST--
Test Gearman worker methods
--SKIPIF--
--FILE--
0) {
// Parent. This is the worker
$worker = new GearmanWorker();
print "addServer: " . var_export($worker->addServer($host, $port), true) . PHP_EOL;
print "addFunction: " . var_export(
$worker->addFunction(
$job_name,
function($job) {
print "workload: " . var_export($job->workload(), true) . PHP_EOL;
}
),
true
) . PHP_EOL;
for ($i = 0; $i < 6; $i++) {
$worker->work();
}
print "unregister: " . var_export($worker->unregister($job_name), true) . PHP_EOL;
// Wait for child
$exit_status = 0;
if (pcntl_wait($exit_status) <= 0) {
print "pcntl_wait exited with error" . PHP_EOL;
} else if (!pcntl_wifexited($exit_status)) {
print "child exited with error" . PHP_EOL;
}
} else {
//Child. This is the client. Don't echo anything here
$client = new GearmanClient();
if ($client->addServer($host, $port) !== true) {
exit(1); // error
};
$tasks = [];
$tasks[] = $client->addTask($job_name, "normal");
$tasks[] = $client->addTaskBackground($job_name, "normalbg");
$tasks[] = $client->addTaskHigh($job_name, 1);
$tasks[] = $client->addTaskHighBackground($job_name, 2.0);
$tasks[] = $client->addTaskLow($job_name, "low");
$tasks[] = $client->addTaskLowBackground($job_name, true);
$client->runTasks();
if ($client->returnCode() != GEARMAN_SUCCESS) {
exit(2); // error
}
exit(0);
}
print "Done";
--EXPECTF--
Start
addServer: true
addFunction: true
workload: '2'
workload: '1'
workload: 'normalbg'
workload: 'normal'
workload: '1'
workload: 'low'
unregister: true
Done
gearman-2.1.2/tests/gearman_tasks_integration_test_002.phpt 0000644 0001750 0001750 00000004471 14603537402 023447 0 ustar rasmus rasmus --TEST--
Test Gearman worker methods
--SKIPIF--
--FILE--
addServer($host, $port);
$worker->addFunction(
$job_name,
function($job) {
if ($job->workload() == "success") {
return "done";
} else if ($job->workload() == "exception") {
$job->sendException("unhandled");
return "exception";
} else if ($job->workload() == "fail") {
$job->sendFail();
return "fail";
}
}
);
for ($i = 0; $i < count($contexts); $i++) {
$worker->work();
}
$worker->unregister($job_name);
exit(0);
} else {
//Parent. This is the client.
$client = new GearmanClient();
if ($client->addServer($host, $port) !== true) {
exit(1); // error
};
$client->setCompleteCallback(function($task) {
print "Complete: " . $task->data() . PHP_EOL;
});
$client->setDataCallback(function($task) {
print "Data: " . $task->data() . PHP_EOL;
});
$client->setExceptionCallback(function($task) {
print "Exception: " . $task->data() . PHP_EOL;
});
$client->setFailCallback(function($task) {
print "Fail" . PHP_EOL;
});
$tasks = [];
foreach ($contexts as $c) {
$tasks[] = $client->addTask($job_name, $c);
}
$client->runTasks();
print "returnCode: " . var_export($client->returnCode(), true) . PHP_EOL;
print "clearCallbacks: " . var_export($client->clearCallbacks(), true) . PHP_EOL;
// Wait for child
$exit_status = 0;
if (pcntl_wait($exit_status) <= 0) {
print "pcntl_wait exited with error" . PHP_EOL;
} else if (!pcntl_wifexited($exit_status)) {
print "child exited with error" . PHP_EOL;
}
}
print "Done";
--EXPECTF--
Start
Exception: unhandled
Fail
Complete: done
returnCode: 0
clearCallbacks: true
Done
gearman-2.1.2/tests/gearman_worker_001.phpt 0000644 0001750 0001750 00000000732 14603537402 020164 0 ustar rasmus rasmus --TEST--
gearman_worker_return_code()
--SKIPIF--
--FILE--
returnCode() . PHP_EOL;
$worker2 = gearman_worker_create();
print "gearman_worker_return_code (Procedural): " . gearman_worker_return_code($worker2) . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanWorker::returnCode (OO): 0
gearman_worker_return_code (Procedural): 0
OK
gearman-2.1.2/tests/gearman_worker_002.phpt 0000644 0001750 0001750 00000000732 14603537402 020165 0 ustar rasmus rasmus --TEST--
gearman_worker_return_code()
--SKIPIF--
--FILE--
returnCode() . PHP_EOL;
$worker2 = gearman_worker_create();
print "gearman_worker_return_code (Procedural): " . gearman_worker_return_code($worker2) . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanWorker::returnCode (OO): 0
gearman_worker_return_code (Procedural): 0
OK
gearman-2.1.2/tests/gearman_worker_003.phpt 0000644 0001750 0001750 00000000663 14603537402 020171 0 ustar rasmus rasmus --TEST--
gearman_worker_error()
--SKIPIF--
--FILE--
error() . "'\n";
$worker2 = gearman_worker_create();
print "gearman_worker_error (Procedural): '" . gearman_worker_error($worker2) . "'\n";
print "OK";
?>
--EXPECT--
GearmanWorker::error (OO): ''
gearman_worker_error (Procedural): ''
OK
gearman-2.1.2/tests/gearman_worker_004.phpt 0000644 0001750 0001750 00000000674 14603537402 020174 0 ustar rasmus rasmus --TEST--
gearman_worker_errno()
--SKIPIF--
--FILE--
getErrno() . PHP_EOL;
$worker2 = gearman_worker_create();
print "gearman_worker_errno (Procedural): " . gearman_worker_errno($worker2) . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanWorker::getErrno (OO): 0
gearman_worker_errno (Procedural): 0
OK
gearman-2.1.2/tests/gearman_worker_005.phpt 0000644 0001750 0001750 00000000705 14603537402 020170 0 ustar rasmus rasmus --TEST--
gearman_worker_options()
--SKIPIF--
--FILE--
options() . PHP_EOL;
$worker2 = gearman_worker_create();
print "gearman_worker_options (Procedural): " . gearman_worker_options($worker2) . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanWorker::options (OO): 644
gearman_worker_options (Procedural): 644
OK
gearman-2.1.2/tests/gearman_worker_006.phpt 0000644 0001750 0001750 00000001522 14603537402 020167 0 ustar rasmus rasmus --TEST--
gearman_worker_set_options()
--SKIPIF--
--FILE--
setOptions(GEARMAN_WORKER_NON_BLOCKING) === true ? 'Success' : 'Failure') . PHP_EOL;
print "GearmanWorker::options() (OO): " . $worker->options() . PHP_EOL;
$worker2 = gearman_worker_create();
print "gearman_worker_set_options (Procedural): " . (gearman_worker_set_options($worker, GEARMAN_WORKER_NON_BLOCKING) === true ? 'Success' : 'Failure') . PHP_EOL;
print "gearman_worker_options() (Procedural): " . gearman_worker_options($worker) . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanWorker::setOptions (OO): Success
GearmanWorker::options() (OO): 6
gearman_worker_set_options (Procedural): Success
gearman_worker_options() (Procedural): 6
OK
gearman-2.1.2/tests/gearman_worker_007.phpt 0000644 0001750 0001750 00000001520 14603537402 020166 0 ustar rasmus rasmus --TEST--
gearman_worker_add_options()
--SKIPIF--
--FILE--
addOptions(GEARMAN_WORKER_NON_BLOCKING) === true ? 'Success' : 'Failure') . PHP_EOL;
print "GearmanWorker::options() (OO): " . $worker->options() . PHP_EOL;
$worker2 = gearman_worker_create();
print "gearman_worker_add_options() (Procedural): " . (gearman_worker_add_options($worker2, GEARMAN_WORKER_NON_BLOCKING) === true ? 'Success' : 'Failure') . PHP_EOL;
print "gearman_worker_options() (OO): " . gearman_worker_options($worker2) . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanWorker::addOptions() (OO): Success
GearmanWorker::options() (OO): 646
gearman_worker_add_options() (Procedural): Success
gearman_worker_options() (OO): 646
OK
gearman-2.1.2/tests/gearman_worker_008.phpt 0000644 0001750 0001750 00000002314 14603537402 020171 0 ustar rasmus rasmus --TEST--
gearman_worker_timeout(), gearman_worker_set_timeout()
--SKIPIF--
--FILE--
timeout() . PHP_EOL;
print "GearmanWorker::setTimeout() (OO): " .($worker->setTimeout($timeout) === true ? "Success" : "Failure") . PHP_EOL;
print "GearmanWorker::timeout() (OO, after setting): " . $worker->timeout() . PHP_EOL;
$worker2 = gearman_worker_create();
print "gearman_worker_timeout() (Procedural, before setting): " . gearman_worker_timeout($worker2) . PHP_EOL;
print "gearman_worker_set_timeout() (Procedural): " . (gearman_worker_set_timeout($worker2, $timeout) === true ? "Success" : "Failure") . PHP_EOL;
print "gearman_worker_timeout() (Procedural, after setting): " . gearman_worker_timeout($worker2) . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanWorker::timeout() (OO, before setting): -1
GearmanWorker::setTimeout() (OO): Success
GearmanWorker::timeout() (OO, after setting): 5
gearman_worker_timeout() (Procedural, before setting): -1
gearman_worker_set_timeout() (Procedural): Success
gearman_worker_timeout() (Procedural, after setting): 5
OK
gearman-2.1.2/tests/gearman_worker_009.phpt 0000644 0001750 0001750 00000001043 14603537402 020170 0 ustar rasmus rasmus --TEST--
gearman_worker_set_id()
--SKIPIF--
--FILE--
setId($id) === true ? "Success" : "Failure").PHP_EOL;
$worker2 = gearman_worker_create();
print "gearman_worker_set_id() (Procedural): " . (gearman_worker_set_id($worker, $id) === true ? "Success" : "Failure").PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanWorker::setId() (OO): Success
gearman_worker_set_id() (Procedural): Success
OK
gearman-2.1.2/tests/gearman_worker_010.phpt 0000644 0001750 0001750 00000002023 14603537402 020157 0 ustar rasmus rasmus --TEST--
gearman_worker_add_server(), gearman_worker_add_servers()
--SKIPIF--
--FILE--
addServer($host, $port) === true ? "Success" : "Failure").PHP_EOL;
print "GearmanWorker::addServers() (OO): " . ($worker->addServers("$host:$port") === true ? "Success" : "Failure").PHP_EOL;
$worker2 = gearman_worker_create();
print "gearman_worker_add_server() (Procedural): " . (gearman_worker_add_server($worker, $host, $port) === true ? "Success" : "Failure").PHP_EOL;
print "gearman_worker_add_servers() (Procedural): " . (gearman_worker_add_servers($worker, "$host:$port") === true ? "Success" : "Failure").PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanWorker::addServer() (OO):Success
GearmanWorker::addServers() (OO): Success
gearman_worker_add_server() (Procedural): Success
gearman_worker_add_servers() (Procedural): Success
OK
gearman-2.1.2/tests/gearman_worker_011.phpt 0000644 0001750 0001750 00000000573 14603537402 020170 0 ustar rasmus rasmus --TEST--
gearman_worker_wait()
--SKIPIF--
--FILE--
addServer($host, $port);
$worker->setTimeout(1);
/*
Still need to figure out how to test wait here...
$worker->wait();
*/
print "OK";
?>
--EXPECT--
OK
gearman-2.1.2/tests/gearman_worker_012.phpt 0000644 0001750 0001750 00000003732 14603537402 020171 0 ustar rasmus rasmus --TEST--
gearman_worker_register(), gearman_worker_unregister(), gearman_worker_unregister_all()
--SKIPIF--
--FILE--
addServer($host, $port);
print "GearmanWorker::register() (OO): " . ($worker->register($registered_func) === true ? "Success" : "Failure") . PHP_EOL;
print "GearmanWorker::unregister() (OO): " . ($worker->unregister($registered_func) === true ? "Success" : "Failure") . PHP_EOL;
print "GearmanWorker::register() (OO): " . ($worker->register($registered_func) === true ? "Success" : "Failure") . PHP_EOL;
print "GearmanWorker::unregisterAll() (OO): " . ($worker->unregisterAll() === true ? "Success" : "Failure") . PHP_EOL;
$worker2 = gearman_worker_create();
gearman_worker_add_server($worker, $host, $port);
print "gearman_worker_register() (Procedural): " . (gearman_worker_register($worker, $registered_func) === true ? "Success" : "Failure") . PHP_EOL;
print "gearman_worker_unregister() (Procedural): " . (gearman_worker_unregister($worker, $registered_func) === true ? "Success" : "Failure") . PHP_EOL;
print "gearman_worker_register() (Procedural): " . (gearman_worker_register($worker, $registered_func) === true ? "Success" : "Failure") . PHP_EOL;
print "gearman_worker_unregister_all() (Procedural): " . (gearman_worker_unregister_all($worker) === true ? "Success" : "Failure") . PHP_EOL;
print "OK";
function registered_function() {
print "I'm in ".__FUNCTION__.PHP_EOL;
}
?>
--EXPECT--
GearmanWorker::register() (OO): Success
GearmanWorker::unregister() (OO): Success
GearmanWorker::register() (OO): Success
GearmanWorker::unregisterAll() (OO): Success
gearman_worker_register() (Procedural): Success
gearman_worker_unregister() (Procedural): Success
gearman_worker_register() (Procedural): Success
gearman_worker_unregister_all() (Procedural): Success
OK
gearman-2.1.2/tests/gearman_worker_013.phpt 0000644 0001750 0001750 00000001472 14603537402 020171 0 ustar rasmus rasmus --TEST--
gearman_worker_add_function()
--SKIPIF--
--FILE--
addServer($host, $port);
print "GearmanWorker::addFunction() (OO): ".($worker->addFunction($job, $func) ? "Success" : "Failure").PHP_EOL;
$worker2 = gearman_worker_create();
gearman_worker_add_server($worker, $host, $port);
print "gearman_worker_add_function() (Procedural): ".(gearman_worker_add_function($worker, $job, $func) ? "Success" : "Failure").PHP_EOL;
print "OK";
function do_work() {
print "I'm in ".__FUNCTION__.PHP_EOL;
}
?>
--EXPECT--
GearmanWorker::addFunction() (OO): Success
gearman_worker_add_function() (Procedural): Success
OK
gearman-2.1.2/tests/gearman_worker_014.phpt 0000644 0001750 0001750 00000002510 14603537402 020164 0 ustar rasmus rasmus --TEST--
gearman_worker_work()
--SKIPIF--
--FILE--
addServer($host, $port);
$handle = $client->doBackground($job, $workload);
$client->doBackground($job, $workload);
print "GearmanWorker::doBackground() (OO): ".(preg_match('/^H:'.gethostname().':\d+$/', $handle) === 1? 'Success' : 'Failure').PHP_EOL;
$worker = new GearmanWorker();
$worker->addServer($host, $port);
$worker->addFunction($job, $func);
print "GearmanWorker::work() (OO): ".($worker->work() === true ? 'Success' : 'Failure') . PHP_EOL;
$worker2 = gearman_worker_create();
gearman_worker_add_server($worker, $host, $port);
gearman_worker_add_function($worker, $job, $func);
print "gearman_worker_work() (Procedural): ".(gearman_worker_work($worker) === true ? 'Success' : 'Failure') . PHP_EOL;
print "OK";
function do_work($job) {
print "Calling function ".__FUNCTION__.PHP_EOL;
}
?>
--EXPECT--
GearmanWorker::doBackground() (OO): Success
Calling function do_work
GearmanWorker::work() (OO): Success
Calling function do_work
gearman_worker_work() (Procedural): Success
OK
gearman-2.1.2/tests/gearman_worker_015.phpt 0000644 0001750 0001750 00000001300 14603537402 020161 0 ustar rasmus rasmus --TEST--
gearman_worker_ping()
--SKIPIF--
--FILE--
addServer($host, $port);
echo "GearmanWorker::server() (OO): ".($worker->ping($json_workload) ? "Success" : "Failure").PHP_EOL;
$worker2 = gearman_worker_create();
gearman_worker_add_server($worker, $host, $port);
echo "gearman_worker_work() (Procedural): ".($worker->ping($json_workload) ? "Success" : "Failure").PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanWorker::server() (OO): Success
gearman_worker_work() (Procedural): Success
OK
gearman-2.1.2/tests/gearman_worker_016.phpt 0000644 0001750 0001750 00000003460 14603537402 020173 0 ustar rasmus rasmus --TEST--
GearmanWorker::addFunction(), context param
--SKIPIF--
--FILE--
addServer($host, $port);
$handle = $client->doBackground($job, $workload);
$client->doBackground($job, $workload);
$client->doBackground($job, $workload);
$client->doBackground($job, $workload);
print "GearmanWorker::doBackground() (OO): ".(preg_match('/^H:'.gethostname().':\d+$/', $handle) === 1? 'Success' : 'Failure').PHP_EOL;
$worker = new TestWorker();
print "GearmanWorker::work() (OO, array ctx): " .($worker->work() === true ? 'Success' : 'Failure') . PHP_EOL;
print "GearmanWorker::work() (OO, array ctx): " .($worker->work() === true ? 'Success' : 'Failure') . PHP_EOL;
print "GearmanWorker::work() (OO, array ctx): " .($worker->work() === true ? 'Success' : 'Failure') . PHP_EOL;
print "OK";
class TestWorker extends \GearmanWorker
{
public function __construct()
{
global $job;
parent::__construct();
$this->addServer();
$this->addFunction($job, [$this, 'test'], ['firstArg' => 'firstValue']);
}
public function test($job, $context)
{
echo "Starting job {$job->workload()}". PHP_EOL;
$firstArg = $context['firstArg'];
echo "FirstArg is $firstArg" . PHP_EOL;
}
}
?>
--EXPECT--
GearmanWorker::doBackground() (OO): Success
Starting job {"workload":"test"}
FirstArg is firstValue
GearmanWorker::work() (OO, array ctx): Success
Starting job {"workload":"test"}
FirstArg is firstValue
GearmanWorker::work() (OO, array ctx): Success
Starting job {"workload":"test"}
FirstArg is firstValue
GearmanWorker::work() (OO, array ctx): Success
OK
gearman-2.1.2/tests/gearman_worker_017.phpt 0000644 0001750 0001750 00000000462 14603537402 020173 0 ustar rasmus rasmus --TEST--
unserialize(serialize(GearmanWorker))
--SKIPIF--
--FILE--
--EXPECT--
012345
OK
gearman-2.1.2/tests/gearman_worker_integration_test_001.phpt 0000644 0001750 0001750 00000004217 14603537402 023630 0 ustar rasmus rasmus --TEST--
Test Gearman worker methods
--SKIPIF--
--FILE--
0) {
// Parent. This is the worker
$worker = new GearmanWorker();
print "addServer: " . var_export($worker->addServer($host, $port), true) . PHP_EOL;
print "setTimeout: " . var_export($worker->setTimeout(100), true) . PHP_EOL;
print "register: " . var_export($worker->register($job_name, 5), true) . PHP_EOL;
print "register: " . var_export($worker->register($job_name . "1", 5), true) . PHP_EOL;
print "register: " . var_export($worker->register($job_name . "2", 5), true) . PHP_EOL;
print "register: " . var_export($worker->register($job_name . "3", 5), true) . PHP_EOL;
print "addFunction: " . var_export(
$worker->addFunction(
$job_name,
function($job) {
print "workload: " . var_export($job->workload(), true) . PHP_EOL;
}
), true
) . PHP_EOL;
print "work: " . var_export($worker->work(), true) . PHP_EOL;
print "unregister: " . var_export($worker->unregister($job_name), true) . PHP_EOL;
print "unregisterAll: " . var_export($worker->unregisterAll(), true) . PHP_EOL;
// Wait for child
$exit_status = 0;
if (pcntl_wait($exit_status) <= 0) {
print "pcntl_wait exited with error" . PHP_EOL;
} else if (!pcntl_wifexited($exit_status)) {
print "child exited with error" . PHP_EOL;
}
} else {
//Child. This is the client. Don't echo anything here
$client = new GearmanClient();
if ($client->addServer($host, $port) !== true) {
exit(1); // error
};
$client->doBackground($job_name, "nothing");
if ($client->returnCode() != GEARMAN_SUCCESS) {
exit(2); // error
}
exit(0);
}
print "Done";
--EXPECTF--
Start
addServer: true
setTimeout: true
register: true
register: true
register: true
register: true
addFunction: true
workload: 'nothing'
work: true
unregister: true
unregisterAll: true
Done
gearman-2.1.2/tests/skipifconnect.inc 0000644 0001750 0001750 00000000614 14603537402 017235 0 ustar rasmus rasmus = {$min_ver}, found version {$version}\n");
}