Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

gearmanclient.dobackground(3) [php man page]

GEARMANCLIENT.DOBACKGROUND(3)						 1					     GEARMANCLIENT.DOBACKGROUND(3)

GearmanClient::doBackground - Run a task in the background

SYNOPSIS
public string GearmanClient::doBackground (string $function_name, string $workload, [string $unique]) DESCRIPTION
Runs a task in the background, returning a job handle which can be used to get the status of the running task. PARAMETERS
o $function_name - A registered function the worker is to execute o $workload - Serialized data to be processed o $unique - A unique ID used to identify a particular task RETURN VALUES
The job handle for the submitted task. EXAMPLES
Example #1 Submit and monitor a background job The worker in this example has an artificial delay introduced to mimic a long running job. The client script periodically checks the status of the running job. <?php /* create our object */ $gmclient= new GearmanClient(); /* add the default server */ $gmclient->addServer(); /* run reverse client */ $job_handle = $gmclient->doBackground("reverse", "this is a test"); if ($gmclient->returnCode() != GEARMAN_SUCCESS) { echo "bad return code "; exit; } $done = false; do { sleep(3); $stat = $gmclient->jobStatus($job_handle); if (!$stat[0]) // the job is known so it is not done $done = true; echo "Running: " . ($stat[1] ? "true" : "false") . ", numerator: " . $stat[2] . ", denomintor: " . $stat[3] . " "; } while(!$done); echo "done! "; ?> The above example will output something similar to: Running: true, numerator: 3, denomintor: 14 Running: true, numerator: 6, denomintor: 14 Running: true, numerator: 9, denomintor: 14 Running: true, numerator: 12, denomintor: 14 Running: false, numerator: 0, denomintor: 0 done! SEE ALSO
GearmanClient::doNormal, GearmanClient::doHigh, GearmanClient::doLow, GearmanClient::doHighBackground, GearmanClient::doLowBackground. PHP Documentation Group GEARMANCLIENT.DOBACKGROUND(3)

Check Out this Related Man Page

GEARMANCLIENT(3)							 1							  GEARMANCLIENT(3)

The GearmanClient class

INTRODUCTION
Represents a class for connecting to a Gearman job server and making requests to perform some function on provided data. The function per- formed must be one registered by a Gearman worker and the data passed is opaque to the job server. CLASS SYNOPSIS
GearmanClient GearmanClient Methods o public bool GearmanClient::addOptions (int $options) o public bool GearmanClient::addServer ([string $host = 127.0.0.1], [int $port = 4730]) o public bool GearmanClient::addServers ([string $servers = 127.0.0.1:4730]) o public GearmanTask GearmanClient::addTask (string $function_name, string $workload, [mixed &$context], [string $unique]) o public GearmanTask GearmanClient::addTaskBackground (string $function_name, string $workload, [mixed &$context], [string $unique]) o public GearmanTask GearmanClient::addTaskHigh (string $function_name, string $workload, [mixed &$context], [string $unique]) o public GearmanTask GearmanClient::addTaskHighBackground (string $function_name, string $workload, [mixed &$context], [string $unique]) o public GearmanTask GearmanClient::addTaskLow (string $function_name, string $workload, [mixed &$context], [string $unique]) o public GearmanTask GearmanClient::addTaskLowBackground (string $function_name, string $workload, [mixed &$context], [string $unique]) o public GearmanTask GearmanClient::addTaskStatus (string $job_handle, [string &$context]) o public bool GearmanClient::clearCallbacks (void ) o public GearmanClient GearmanClient::clone (void ) o public GearmanClient::__construct (void ) o public string GearmanClient::context (void ) o public string GearmanClient::data (void ) o public string GearmanClient::do (string $function_name, string $workload, [string $unique]) o public string GearmanClient::doBackground (string $function_name, string $workload, [string $unique]) o public string GearmanClient::doHigh (string $function_name, string $workload, [string $unique]) o public string GearmanClient::doHighBackground (string $function_name, string $workload, [string $unique]) o public string GearmanClient::doJobHandle (void ) o public string GearmanClient::doLow (string $function_name, string $workload, [string $unique]) o public string GearmanClient::doLowBackground (string $function_name, string $workload, [string $unique]) o public string GearmanClient::doNormal (string $function_name, string $workload, [string $unique]) o public array GearmanClient::doStatus (void ) o public bool GearmanClient::echo (string $workload) o public string GearmanClient::error (void ) o public int GearmanClient::getErrno (void ) o public array GearmanClient::jobStatus (string $job_handle) o public bool GearmanClient::ping (string $workload) o public bool GearmanClient::removeOptions (int $options) o public int GearmanClient::returnCode (void ) o public bool GearmanClient::runTasks (void ) o public void GearmanClient::setClientCallback (callable $callback) o public bool GearmanClient::setCompleteCallback (callable $callback) o public bool GearmanClient::setContext (string $context) o public bool GearmanClient::setCreatedCallback (string $callback) o public bool GearmanClient::setData (string $data) o public bool GearmanClient::setDataCallback (callable $callback) o public bool GearmanClient::setExceptionCallback (callable $callback) o public bool GearmanClient::setFailCallback (callable $callback) o public bool GearmanClient::setOptions (int $options) o public bool GearmanClient::setStatusCallback (callable $callback) o public bool GearmanClient::setTimeout (int $timeout) o public bool GearmanClient::setWarningCallback (callable $callback) o public bool GearmanClient::setWorkloadCallback (callable $callback) o public int GearmanClient::timeout (void ) PHP Documentation Group GEARMANCLIENT(3)
Man Page