brianlmoon / net_gearman

A PHP interface for Gearman
84 stars 46 forks source link

Returning data from a function #47

Closed stccorp closed 3 years ago

stccorp commented 3 years ago

I am having problem getting data back from a function. If I go to the php manual, with task you can send a return parameter that you can use later. But here I dont seem to be able to pass that parameter.

class GearmanTest { static function workCB($func, $handle, $result){ var_dump($result); }

function doWork($param) { $client = new Net_Gearman_Client("localhost"); $set = new Net_Gearman_Set(); $task = new Net_Gearman_Task("gearman_function", $param);

    $task->attachCallback('GearmanTest::workCB');
    $set->addTask($task);
    $client->runSet($set);

    return WHAT???**********************

}

}

//using it here $engine = new GearmanTest(); $out = $engine->doWork('123'); //dont know how to return the out data

brianlmoon commented 3 years ago

Whatever callback you set will need to expose the result to your current scope.