Job/Common.phpView Source

Show: PublicProtectedPrivateinherited
Table of Contents
Interface for Danga's Gearman job scheduling system

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\Job\Common

abstract
Package: ShSo\Net\Gearman
Base job class for all Gearman jobs
See
ShSo\Net\Gearman\Worker  
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@  

Properties

>VPropertyprotectedresource $conn = null
Connection to Gearman
Default valuenullDetails
Type
resource
See
 
>VPropertyprotectedstring $handle = ''
Gearman job handle
Default value''Details
Type
string

Methods

methodpublic__construct(resource $conn, string $handle, array $initParams = array()) : void

Constructor

Parameters
NameTypeDescription
$connresource

Connection to communicate with

$handlestring

Job ID / handle for this job

$initParamsarray

initialization parameters

methodpubliccomplete(array $result) : void

Mark your job as complete with its status

ShSo\Net\Gearman communicates between the client and jobs in JSON. The main benefit of this is that we can send fairly complex data types between different languages. You should always pass an array as the result to this function.

Parameters
NameTypeDescription
$resultarray

Result of your job

Details
See
 
methodpublicfail() : void

Mark your job as failing

If your job fails for some reason (e.g. a query fails) you need to run this function and exit from your run() method. This will tell Gearman (and the client by proxy) that the job has failed.

Details
See
 
methodpublicrun(array $arg) : void
abstract

Run your job here

Parameters
NameTypeDescription
$argarray

Arguments passed from the client

Throws
ExceptionDescription
\ShSo\Net\Gearman\Job\ShSo\Net\Gearman\Exception
methodpublicstatus(integer $numerator, integer $denominator) : void

Update Gearman with your job's status

Parameters
NameTypeDescription
$numeratorinteger

The numerator (e.g. 1)

$denominatorinteger

The denominator (e.g. 100)

Details
See
 
Documentation was generated by phpDocumentor 2.8.5.