...
Here is the matrix of what's currently supported by In-Portal:
Interactive | Non-Interactive | |
---|---|---|
User Triggered |
|
|
System Triggered |
|
|
Thoughts:
- interactive tasks are blocking UI and therefore user can't do something else in Admin Console while they are running
- user don't create about real-time status update of interactive tasks in most (but not all) cases, but just wants to know when they're completed
- scheduled tasks (system triggered non-interactive tasks):
- provide limited insight about task execution status
- only retain last task execution status
- e-mail queue:
- successfully executed tasks are removed from queue (the "E-mail Logs" section sort of compensates for that currently)
- no error information is stored within task
...
- create "
TaskQueue
" class (not item of "task-queue
" unit) - 0.1h - add protected "
TaskQueue::createTaskHandler($class_name)
" method, that will: - 0.5h- create instance of given class or throw an exception when failed
- if created object doesn't implement "
ITaskHandler
" interface, then throw an exception - return the object
- add public "
TaskQueue::addTask($task_handler_class, array $task_data, $scheduled_on, $max_retries = null)
" method, that will: - 0.4h- call "
TaskQueue::createTaskHandler
" method to verify, that class given in "$task_handler_class
" parameter is valid - consider "
$max_retries
" as "5
" when not given - create new db record using provided data using "
task-queue
" object
- call "
- add public "
TaskQueue::refreshTaskRunnersStatus()
" method that will: - 0.5h- get all "
task-runner
" in "running
" status - if associated process isn't running anymore, then set "
task-runner
" status from "running
" to "timeout
" (the "task-runner::OnAfterItemUpdate
" would update connected task runs)
- get all "
- add protected "
TaskQueue::createTaskRun(kDBItem $task_queue)
" method, that will: - 0.5h- will create new task run (and return it's ID) for given queue record, when all of following rules aren't violated:
- only 1 (or less) running "
task-run
" can exist for one "task-queue
" record - "
TaskRunsFailed
" must be smaller, then "MaxRetries
" on associated "task-queue
" record
- only 1 (or less) running "
- return "
null
" otherwise
- will create new task run (and return it's ID) for given queue record, when all of following rules aren't violated:
- add protected "
TaskQueue::createMissingTaskRuns()
" method, that will: - 0.5h- get all records from "
TaskQueue
" table, for which task runs can be created:ScheduledOn
<NOW()
LastStatus
is not "running
"TaskRunsFailed
must be smaller, thenMaxRetries
- call the "
TaskQueue::createTaskRun
" method on each of them (method can return "NULL" in some cases, but that's ok)
- get all records from "
- add protected "
TaskQueue::getTaskRunnerCount()
" method, that will return number of "task-runner
" in "running
" status - 0.3h - add protected "
TaskQueue::getMissingTaskRunnerCount()
" method, that will: - 0.2h- get value of "
TaskRunnerLimit
" system setting - call "
TaskQueue::getTaskRunnerCount
" method - return difference or 0, when difference is negative
- get value of "
- add public "
TaskQueue::runStandalone()
", that will: - 0.5h- call "
TaskQueue::getTaskRunner
" method - if object is returned call "
->process()
" method on it
- call "
- add public "
TaskQueue::createMissingTaskRunners()
" method, that will: - 0.5h- if in CLI:
- call "
TaskQueue::getMissingTaskRunnerCount
" method - if it returned "0" do nothing
- execute command (see last plan) X number of times in background processes (X - number returned above)
- call "
- if not in CLI:
- call "
TaskQueue::runStandalone
" method
- call "
- if in CLI:
- add public "
TaskQueue::processQueue()
" method, that will: - 0.4h- call "
TaskQueue::
" methodrefreshTaskRunnersStatus
- call "
TaskQueue::createMissingTaskRuns
" method
- call "
- create "
task-queue:OnProcess
" event, that: - 0.1h- would be called as Scheduled Task on a regular basis (e.g. each 5 minutes)
- would call "
TaskQueue::processQueue
" method
- create "
task-queue:OnCreateTaskRunners
" event, that: - 0.3h- would be called as Scheduled Task on a regular basis (e.g. each 5 minutes) - can be disabled if needed
- will call "
TaskQueue::createMissingTaskRunners
" method
- create "
task-queue:OnDebug
" event, that will call "TaskQueue::runStandalone
" method - 0.2h
...