Manager.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\Manager

Package: ShSo\Net\Gearman
A client for managing Gearmand servers

This class implements the administrative text protocol used by Gearman to do a number of administrative tasks such as collecting stats on workers, the queue, shutting down the server, version, etc.

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 resource
Default valuenullDetails
Type
resource
See
 
See
 
>VPropertyprotectedboolean $shutdown = false
The server is shutdown

We obviously can't send more commands to a server after it's been shut down. This is set to true in ShSo\Net\Gearman\Manager::shutdown() and then checked in ShSo\Net\Gearman\Manager::sendCommand().

Default valuefalseDetails
Type
boolean

Methods

methodpublic__construct(string $server, integer $timeout = 5) : void

Constructor

Parameters
NameTypeDescription
$serverstring

Host and port (e.g. 'localhost:7003')

$timeoutinteger

Connection timeout

Throws
ExceptionDescription
\ShSo\Net\Gearman\ShSo\Net\Gearman\Exception
Details
See
 
methodpublic__destruct() : void

Destructor

methodprotectedcheckForError(string $data) : void

Check for an error

Gearman returns errors in the format of 'ERR code_here Message+here'. This method checks returned values from the server for this error format and will throw the appropriate exception.

Parameters
NameTypeDescription
$datastring

The returned data to check for an error

Throws
ExceptionDescription
\ShSo\Net\Gearman\ShSo\Net\Gearman\Exception
methodpublicdisconnect() : void

Disconnect from server

Details
See
 
methodprotectedrecvCommand() : string

Receive a response

For most commands Gearman returns a bunch of lines and ends the transmission of data with a single line of ".\n". This command reads in everything until ".\n". If the command being sent is NOT ended with ".\n" DO NOT use this command.

Returns
TypeDescription
string
Throws
ExceptionDescription
\ShSo\Net\Gearman\ShSo\Net\Gearman\Exception
methodprotectedsendCommand(string $cmd) : void

Send a command

Parameters
NameTypeDescription
$cmdstring

The command to send

Throws
ExceptionDescription
\ShSo\Net\Gearman\ShSo\Net\Gearman\Exception
methodpublicsetMaxQueueSize(string $function, integer $size) : boolean

Set maximum queue size for a function

For a given function of job, the maximum queue size is adjusted to be max_queue_size jobs long. A negative value indicates unlimited queue size.

If the max_queue_size value is not supplied then it is unset (and the default maximum queue size will apply to this function).

Parameters
NameTypeDescription
$functionstring

Name of function to set queue size for

$sizeinteger

New size of queue

Returns
TypeDescription
boolean
Throws
ExceptionDescription
\ShSo\Net\Gearman\ShSo\Net\Gearman\Exception
methodpublicshutdown(boolean $graceful = false) : boolean

Shut down Gearman

Parameters
NameTypeDescription
$gracefulboolean

Whether it should be a graceful shutdown

Returns
TypeDescription
boolean
Details
See
 
See
 
See
 
methodpublicstatus() : array

Get queue/worker status by function

This function queries for queue status. The array returned is keyed by the function (job) name and has how many jobs are in the queue, how many jobs are running and how many workers are capable of performing that job.

Returns
TypeDescription
arrayAn array keyed by function name
Throws
ExceptionDescription
\ShSo\Net\Gearman\ShSo\Net\Gearman\Exception
methodpublicversion() : string

Get the version of Gearman running

Returns
TypeDescription
string
Details
See
 
See
 
methodpublicworkers() : array

Get worker status and info

Returns the file descriptor, IP address, client ID and the abilities that the worker has announced.

Returns
TypeDescription
arrayA list of workers connected to the server
Throws
ExceptionDescription
\ShSo\Net\Gearman\ShSo\Net\Gearman\Exception
Documentation was generated by phpDocumentor 2.8.5.