Class TaskQueue

Task queue with concurrency control. By default, all added tasks will be auto scheduled and executed. You can use stop() and start() to control the execution.

Hierarchy

  • TaskQueueBase
    • TaskQueue

Constructors

Properties

concurrency: number
defaultIncrementalTaskId: boolean
failedRetryableTaskQueue: Task<any>[] = []
logger: ILogger
memorizeTasks: boolean
messageHub: MessageHub
onTaskStatusUpdate: undefined | TaskStatusUpdateHandler<any> = undefined
prioritizedTasksWaitingQueue: WaitedTask<any>[] = []
promiseQueueCapacity: number = PROMISE_QUEUE_CAPACITY
promiseQueues: PromiseQueue[] = []
retrying: boolean = false
stopOnError: boolean
stopped: boolean = false
taskLookup: Record<TaskId, Task<any>> = {}
taskPrioritizationMode: TaskPrioritizationMode
tasksWaitingQueue: WaitedTask<any>[] = []

Methods

  • Internal

    Returns void

  • Internal

    Returns null | PromiseQueue

  • Internal

    Parameters

    • previousTaskHasRun: boolean

    Returns undefined | null | Task<any>

  • Internal

    Parameters

    • config: {
          level: LoggerMethodNames;
          taskId?: TaskId;
      }
      • level: LoggerMethodNames
      • Optional taskId?: TaskId
    • Rest ...messages: any[]

    Returns void

  • Internal

    Parameters

    • task: WaitedTask<any>

    Returns void

  • Internal

    Parameters

    • Optional task: Task<any>

    Returns boolean

  • Add tasks with callback functions to the queue.

    Parameters

    • tasks: {
          callback: (() => unknown);
          onStatusUpdate?: TaskStatusUpdateHandler<unknown>;
          priority?: TaskPriority;
          taskId?: TaskId;
      }[]

      The array of tasks with callback functions, IDs, task status update subscribers, and priorities

    Returns Promise<unknown[]>

  • Adjust the concurrency.

    Parameters

    • newConcurrency: number

      The new concurrency

    • taskBalancingStrategy: "round-robin" = 'round-robin'

      The existing running task balancing strategy

    Returns void

  • Clear all task details.

    Returns void

  • Clear all failed retryable tasks from the queue.

    Returns void

  • Clear the task details with task ID.

    Parameters

    • taskId: TaskId

      The ID of the task

    Returns void

  • Clear all waited tasks from the queue.

    Returns void

  • Get all task details with optional matching status.

    Parameters

    Returns Task<any>[]

  • Get the current concurrency of the queue

    Returns number

  • Get the task details with task ID.

    Parameters

    • taskId: TaskId

      The ID of the task

    Returns Task<any>

  • Check if the queue is manually stopped.

    Returns boolean

  • Remove the task from failed retryable task queue.

    Parameters

    • taskIdOrTask: TaskId | Task<any>

      The ID of the task or task object

    Returns void

  • Remove the task from waited task queue.

    Parameters

    • taskIdOrTask: TaskId | Task<any>

      The ID of the task or task object

    Returns void

  • Retry running the queue with failed tasks. Please note, this method will be effective only when marking "stopOnError" as "true" for the queue.

    Returns void

  • Start the queue execution.

    Returns void

  • Stop the queue execution. Please note, the current ongoing task will not be stopped immediately.

    Returns void

  • Subscribe to the task status changes.

    Parameters

    • onTaskStatusUpdate: TaskStatusUpdateHandler<any>

      The listener for task status updates

    Returns (() => void)

      • (): void
      • Returns void

  • Unsubscribe from the task status changes.

    Parameters

    • onTaskStatusUpdate: TaskStatusUpdateHandler<any>

      The listener for task status updates

    Returns void

Generated using TypeDoc