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

Class: Net_Gearman_Task

Source Location: /Net_Gearman-0.1.0/Net/Gearman/Task.php

Class Overview


Task class for creating Net_Gearman tasks


Author(s):

Copyright:

  • 2007-2008 Digg.com, Inc.

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 35]
Task class for creating Net_Gearman tasks


[ Top ]


Class Variables

$arg = array()

[line 49]

Arguments to pass to function/job
  • Access: public

Type:   array


[ Top ]

$callback = array(
        self::TASK_COMPLETE => array(),self::TASK_FAIL=>array(),self::TASK_STATUS=>array())

[line 115]

Callbacks registered for each state

Type:   array


[ Top ]

$finished =  false

[line 97]

Is this task finished?

Type:   boolean


[ Top ]

$func =  ''

[line 42]

The function/job to run
  • Access: public

Type:   string


[ Top ]

$handle =  ''

[line 71]

Handle returned from job server

Type:   string


[ Top ]

$result =  ''

[line 104]

The result returned from the worker
  • Access: public

Type:   object


[ Top ]

$type =  self::JOB_NORMAL

[line 63]

Type of job

Which type of job you wish this task to be ran as. Keep in mind that background jobs are "fire and forget" and DO NOT return results to the job server in a manner that you can actually retrieve.


Type:   integer


[ Top ]

$uniq =  ''

[line 87]

The unique identifier for this job

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.

  • Access: public

Type:   string


[ Top ]



Method Detail

__construct (Constructor)   [line 193]

void __construct( string $func, array $arg, [string $uniq = null], [integer $type = self::JOB_NORMAL])

Constructor
  • Access: public

Parameters:

string   $func   —  Name of job to run
array   $arg   —  List of arguments for job
string   $uniq   —  The unique id of the job
integer   $type   —  Type of job to run task as

[ Top ]

attachCallback   [line 217]

void attachCallback( callback $callback, [integer $type = self::TASK_COMPLETE])

Attach a callback to this task
  • Throws: Net_Gearman_Exception
  • Access: public

Parameters:

callback   $callback   —  A valid PHP callback
integer   $type   —  Type of callback

[ Top ]

complete   [line 237]

void complete( object $result)

Run the complete callbacks

Complete callbacks are passed the name of the job, the handle of the job and the result of the job (in that order).


Parameters:

object   $result   —  JSON decoded result passed back

[ Top ]

fail   [line 260]

void fail( )

Run the failure callbacks

Failure callbacks are passed the name of the job and the handle of the job that failed (in that order).


[ Top ]

status   [line 284]

void status( integer $numerator, integer $denominator)

Run the status callbacks

Status callbacks are passed the name of the job, handle of the job and the numerator/denominator as the arguments (in that order).


Parameters:

integer   $numerator   —  The numerator from the status
integer   $denominator   —  The denominator from the status

[ Top ]


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