Module for handling possibly long running tasks
- Description:
Module for handling possibly long running tasks
- Source:
Methods
(static) checkIfRunning(options, callback)
- Description:
Check if task like that is arleady running or not
- Source:
Parameters:
| Name | Type | Description | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | options for the task Properties
|
||||||||||||||||||||||||||||
callback |
funciton | callback for the result |
(static) checkResult(options, callback)
- Description:
Check task's status
- Source:
Parameters:
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | options for the task Properties
|
|||||||||
callback |
funciton | callback for the result |
(static) createTask(options, callbackopt)
- Description:
Create task with data, without result
- Source:
Parameters:
| Name | Type | Attributes | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | options for the task Properties
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
callback |
function |
<optional> |
callback when data is stored |
(static) deleteAdditionalResults(task, options, callback)
- Description:
Delete additional results specific to task type
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
task |
object | the task object |
options |
object | options for the task |
callback |
function | callback for the result |
(static) deleteResult(options, callback)
- Description:
Delete specific task result
- Source:
Parameters:
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | options for the task Properties
|
|||||||||
callback |
funciton | callback for the result |
(static) editTask(options, callback)
- Description:
Edit specific task
- Source:
Parameters:
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | options for the task Properties
|
||||||||||||
callback |
funciton | callback for the result |
(static) errorResults(options, callback)
- Description:
Mark all running or rerunning tasks as errored
- Source:
Parameters:
| Name | Type | Description | ||||||
|---|---|---|---|---|---|---|---|---|
options |
object | options for the task Properties
|
||||||
callback |
funciton | callback for the result |
(static) getCounts(options, callback)
- Description:
Get task counts based on query and grouped by app_id
- Source:
Parameters:
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | options for the task Properties
|
|||||||||
callback |
funciton | callback for the result |
(static) getId() → {string}
- Description:
Generates ID for the task
- Source:
Returns:
id to be used when saving the task
- Type
- string
(static) getResult(options, callback)
- Description:
Get specific task result
- Source:
Parameters:
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | options for the task Properties
|
|||||||||
callback |
funciton | callback for the result |
(static) getResultByQuery(options, callback)
- Description:
Get specific task result
- Source:
Parameters:
| Name | Type | Description | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | options for the task Properties
|
|||||||||
callback |
funciton | callback for the result |
(static) getResults(options, callback)
- Description:
Get multiple task results based on query
- Source:
Parameters:
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | options for the task Properties
|
||||||||||||
callback |
funciton | callback for the result |
(static) getTableQueryResult(options, callback)
- Description:
Get dataTable query results for tasks
- Source:
Parameters:
| Name | Type | Description | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | options for the task Properties
|
||||||||||||||||||
callback |
funciton | callback for the result |
(static) longtask(options) → {function}
- Description:
Monitors DB query or some other potentially long task and switches to long task manager if it exceeds threshold
- Source:
Example
common.db.collection("data").findOne({_id:"test"}, taskmanager.longtask({
db:common.db,
threshold:30,
force:false,
app_id:"58b6d13bf1de9562e5a8029f",
params: params,
type:"funnels",
meta: {},
name:"FunnelName",
view:"#/funnels/task/",
processData:function(err, res, callback){
if(!err)
callback(null, res);
else
callback(null, {});
}, outputData:function(err, data){
common.returnOutput(params, data);
}
}));
Parameters:
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | options for the task Properties
|
Returns:
standard nodejs callback function accepting error as first parameter and result as second one. This result is passed to processData function, if such is available.
- Type
- function
(static) nameResult(options, data, callbackopt)
- Description:
Give a name to task result or rename it
- Source:
Parameters:
| Name | Type | Attributes | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | options for the task Properties
|
|||||||||||||
data |
object | not used at all. pass anything. left for compability |
|||||||||||||
callback |
function |
<optional> |
callback when data is stored |
(static) rerunTask(options, callback)
- Description:
Rerun specific task
- Source:
Parameters:
| Name | Type | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | options for the task Properties
|
|||||||||||||||
callback |
funciton | callback for the result |
(static) saveResult(options, data, callbackopt)
- Description:
Save result from the task
- Source:
Parameters:
| Name | Type | Attributes | Description | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object | options for the task Properties
|
||||||||||||||||||||||
data |
object | result data of the task |
||||||||||||||||||||||
options.gridfs |
boolean | store result in gridfs instead of MongoDB document |
||||||||||||||||||||||
callback |
function |
<optional> |
callback when data is stored |
(inner) getResult(callback, options) → {function}
- Description:
Create a callback for getting result, including checking gridfs
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
callback |
function | callback for the result |
options |
object | options object |
Returns:
callback to use for db query
- Type
- function