From 30c6f10d8091b8ce460e1b79c0052fae30f815e6 Mon Sep 17 00:00:00 2001 From: Paolo Date: Wed, 4 Mar 2020 15:54:23 +0100 Subject: [PATCH] First proposal --- application/config/jqm.php | 6 ++ .../controllers/system/JobsQueueMonitor.php | 56 +++++++++++++++++++ application/core/JQW_Controller.php | 56 +++++++++++++++++++ application/libraries/JobsQueueLib.php | 56 +++++++++++++++++++ 4 files changed, 174 insertions(+) create mode 100644 application/config/jqm.php create mode 100644 application/controllers/system/JobsQueueMonitor.php create mode 100644 application/core/JQW_Controller.php create mode 100644 application/libraries/JobsQueueLib.php diff --git a/application/config/jqm.php b/application/config/jqm.php new file mode 100644 index 000000000..5890241ae --- /dev/null +++ b/application/config/jqm.php @@ -0,0 +1,6 @@ + 'monitoring:r', + 'getJobsByStatus' => 'monitoring:r', + 'getJobsByCreationTime' => 'monitoring:r' + ) + ); + + // Loads JobsQueueLib + $this->load->library('JobsQueueLib'); + } + + /** + * + */ + public function getJobsByType() + { + $jobType = $this->input->get(JobsQueueLib::PARAM_JOB_TYPE); + + $this->outputJson($this->jobsqueuelib->getJobsByType($jobType)); + } + + /** + * + */ + public function getJobsByStatus() + { + $jobStatus = $this->input->get(JobsQueueLib::PARAM_JOB_STATUS); + + $this->outputJson($this->jobsqueuelib->getJobsByStatus($jobStatus)); + } + + /** + * + */ + public function getJobsByCreationTime() + { + $jobCreationTime = $this->input->get(JobsQueueLib::PARAM_JOB_CREATION_TIME); + + $this->outputJson($this->jobsqueuelib->getJobsByCreationTime($jobCreationTime)); + } +} diff --git a/application/core/JQW_Controller.php b/application/core/JQW_Controller.php new file mode 100644 index 000000000..9cb058f6b --- /dev/null +++ b/application/core/JQW_Controller.php @@ -0,0 +1,56 @@ +load->library('LogLib', array( + 'classIndex' => 5, + 'functionIndex' => 5, + 'lineIndex' => 4, + 'dbLogType' => 'job', // required + 'dbExecuteUser' => 'Jobs queue system' + )); + + // Loads JobsQueueLib + $this->load->library('JobsQueueLib'); + } + + // ------------------------------------------------------------------------------------------------------------ + // Protected methods to read/write the jobs queue + + /** + * + */ + protected function getJobsByType($jobType) + { + $jobs = $this->jobsqueuelib->getJobsByType($jobType); + + if (isError($jobs)) $this->logError(getError($jobs), $jobType); + + return $jobs; + } + + /** + * + */ + protected function addNewJobsToQueue($jobType, $jobs) + { + $result = $this->jobsqueuelib->addNewJobsToQueue($jobType, $jobs); + + if (isError($result)) $this->logError(getError($result), $jobType); + + return $result; + } +} diff --git a/application/libraries/JobsQueueLib.php b/application/libraries/JobsQueueLib.php new file mode 100644 index 000000000..0c7e44274 --- /dev/null +++ b/application/libraries/JobsQueueLib.php @@ -0,0 +1,56 @@ +_ci =& get_instance(); + } + + //------------------------------------------------------------------------------------------------------------------ + // Public methods + + /** + * + */ + public function getJobsByType() + { + } + + /** + * + */ + public function addNewJobsToQueue() + { + } + + /** + * + */ + public function getJobsByStatus() + { + } +}