Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Here is the matrix of what's currently supported by In-Portal:

 InteractiveNon-Interactive
User Triggered
  • all import scripts (e.g. product import in catalog)
  • rebuilding of category permissions cache
  • template parser template recompilation
  • e-mail queue
System Triggered
  • not supported
  • all scheduled tasks

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

...

  1. create "TaskQueue" class (not item of "task-queue" unit) - 0.1h
  2. add protected "TaskQueue::createTaskHandler($class_name)" method, that will: - 0.5h
    1. create instance of given class or throw an exception when failed
    2. if created object doesn't implement "ITaskHandler" interface, then throw an exception
    3. return the object
  3. add public "TaskQueue::addTask($task_handler_class, array $task_data, $scheduled_on, $max_retries = null)" method, that will: - 0.4h
    1. call "TaskQueue::createTaskHandler" method to verify, that class given in "$task_handler_class" parameter is valid
    2. consider "$max_retries" as "5" when not given
    3. create new db record using provided data using "task-queue" object
  4. add public "TaskQueue::refreshTaskRunnersStatus()" method that will: - 0.5h
    1. get all "task-runner" in "running" status
    2. 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)
  5. add protected "TaskQueue::createTaskRun(kDBItem $task_queue)" method, that: - 0.5h
    1. will create new task run (and return it's ID) for given queue record, when all of following rules aren't violated:
      1. only 1 (or less) running "task-run" can exist for one "task-queue" record
      2. "TaskRunsFailed" must be smaller, then "MaxRetries" on associated "task-queue" record
    2. return "null" otherwise
  6. add protected "TaskQueue::createMissingTaskRuns()" method, that will: - 0.5h
    1. get all records from "TaskQueue" table, for which task runs can be created:
      1. ScheduledOn < NOW()
      2. LastStatus is not "running"
      3. TaskRunsFailed must be smaller, then MaxRetries
    2. call the "TaskQueue::createTaskRun" method on each of them (method can return "NULL" in some cases, but that's ok)
  7. add protected "TaskQueue::getTaskRunnerCount()" method, that will return number of "task-runner" in "running" status - 0.3h
  8. add protected "TaskQueue::getMissingTaskRunnerCount()" method, that will: - 0.2h
    1. get value of  "TaskRunnerLimit" system setting
    2. call "TaskQueue::getTaskRunnerCount" method
    3. return difference or 0, when difference is negative
  9. add public "TaskQueue::runStandalone()", that will: - 0.5h
    1. call "TaskQueue::getTaskRunner" method
    2. if object is returned call "->process()" method on it
  10. add public "TaskQueue::createMissingTaskRunners()" method, that will: - 0.5h
    1. if in CLI:
      1. call "TaskQueue::getMissingTaskRunnerCount" method
      2. if it returned "0" do nothing
      3. execute command (see last plan) X number of times in background processes (X - number returned above)
    2. if not in CLI:
      1. call "TaskQueue::runStandalone" method
  11. add public "TaskQueue::processQueue()" method, that will: - 0.4h
    1. call "TaskQueue::refreshTaskRunnersStatus" method
    2. call "TaskQueue::createMissingTaskRuns" method
  12. create "task-queue:OnProcess" event, that: - 0.1h
    1. would be called as Scheduled Task on a regular basis (e.g. each 5 minutes)
    2. would call "TaskQueue::processQueue" method
  13. create "task-queue:OnCreateTaskRunners" event, that: - 0.3h
    1. would be called as Scheduled Task on a regular basis (e.g. each 5 minutes) - can be disabled if needed
    2. will call "TaskQueue::createMissingTaskRunners" method
  14. create "task-queue:OnDebug" event, that will call "TaskQueue::runStandalone" method - 0.2h

...