GearmanWorker::work

(PECL gearman >= 0.5.0)
Wait for and perform jobs
public bool GearmanWorker::work ( void )

Waits for a job to be assigned and then calls the appropriate callback function. Issues an E_WARNING with the last Gearman error if the return code is not one of GEARMAN_SUCCESS, GEARMAN_IO_WAIT, or GEARMAN_WORK_FAIL.

Returns:

Returns TRUE on success or FALSE on failure.

Examples:
GearmanWorker::work() example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php
 
# create the worker
$worker new GearmanWorker(); 
 
# add the default job server (localhost)
$worker->addServer(); 
 
# add the reverse function
$worker->addFunction("reverse""my_reverse_function"); 
 
# start te worker listening for job submissions
while ($worker->work()); 
  
function my_reverse_function($job
  return strrev($job->workload()); 
}
 
?>
See also:

GearmanWorker::addFunction() -

doc_php
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.