Renamed the codebase to RippingCluster
Since the new design is engine agnostic, removed HandBrake from the class names.
This commit is contained in:
48
lib/RippingCluster/Worker.class.php
Normal file
48
lib/RippingCluster/Worker.class.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
class RippingCluster_Worker {
|
||||
|
||||
protected $gearman;
|
||||
|
||||
public function __construct() {
|
||||
$this->init();
|
||||
|
||||
}
|
||||
|
||||
private function init() {
|
||||
if ($this->gearman) {
|
||||
return;
|
||||
}
|
||||
|
||||
$config = RippingCluster_Main::instance()->config();
|
||||
|
||||
$this->gearman = new GearmanWorker();
|
||||
$this->gearman->addServers($config->get('rips.job_servers'));
|
||||
|
||||
// Load all the plugin classes
|
||||
echo "Loading Plugins\n";
|
||||
RippingCluster_Worker_PluginFactory::scan();
|
||||
foreach (RippingCluster_Worker_PluginFactory::getValidPlugins() as $plugin) {
|
||||
echo "Grabbing worker functions provided by {$plugin}\n";
|
||||
$workerFunctions = RippingCluster_Worker_PluginFactory::getPluginWorkerFunctions($plugin);
|
||||
|
||||
foreach ($workerFunctions as $function => $callback) {
|
||||
echo "Adding {$plugin}::{$callback[1]} as {$function}\n";
|
||||
$this->gearman->addFunction($function, $callback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function start() {
|
||||
while($this->gearman->work()) {
|
||||
if ($this->gearman->returnCode() != GEARMAN_SUCCESS) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user