- Channel ⇐
EventEmitter Channel class (queue)
- ChannelQueue ⇐
EventEmitter ChannelQueue class, for managing channels
- ParallelChannel ⇐
Channel ParallelChannel class (queue)
- Task
Internal Task class, for handling executions
- TaskPriority :
Normal|High|Tail Task Priority
ChannelQueue class, for managing channels
Kind: global class
Extends: EventEmitter
- ChannelQueue ⇐
EventEmitter
The channels
Kind: instance property of ChannelQueue
channelQueue.createChannel(name) ⇒ Channel
Create a new channel
Kind: instance method of ChannelQueue
Returns: Channel - The new channel
Throws:
ErrorThrows if the channel already exists
| Param | Type | Description |
|---|---|---|
| name | String |
The channel name |
channelQueue.createParallelChannel(name, [parallelism]) ⇒ ParallelChannel
Create a new parallel channel Creates a special channel that supports running several tasks in parallel.
Kind: instance method of ChannelQueue
Returns: ParallelChannel - The new channel
Throws:
ErrorThrows if the channel already exists
| Param | Type | Description |
|---|---|---|
| name | String |
The name of the channel |
| [parallelism] | Number |
Optional number of maximum parallel tasks |
channelQueue.channel(name) ⇒ Channel
Get channel by name Creates a new channel automatically if it doesn't yet exist
Kind: instance method of ChannelQueue
Returns: Channel - The channel which was requested
| Param | Type | Description |
|---|---|---|
| name | String |
The channel name |
Check if a channel exists
Kind: instance method of ChannelQueue
Returns: Boolean - True if it exists
| Param | Type | Description |
|---|---|---|
| name | String |
The name of the channel |
ParallelChannel ⇐ Channel
ParallelChannel class (queue)
Kind: global class
Extends: Channel
- ParallelChannel ⇐
Channel- .isEmpty :
Boolean - .parallelism :
Number - .runningTasks :
Array.<Task> - .autostart :
Boolean - .isRunning :
Boolean - .name :
String - .tasks :
Array.<Task> - .tasksThrow :
Boolean - .clear([priorityType])
- .enqueue(item, [type], [stack], [timeout]) ⇒
Promise - .getStackedItems(stack) ⇒
Array.<Task> - .retrieveNextItem() ⇒
Task|undefined - .sort()
- .start() ⇒
Boolean - .waitForEmpty() ⇒
Promise
- .isEmpty :
Whether the queue is empty or not
Kind: instance property of ParallelChannel
Overrides: isEmpty
Read only: true
The amount of allowed parallel executed tasks
Kind: instance property of ParallelChannel
Read only: true
parallelChannel.runningTasks : Array.<Task>
Get the currently running tasks
Kind: instance property of ParallelChannel
Read only: true
Whether the execution should start automatically or not Defaults to true
Kind: instance property of ParallelChannel
Overrides: autostart
Whether the queue is currently running or not
Kind: instance property of ParallelChannel
Overrides: isRunning
Read only: true
The name of the channel
Kind: instance property of ParallelChannel
Overrides: name
Read only: true
parallelChannel.tasks : Array.<Task>
Array of tasks (in queue)
Kind: instance property of ParallelChannel
Overrides: tasks
Read only: true
Whether or not tasks throw errors
Kind: instance property of ParallelChannel
Overrides: tasksThrow
Remove all pending tasks from the channel
Kind: instance method of ParallelChannel
Overrides: clear
| Param | Type | Description |
|---|---|---|
| [priorityType] | String |
Optional priority type to clear only tasks with a certain priority value |
Enqueues a function
Kind: instance method of ParallelChannel
Overrides: enqueue
Returns: Promise - A promise that eventually resolves with the result from the
enqueued function or promise
| Param | Type | Description |
|---|---|---|
| item | function | Promise |
The item to place into the queue |
| [type] | TaskPriority |
The task priority to use |
| [stack] | String |
The stack name |
| [timeout] | Number |
Optional millisecond time-limt |
parallelChannel.getStackedItems(stack) ⇒ Array.<Task>
Get all task items for a stack name
Kind: instance method of ParallelChannel
Overrides: getStackedItems
Returns: Array.<Task> - An array of task instances
| Param | Type | Description |
|---|---|---|
| stack | String |
The stack name |
parallelChannel.retrieveNextItem() ⇒ Task | undefined
Get the next queued Task instance This modifies the task queue by removing the task
Kind: instance method of ParallelChannel
Overrides: retrieveNextItem
Returns: Task | undefined - A task instance if there are any in queue
Sort the tasks
Kind: instance method of ParallelChannel
Overrides: sort
Start processing the queue Will automatically return early if queue has already started
Kind: instance method of ParallelChannel
Overrides: start
Returns: Boolean - Returns true if started, false if already started
Emits: Channel#event:started, Channel#event:stopped
Wait for the queue to become empty
Kind: instance method of ParallelChannel
Overrides: waitForEmpty
Internal Task class, for handling executions
Kind: global class
- Task
- new Task(item, [type], [stack])
- .created :
Number - .error :
Error|null - .queuedPromise :
Promise - .stack :
String - .target :
function - .timeLimit :
Number - .type :
TaskPriority - .execute() ⇒
Promise
Constructor for a Task
| Param | Type | Description |
|---|---|---|
| item | function | Promise |
The item to enqueue |
| [type] | TaskPriority |
The priority to set |
| [stack] | String |
The stack name |
Creation timestamp
Kind: instance property of Task
Read only: true
Execution error, if one occurred
Kind: instance property of Task
Promise which resolves when work has completed
Kind: instance property of Task
The stack name
Kind: instance property of Task
The target function
Kind: instance property of Task
Current time limit
Kind: instance property of Task
task.type : TaskPriority
The task priority type
Kind: instance property of Task
Execute the task
Kind: instance method of Task
Task Priority
Kind: global typedef
Normal task priority
Kind: static property of TaskPriority
High task priority
Kind: static property of TaskPriority
Task tail-priority
Kind: static property of TaskPriority