Webanizr Logo
Open / sluit menu
Module taskModelAPI

Last change: July 6, 2020

Current version: 1.2.0

Requires at least webanizr 1.16.0 for correct error handling.

The taskModelAPI module is used for executing tasks, queueing tasks, chunking, pausing and resuming tasks.

The state of the task execution is shared in webanizr variables:

  • status__taskmodelapi: the actual status of the executer. If it is set, it can have these values:
    • busy: in case a task execution is in progress (also the state in case of chunks)
    • idle: in case no tasks are in progress
    • paused: is the state after a task failed. No further tasks will be executed. Until manually resumed. An interface solution should assist in doing so (e.g. resume or clear-all)
  • queuelength__taskmodelapi: the amount of tasks that is still in the queue. 
  • cursor__taskmodelapi: in case a task is executed in chunks and returns a cursor, the cursor is updated here.

All tasks to execute are queued and executed in order. Upfollowing chunks of a chunked task will not get any priority in case in the mean time other tasks were queued. This will keep the system responsive to work with in case of time consuming tasks like exports or imports. 

webanizr.send('taskModelAPI', data, parameters, callack, error);

send

data

The data used as parameters for this particular task.

parameters

The taskModelAPI module accepts the following parameters:

type__action

The type of action to execute. Defaults to "execute", but can be one of the following:

  • execute: to execute a task. The name of the task to execute should be in parameter "execute__task"
  • debug: to enable verbose logging for this plugin
  • resume: to resume execution of tasks in case the executer halted on a failed tasked
  • delete-all: to remove any pending tasks from the queue

url__taskserver (optional)

The url to send the request to. If not given, the request will go to the task service url of the current domain.

callback

The callback to call after execution of the task

error

The callback to call if the task failed to execute. 

Changelog

  • July 6, 2020: 1.2.0 - Added parameter url__taskserver
  • January 30, 2020: 1.1.2 - context parses webanizr vars
  • January 16, 2020: 1.0.0 - first version of the module