AsyncJobRunner Class
An abstract implementation of JobRunner that handles performing a series of asynchronous tasks. The runner provides the ability to run the tasks in parallel or 1 after another. The extending implementation must provides the set of tasks to execute
Constructor
AsyncJobRunner
()
Item Index
Methods
Properties
Methods
getChunkOfWorkPercentage
()
Number
Returns:
getId
()
String
Returns:
getTasks
-
cb
Responsible for providing an array or hash of tasks that will be executed by the job. The extending implmentation MUST override this function or an error will be thrown.
Parameters:
-
cbFunctionA callback that takes two parameters: cb(Error, Object|Array)
init
-
[name] -
[jobId]
Parameters:
-
[name]String optionalThe job's name -
[jobId]String optionalThe job's unique identifier
log
-
message
Parameters:
-
messageStringThe message or pattern to log
onBeforeFirstTask
-
cb
Called directly before the first tasks begins to execute. It is recommended that the extending implementation override this function in order to call the "onStart" function.
Parameters:
-
cbFunctionA callback that takes one optional error parameter
onCompleted
-
[status] -
err
Parameters:
-
[status]String optionalThe final status of the job. If not provided the status will default to 'COMPLETED' or 'ERRORED' when an error is provided as the second parameter. -
errErrorThe error, if any, that was generated by the job's execution
onStart
-
[status='RUNNING']
Parameters:
-
[status='RUNNING']String optionalThe starting status of the job
onUpdate
-
progressIncrement -
[status]
Parameters:
-
progressIncrementInteger -
[status]String optional
processResults
-
err -
results
Called once after job execution. It is recommended that extending implmentations use this function to peform any ETL operations to prepare data for the callback.
Parameters:
-
errErrorThe error generated during task execution if exists
-
resultsObject | ArrayThe result of each tasks' execution.
run
-
cb
Kicks off the set of tasks for the job. The implementation wraps the items in a domain in an attempt to provide a level of error handling. When a qualifying error is intercepted by the domain processResults is called providing the error and all other task execution is halted.
Parameters:
-
cbFunction
setChunkOfWorkPercentage
-
chunkOfWorkPercentage
Parameters:
-
chunkOfWorkPercentageNumber
Returns:
setParallelLimit
-
max
Sets the number of tasks to run in parallel
Parameters:
-
maxIntegerThe maximum number of tasks to run in parallel
Properties
id
String
parallelLimit
Integer
The number of tasks to run in parallel
