Voting

: seven plus two?
(Example: nine)

The Note You're Voting On

liv_romania at yahoo dot com
10 years ago
To properly test the server added you could use the following code:

<?php
// create the worker
$worker= new GearmanWorker();

// add the job server (bad host/port)
$worker->addServer('127.0.0.2', 4731);

// define a variable to hold application data
$count = 0;

// add the reverse function
$worker->addFunction('reverse', 'my_reverse_function', $count);

// test job server response
if (!@$worker->echo('test data')) {
die(
$worker->error());
}

// start the worker listening for job submissions
while ($worker->work());

function
my_reverse_function($job, &$count)
{
$count++;

return
$count . ': ' . strrev($job->workload()) . "\n";
}
?>

<< Back to user notes page

To Top