Task.php
PHP version 5.1.0+
LICENSE: This source file is subject to the New BSD license that is available through the world-wide-web at the following URI: http://www.opensource.org/licenses/bsd-license.php. If you did not receive a copy of the New BSD License and are unable to obtain it through the web, please send a note to license@php.net so we can mail you a copy immediately.
- Author
- Joe Stump
- Category
- Net
- Copyright
- 2007-2008 Digg.com, Inc.
- License
- New BSD License
- Link
- http://pear.php.net/package/Net_Gearman
- Link
- http://www.danga.com/gearman/
- Package
- ShSo\Net\Gearman
- Version
- CVS: $Id$
\ShSo\Net\Gearman\Task
- See
- ShSo\Net\Gearman\Client
- Author
- Joe Stump
- Category
- Net
- Copyright
- 2007-2008 Digg.com, Inc.
- License
- New BSD License
- Link
- http://www.danga.com/gearman/
- Version
- Release: @package_version@
Constants
integer
JOB_NORMAL
= 1Normal jobs are ran against a worker with the result being returned all in the same thread (e.g. Your page will sit there waiting for the job to finish and return it's result).
- JOB_NORMAL
- integer
JOB_NORMAL
integer
JOB_BACKGROUND
= 2Background jobs in Gearman are "fire and forget". You can check a job's status periodically, but you can't get a result back from it.
- JOB_BACKGROUND
- integer
JOB_BACKGROUND
integer
JOB_LOW_BACKGROUND
= 6- JOB_LOW_BACKGROUND
- integer
JOB_LOW_BACKGROUND
Properties

array $callback = array(self::TASK_COMPLETE => array(), self::TASK_FAIL => array(), self::TASK_STATUS => array())
string $uniq = ''Keep in mind that a unique job is only unique to the job server it is submitted to. Gearman servers don't communicate with each other to ensure a job is unique across all workers.
That being said, Gearman does group identical jobs sent to it and runs that job only once. If you send the job Sum with args 1, 2, 3 to the server 10 times in a second Gearman will only run that job once and then return the result 10 times.
''Details- Type
- string
Methods

__construct(string $func, mixed $arg, string $uniq = null, integer $type = self::JOB_NORMAL) : \ShSo\Net\Gearman\ShSo\Net\Gearman\TaskConstructor
| Name | Type | Description |
|---|---|---|
| $func | string | Name of job to run |
| $arg | mixed | List of arguments for job |
| $uniq | string | The unique id of the job |
| $type | integer | Type of job to run task as |
| Type | Description |
|---|---|
| \ShSo\Net\Gearman\ShSo\Net\Gearman\Task |
| Exception | Description |
|---|---|
| \ShSo\Net\Gearman\ShSo\Net\Gearman\Exception |

attachCallback(callback $callback, integer $type = self::TASK_COMPLETE) : \ShSo\Net\Gearman\TaskAttach a callback to this task
| Name | Type | Description |
|---|---|---|
| $callback | callback | A valid PHP callback |
| $type | integer | Type of callback |
| Type | Description |
|---|---|
| \ShSo\Net\Gearman\Task |
| Exception | Description |
|---|---|
| \ShSo\Net\Gearman\ShSo\Net\Gearman\Exception | When the callback is invalid. |
| \ShSo\Net\Gearman\ShSo\Net\Gearman\Exception | When the callback's type is invalid. |
- Fluent
- This method is part of a fluent interface and will return the same instance