mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-24 02:12:17 +00:00
2nd draft
This commit is contained in:
@@ -5,11 +5,13 @@ if (!defined("BASEPATH")) exit("No direct script access allowed");
|
||||
/**
|
||||
* Long Run Task
|
||||
*
|
||||
* This controller acts as interface of the LongRunTaskLib that contains
|
||||
* - This controller acts as interface of the LongRunTaskLib that contains
|
||||
* all the needed functionalities to operate with the Long Run Task system
|
||||
* that is built on top of the Jobs Queue System
|
||||
* This is an abstract class that provide basic functionalities,
|
||||
* - This is an abstract class that provide basic functionalities,
|
||||
* it has to be extended to broaden its logic
|
||||
* - Any implementation of a Long Run Task should extends this class to
|
||||
* properly operate with the LRT system
|
||||
*/
|
||||
abstract class LRT_Controller extends JQW_Controller
|
||||
{
|
||||
@@ -23,8 +25,8 @@ abstract class LRT_Controller extends JQW_Controller
|
||||
// Changes the needed configs for LogLib
|
||||
$this->LogLibJob->setConfigs(
|
||||
array(
|
||||
'dbExecuteUser' => 'LRTs queue system',
|
||||
'requestId' => 'LTR'
|
||||
'dbExecuteUser' => get_class($this),
|
||||
'requestId' => 'LRT'
|
||||
)
|
||||
);
|
||||
|
||||
@@ -32,42 +34,36 @@ abstract class LRT_Controller extends JQW_Controller
|
||||
$this->load->library('LongRunTaskLib');
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
abstract public function run($jobid);
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Protected methods
|
||||
|
||||
/**
|
||||
* Get the oldest added LRTs to the queue having status = new
|
||||
*/
|
||||
protected function getLRTs()
|
||||
{
|
||||
$lrts = $this->longruntasklib->getLRTs();
|
||||
|
||||
// If an error occurred then log it in database
|
||||
if (isError($lrts)) $this->logError(getError($lrts));
|
||||
|
||||
return $lrts;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function addNewLRTsToQueue($type, $lrts)
|
||||
protected function getLrt($jobid)
|
||||
{
|
||||
$result = $this->longruntasklib->addNewLRTsToQueue($type, $lrts);
|
||||
|
||||
// If an error occurred then log it in database
|
||||
if (isError($result)) $this->logError(getError($result), $type);
|
||||
|
||||
return $result;
|
||||
$this->longruntasklib->getLrt($jobid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility method to generate a job with the given parameters and return it inside an array
|
||||
* ready to be used by addNewJobsToQueue and updateJobsQueue
|
||||
*
|
||||
*/
|
||||
protected function generateJobs($status, $input)
|
||||
protected function setProgress($jobid, $progress)
|
||||
{
|
||||
return JobsQueueLib::generateJobs($status, $input);
|
||||
$this->longruntasklib->setProgress($jobid, $progress);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected function setOutuput($jobid, $output)
|
||||
{
|
||||
$this->longruntasklib->setOutuput($jobid, $output);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user