Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 421 lines (291 sloc) 13.082 kb

new PowerQueue([options])  Anywhere

Creates an instance of a power queue 
[Check out demo](http://power-queue-test.meteor.com/)

Arguments

  • options {object} (Optional) Settings
    • filo {boolean} (Default = false) Make it a first in last out queue
    • isPaused {boolean} (Default = false) Set queue paused
    • autostart {boolean} (Default = true) May adding a task start the queue
    • name {string} (Default = "Queue") Name of the queue
    • maxProcessing {number} (Default = 1) Limit of simultanous running tasks
    • maxFailures {number} (Default = 5) Limit retries of failed tasks, if 0 or below we allow infinite failures
    • jumpOnFailure {number} (Default = true) Jump to next task and retry failed task later
    • debug {boolean} (Default = false) Log verbose messages to the console
    • reactive {boolean} (Default = true) Set whether or not this queue should be reactive
    • spinalQueue {SpinalQueue} (Optional) Set spinal queue uses pr. default MicroQueue or ReactiveList if added to the project

PowerQueue = function(options) { ... power-queue.js:27

powerqueue.onEnded  Anywhere

This callback onEnded is defined in PowerQueue Is called when queue is ended

self.onEnded = options && options.onEnded || function() { ... power-queue.js:103

powerqueue.onRelease  Anywhere

This callback onRelease is defined in PowerQueue Is called when queue is released

self.onRelease = options && options.onRelease || function() { ... power-queue.js:110

powerqueue.onAutostart  Anywhere

This callback onAutostart is defined in PowerQueue Is called when queue is auto started

self.onAutostart = options && options.onAutostart || function() { ... power-queue.js:115

powerqueue.total()  Anywhere

This method total is defined in PowerQueue

Returns {number} (is reactive) The total number of tasks added to this queue

self.total = self._maxLength.get; power-queue.js:123

powerqueue.isPaused()  Anywhere

This method isPaused is defined in PowerQueue

Returns {boolean} (is reactive) Status of the paused state of the queue

self.isPaused = self._paused.get; power-queue.js:129

powerqueue.processing()  Anywhere

This method processing is defined in PowerQueue

Returns {number} (is reactive) Number of tasks currently being processed

self.processing = self._isProcessing.get; power-queue.js:135

powerqueue.errors()  Anywhere

This method errors is defined in PowerQueue

Returns {number} (is reactive) The total number of errors Errors are triggered when maxFailures are exeeded

self.errors = self._errors.get; power-queue.js:142

powerqueue.failures()  Anywhere

This method failures is defined in PowerQueue

Returns {number} (is reactive) The total number of failed tasks

self.failures = self._failures.get; power-queue.js:148

powerqueue.isRunning()  Anywhere

This method isRunning is defined in PowerQueue

Returns {boolean} (is reactive) True if the queue is running

NOTE: The task can be paused but marked as running

self.isRunning = self._running.get; power-queue.js:155

powerqueue.maxProcessing([max])  Anywhere

This method maxProcessing is defined in PowerQueue

Arguments

  • max {number} (Optional) If not used this function works as a getter

Returns {number} (is reactive) Maximum number of simultaneous processing tasks

Example:

  foo.maxProcessing();    // Works as a getter and returns the current value
  foo.maxProcessing(20);  // This sets the value to 20

self.maxProcessing = self._maxProcessing.getset; power-queue.js:168

powerqueue.autostart([autorun])  Anywhere

This method autostart is defined in PowerQueue

Arguments

  • autorun {boolean} (Optional) If not used this function works as a getter

Returns {boolean} (is reactive) If adding a task may trigger the queue to start

Example:

  foo.autostart();    // Works as a getter and returns the current value
  foo.autostart(true);  // This sets the value to true

self.autostart = self._autostart.getset; power-queue.js:189

powerqueue.maxFailures([max])  Anywhere

This method maxFailures is defined in PowerQueue

Arguments

  • max {number} (Optional) If not used this function works as a getter

Returns {number} (is reactive) The maximum for failures pr. task before triggering an error

Example:

  foo.maxFailures();    // Works as a getter and returns the current value
  foo.maxFailures(10);  // This sets the value to 10

self.maxFailures = self._maxFailures.getset; power-queue.js:202

powerqueue.processList()  Anywhere

This method processList is defined in prototype of PowerQueue

Returns {array} (is reactive) List of tasks currently being processed

PowerQueue.prototype.processingList = function() { ... power-queue.js:209

powerqueue.isHalted()  Anywhere

This method isHalted is defined in prototype of PowerQueue

Returns {boolean} (is reactive) True if the queue is not running or paused

PowerQueue.prototype.isHalted = function() { ... power-queue.js:218

powerqueue.length()  Anywhere

This method length is defined in prototype of PowerQueue

Returns {number} (is reactive) Number of tasks left in queue to be processed

PowerQueue.prototype.length = function() { ... power-queue.js:227

powerqueue.progress()  Anywhere

This method progress is defined in prototype of PowerQueue

Returns {number} (is reactive) 0 .. 100 % Indicates the status of the queue

PowerQueue.prototype.progress = function() { ... power-queue.js:236

powerqueue.usage()  Anywhere

This method usage is defined in prototype of PowerQueue

Returns {number} (is reactive) 0 .. 100 % Indicates ressource usage of the queue

PowerQueue.prototype.usage = function() { ... power-queue.js:249

powerqueue.reset()  Anywhere

This method reset is defined in prototype of PowerQueue Calling this will:

  • stop the queue
  • paused to false
  • Discart all queue data

NOTE: At the moment if the queue has processing tasks they can change the errors and failures counters. This could change in the future or be prevented by creating a whole new instance of the PowerQueue

PowerQueue.prototype.reset = function() { ... power-queue.js:264

powerqueue.add(data, [failures])  Anywhere

This method add is defined in prototype of PowerQueue

Arguments

  • data {any}
    The task to be handled
  • failures {number} (Optional) Internally used to Pass on number of failures.

PowerQueue.prototype.add = function(data, failures, id) { ... power-queue.js:316

powerqueue.next([err])  Anywhere

This method next is defined in prototype of PowerQueue

Arguments

  • err {string} (Optional) Error message if task failed

  • Can pass in null to start the queue
  • Passing in a string to next will trigger a failure
  • Passing nothing will simply let the next task run next is handed into the taskHandler as a callback to mark an error or end of current task

PowerQueue.prototype.next = function(err) { ... power-queue.js:394

powerqueue.queueTaskHandler()  Anywhere

This method queueTaskHandler is defined in prototype of PowerQueue This method handles tasks that are sub queues

PowerQueue.prototype.queueTaskHandler = function(subQueue, next, failures) { ... power-queue.js:555

powerqueue.taskHandler  Anywhere

This callback taskHandler is defined in prototype of PowerQueue

Arguments

  • data {any}
    This can be data or functions
  • next {function}
    Function next call this to end task
  • failures {number}
    Number of failures on this task

Default task handler expects functions as data:

  self.taskHandler = function(data, next, failures) {
    // This default task handler expects invocation to be a function to run
    if (typeof data !== 'function') {
      throw new Error('Default task handler expects a function');
    }
    try {
      // Have the function call next
      data(next, failures);
    } catch(err) {
      // Throw to fail this task
      next(err);
    }
  };

PowerQueue.prototype.taskHandler = function(data, next, failures) { ... power-queue.js:601

powerqueue.errorHandler  Anywhere

This callback errorHandler is defined in prototype of PowerQueue

Arguments

  • data {any}
    This can be data or functions
  • addTask {function}
    Use this function to insert the data into the queue again
  • failures {number}
    Number of failures on this task

The default callback:

  var foo = new PowerQueue();

  // Overwrite the default action
  foo.errorHandler = function(data, addTask, failures) {
    // This could be overwritten the data contains the task data and addTask
    // is a helper for adding the task to the queue
    // try again: addTask(data);
    // console.log('Terminate at ' + failures + ' failures');
  };

PowerQueue.prototype.errorHandler = function(data, addTask, failures) { ... power-queue.js:634

powerqueue.pause()  Anywhere

This method pause is defined in prototype of PowerQueue

PowerQueue.prototype.pause = function() { ... power-queue.js:645

powerqueue.resume()  Anywhere

This method resume is defined in prototype of PowerQueue

This will not start a stopped queue

PowerQueue.prototype.resume = function() { ... power-queue.js:665

powerqueue.run()  Anywhere

This method run is defined in prototype of PowerQueue

Using this command will resume a paused queue and will start a stopped queue.

PowerQueue.prototype.run = function() { ... power-queue.js:677

Something went wrong with that request. Please try again.