Class BatchCluster

BatchCluster instances manage 0 or more homogeneous child processes, and provide the main interface for enqueuing Tasks via enqueueTask.

Given the large number of configuration options, the constructor receives a single options hash. The most important of these are the ChildProcessFactory, which specifies the factory that creates ChildProcess instances, and BatchProcessOptions, which specifies how child tasks can be verified and shut down.

Hierarchy

  • BatchCluster

Constructors

Properties

emitter: BatchClusterEmitter = ...
off: (<E>(eventName: E, listener: ((...args: Args<BatchClusterEvents[E]>) => void)) => BatchClusterEmitter) = ...

Type declaration

on: (<E>(eventName: E, listener: ((...args: Args<BatchClusterEvents[E]>) => void)) => BatchClusterEmitter) = ...

Type declaration

options: AllOpts

Accessors

  • get busyProcCount(): number
  • Returns

    the current number of child processes currently servicing tasks

    Returns number

  • get childEndCounts(): { broken: number; closed: number; ended: number; ending: number; idle: number; old: number; proc.close: number; proc.disconnect: number; proc.error: number; proc.exit: number; startError: number; stderr: number; stderr.error: number; stdin.error: number; stdout.error: number; timeout: number; tooMany: number; unhealthy: number; worn: number }
  • Returns { broken: number; closed: number; ended: number; ending: number; idle: number; old: number; proc.close: number; proc.disconnect: number; proc.error: number; proc.exit: number; startError: number; stderr: number; stderr.error: number; stdin.error: number; stdout.error: number; timeout: number; tooMany: number; unhealthy: number; worn: number }

    • broken: number
    • closed: number
    • ended: number
    • ending: number
    • idle: number
    • old: number
    • proc.close: number
    • proc.disconnect: number
    • proc.error: number
    • proc.exit: number
    • startError: number
    • stderr: number
    • stderr.error: number
    • stdin.error: number
    • stdout.error: number
    • timeout: number
    • tooMany: number
    • unhealthy: number
    • worn: number
  • get currentTasks(): Task<any>[]
  • Returns

    the current running Tasks (mostly for testing)

    Returns Task<any>[]

  • get internalErrorCount(): number
  • For integration tests:

    Returns number

  • get isIdle(): boolean
  • Returns

    true if all previously-enqueued tasks have settled

    Returns boolean

  • get meanTasksPerProc(): number
  • Returns

    the mean number of tasks completed by child processes

    Returns number

  • get pendingTaskCount(): number
  • Returns

    the number of pending tasks

    Returns number

  • get pendingTasks(): Task<any>[]
  • Returns

    the current pending Tasks (mostly for testing)

    Returns Task<any>[]

  • get procCount(): number
  • Returns

    the current number of spawned child processes. Some (or all) may be idle.

    Returns number

  • get spawnedProcCount(): number
  • Returns

    the total number of child processes created by this instance

    Returns number

Methods

  • Shut down any currently-running child processes. New child processes will be started automatically to handle new tasks.

    Parameters

    • gracefully: boolean = true

    Returns Promise<void>

  • Shut down this instance, and all child processes.

    Parameters

    • gracefully: boolean = true

      should an attempt be made to finish in-flight tasks, or should we force-kill child PIDs.

    Returns Deferred<void>

  • Submits task for processing by a BatchProcess instance

    Returns

    a Promise that is resolved or rejected once the task has been attempted on an idle BatchProcess

    Type Parameters

    • T

    Parameters

    Returns Promise<T>

  • Verify that each BatchProcess PID is actually alive.

    Returns

    the spawned PIDs that are still in the process table.

    Returns Promise<number[]>

  • Reset the maximum number of active child processes to maxProcs. Note that this is handled gracefully: child processes are only reduced as tasks are completed.

    Parameters

    • maxProcs: number

    Returns void

  • For diagnostics. Contents may change.

    Returns { childEndCounts: { broken: number; closed: number; ended: number; ending: number; idle: number; old: number; proc.close: number; proc.disconnect: number; proc.error: number; proc.exit: number; startError: number; stderr: number; stderr.error: number; stdin.error: number; stdout.error: number; timeout: number; tooMany: number; unhealthy: number; worn: number }; currentProcCount: number; ended: boolean; ending: boolean; internalErrorCount: number; maxProcCount: number; msBeforeNextSpawn: number; pendingTaskCount: number; readyProcCount: number; spawnedProcCount: number; startErrorRatePerMinute: number }

    • childEndCounts: { broken: number; closed: number; ended: number; ending: number; idle: number; old: number; proc.close: number; proc.disconnect: number; proc.error: number; proc.exit: number; startError: number; stderr: number; stderr.error: number; stdin.error: number; stdout.error: number; timeout: number; tooMany: number; unhealthy: number; worn: number }
      • broken: number
      • closed: number
      • ended: number
      • ending: number
      • idle: number
      • old: number
      • proc.close: number
      • proc.disconnect: number
      • proc.error: number
      • proc.exit: number
      • startError: number
      • stderr: number
      • stderr.error: number
      • stdin.error: number
      • stdout.error: number
      • timeout: number
      • tooMany: number
      • unhealthy: number
      • worn: number
    • currentProcCount: number
    • ended: boolean
    • ending: boolean
    • internalErrorCount: number
    • maxProcCount: number
    • msBeforeNextSpawn: number
    • pendingTaskCount: number
    • readyProcCount: number
    • spawnedProcCount: number
    • startErrorRatePerMinute: number
  • Run maintenance on currently spawned child processes. This method is normally invoked automatically as tasks are enqueued and processed.

    Only public for tests.

    Returns Promise<void[]>

Generated using TypeDoc