Net_Gearman
[ class tree: Net_Gearman ] [ index: Net_Gearman ] [ all elements ]

Class: Net_Gearman_Manager

Source Location: /Net_Gearman-0.2.3/Net/Gearman/Manager.php

Class Overview


A client for managing Gearmand servers


Author(s):

Copyright:

  • 2007-2008 Digg.com, Inc.

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 40]
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.



[ Top ]


Class Variables

$conn =  null

[line 49]

Connection resource

Type:   resource


[ Top ]

$shutdown =  false

[line 60]

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 Net_Gearman_Manager::shutdown() and then checked in Net_Gearman_Manager::sendCommand().

  • Access: protected

Type:   boolean


[ Top ]



Method Detail

__construct (Constructor)   [line 71]

Net_Gearman_Manager __construct( string $server, [integer $timeout = 5])

Constructor

Parameters:

string   $server   —  Host and port (e.g. 'localhost:7003')
integer   $timeout   —  Connection timeout

[ Top ]

__destruct (Destructor)   [line 314]

void __destruct( )

Destructor
  • Access: public

[ Top ]

checkForError   [line 287]

void checkForError( string $data)

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.

  • Throws: Net_Gearman_Exception
  • Access: protected

Parameters:

string   $data   —  The returned data to check for an error

[ Top ]

disconnect   [line 302]

void disconnect( )

Disconnect from server

[ Top ]

recvCommand   [line 259]

string recvCommand( )

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.

  • Throws: Net_Gearman_Exception
  • Access: protected

[ Top ]

sendCommand   [line 237]

void sendCommand( string $cmd)

Send a command
  • Throws: Net_Gearman_Exception
  • Access: protected

Parameters:

string   $cmd   —  The command to send

[ Top ]

setMaxQueueSize   [line 178]

boolean setMaxQueueSize( string $function, integer $size)

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).

  • Throws: Net_Gearman_Exception
  • Access: public

Parameters:

string   $function   —  Name of function to set queue size for
integer   $size   —  New size of queue

[ Top ]

shutdown   [line 115]

boolean shutdown( [boolean $graceful = false])

Shut down Gearman

Parameters:

boolean   $graceful   —  Whether it should be a graceful shutdown

[ Top ]

status   [line 205]

array status( )

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.

  • Return: An array keyed by function name
  • Throws: Net_Gearman_Exception
  • Access: public

[ Top ]

version   [line 97]

string version( )

Get the version of Gearman running

[ Top ]

workers   [line 135]

array workers( )

Get worker status and info

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

  • Return: A list of workers connected to the server
  • Throws: Net_Gearman_Exception
  • Access: public

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:31:13 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.