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

Class: Net_Gearman_Connection

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

Class Overview


The base connection class


Author(s):

Copyright:

  • 2007-2008 Digg.com, Inc.

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 36]
The base connection class


[ Top ]


Class Variables

$commands = array(
        'can_do' => array(1, array('func')),'can_do_timeout'=>array(23,array('func','timeout')),'cant_do'=>array(2,array('func')),'reset_abilities'=>array(3,array()),'set_client_id'=>array(22,array('client_id')),'pre_sleep'=>array(4,array()),'noop'=>array(6,array()),'submit_job'=>array(7,array('func','uniq','arg')),'submit_job_high'=>array(21,array('func','uniq','arg')),'submit_job_bg'=>array(18,array('func','uniq','arg')),'job_created'=>array(8,array('handle')),'grab_job'=>array(9,array()),'no_job'=>array(10,array()),'job_assign'=>array(11,array('handle','func','arg')),'work_status'=>array(12,array('handle','numerator','denominator')),'work_complete'=>array(13,array('handle','result')),'work_fail'=>array(14,array('handle')),'get_status'=>array(15,array('handle')),'status_res'=>array(20,array('handle','known','running','numerator','denominator')),'echo_req'=>array(16,array('text')),'echo_res'=>array(17,array('text')),'error'=>array(19,array('err_code','err_text')),'all_yours'=>array(24,array()))

[line 49]

A list of valid Gearman commands

This is a list of valid Gearman commands (the key of the array), their integery type (first key in second array) used in the binary header, and the arguments / order of arguments to send/receive.


Type:   array


[ Top ]

$magic = array()

[line 85]

The reverse of Net_Gearman_Connection::$commands

This is the same as the Net_Gearman_Connection::$commands array only it's keyed by the magic (integer value) value of the command.


Type:   array


[ Top ]

$multiByteSupport =  null

[line 105]

Is PHP's multibyte overload turned on?
  • Access: protected

Type:   integer


[ Top ]

$waiting = array()

[line 98]

Tasks waiting for a handle

Tasks are popped onto this queue as they're submitted so that they can later be popped off of the queue once a handle has been assigned via the job_created command.

  • Access: public

Type:   array


[ Top ]



Method Detail

blockingRead   [line 309]

array blockingRead( resource $socket, [float $timeout = 500])

Blocking socket read
  • Throws: Net_Gearman_Exception on timeouts
  • Access: public

Parameters:

resource   $socket   —  The socket to read from
float   $timeout   —  The timeout for the read

[ Top ]

close   [line 342]

void close( resource $socket)

Close the connection
  • Access: public

Parameters:

resource   $socket   —  The connection/socket to close

[ Top ]

connect   [line 132]

resource connect( string $host, [int $timeout = 2000])

Connect to Gearman

Opens the socket to the Gearman Job server. It throws an exception if a socket error occurs. Also populates Net_Gearman_Connection::$magic.


Parameters:

string   $host   —  e.g. 127.0.0.1 or 127.0.0.1:7003
int   $timeout   —  Timeout in milliseconds

[ Top ]

isConnected   [line 356]

boolean isConnected( resource $conn)

Are we connected?
  • Return: False if we aren't connected
  • Access: public

Parameters:

resource   $conn   —  The connection/socket to check

[ Top ]

read   [line 243]

array read( resource $socket)

Read command from Gearman
  • Return: Result read back from Gearman
  • See: Net_Gearman_Connection::$magic
  • Throws: Net_Gearman_Exception connection issues or invalid responses
  • Access: public

Parameters:

resource   $socket   —  The socket to read from

[ Top ]

send   [line 183]

boolean send( resource $socket, string $command, [array $params = array()])

Send a command to Gearman

This is the command that takes the string version of the command you wish to run (e.g. 'can_do', 'grab_job', etc.) along with an array of parameters (in key value pairings) and packs it all up to send across the socket.


Parameters:

resource   $socket   —  The socket to send the command to
string   $command   —  Command to send (e.g. 'can_do')
array   $params   —  Params to send

[ Top ]

stringLength   [line 371]

integer stringLength( string $value)

Determine if we should use mb_strlen or stock strlen

Parameters:

string   $value   —  The string value to check

[ Top ]

subString   [line 396]

string subString( string $str, integer $start, integer $length)

Multibyte substr() implementation

Parameters:

string   $str   —  The string to substr()
integer   $start   —  The first position used
integer   $length   —  The maximum length of the returned string

[ Top ]


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