Task Object Overview


Tasks provide the capability to periodically execute queries against internal and/or external data sources and use the results to create new Drops or execute some additional flow.js. What this means in practice is that you can use some external data source such as a REST api as a source of streaming data to drive flowthings.io applications by running requests on it at a fixed time interval.

Tasks execute as a two-step procedure. First, the source part of the task is executed (if specified). This is where you describes how and where queries will be executed and optionally how the returned data parsed. The query can be executed against an url or against the flow.js drop.find() API.

The second js step uses a javascript function that will then further turn the results from the source into some number of Drops.

Task Object Members


periodicity

periodicity controls how often the task will be invoked and is expressed in milliseconds. If no value is set the default value of 1 hour (3600000) will be used. Tasks can not be scheduled to run more often than once per minute. Values below 1 minute will be rejected.

displayName

The displayName member is a string (max 2048 chars). It is optional and its primary purpose is to store a human-readable name for the Task.

description

The description member is a string. It is optional and its primary purpose is to store a human-readable description or contextual data concerning the Task.

reportFlowId (Read Only)

The reportFlowId member is the unique identifier for the task's reporting Flow. A Drop with information on the task's performance will be written to this Flow every time a task is executed.

reportPath (Read Only)

The reportPath member is the path to the task's reporting Flow. A Drop with information on the task's performance will be written to this Flow every time a task is executed.

lastRun (Read Only)

The lastRun member is the millisecond timestamp indicating the most recent execution of the Task.

nextRun (Read Only)

"destination":"/path/to/my/flow" The nextRun member is the millisecond timestamp indicating the next scheduled execution of the Task.

status (Read Only)

The status member is a string indicating the state of the most recent Task execution.

runCt (Read Only)

The runCt member is an integer indication the number of times the Task has been run.

destination

Just as with Tracks, every Task requires a default destination Flow where generated Drops will be sent. If you provide an associated javascript processing function for this task you can dynamically redefine the destination.

source

The source field specifies a map that describes how a task will retrieve its data. This data may then be subject to additional processing in the js step or directly written to the destination flow. For more information, see Tasks In Depth.

js

The js field specifies a javascript function that takes a list of any drops that may have been preparsed in the source, as well as any request data that may have been generated by an http request in the source, and must output drops that will then be written to their specified flows. For more information, see Tasks In Depth.