Options
All
  • Public
  • Public/Protected
  • All
Menu

batch-cluster

Index

Type aliases

Log

Log: function

Type declaration

    • (message: string, ...optionalParams: any[]): void
    • Parameters

      • message: string
      • Rest ...optionalParams: any[]

      Returns void

Parser

Parser: function

Parser implementations convert stdout from the underlying child process to a more useable format. This can be a no-op passthrough if no parsing is necessary.

Type declaration

    • (data: string): T
    • Parameters

      • data: string

      Returns T

Variables

Const ConsoleLogger

ConsoleLogger: Logger = Object.freeze({/*** No-ops by default, as this is very low-level information.*/trace: noop,/*** Delegates to `util.debuglog("batch-cluster")`:* <https://nodejs.org/api/util.html#util_util_debuglog_section>*/debug: _debuglog,/*** Delegates to `util.debuglog("batch-cluster")`:* <https://nodejs.org/api/util.html#util_util_debuglog_section>*/info: _debuglog,/*** Delegates to `console.warn`*/warn: console.warn,/*** Delegates to `console.error`*/error: console.error})

Default Logger implementation. debug and info go to util.debuglog("batch-cluster").warnanderrorgo toconsole.warnandconsole.error`.

Const LogLevels

LogLevels: ("trace" | "debug" | "info" | "warn" | "error")[] = ["trace","debug","info","warn","error"]

Const NoLogger

NoLogger: Logger = Object.freeze({trace: noop,debug: noop,info: noop,warn: noop,error: noop})

Logger that disables all logging.

Functions

delay

  • delay(millis: number, unref?: boolean): Promise<void>
  • Parameters

    • millis: number
    • Default value unref: boolean = false

    Returns Promise<void>

filterInPlace

  • filterInPlace<T>(arr: T[], filter: function): T[]
  • Remove all elements from the given array that return false from the given predicate filter.

    Type parameters

    • T

    Parameters

    • arr: T[]
    • filter: function
        • (t: T): boolean
        • Parameters

          • t: T

          Returns boolean

    Returns T[]

kill

  • kill(pid: number, force?: boolean): void
  • Send a signal to the given process id.

    export

    Parameters

    • pid: number

      the process id. Required.

    • Default value force: boolean = false

    Returns void

logger

map

  • map<T, R>(obj: T | undefined | null, f: function): R | undefined
  • Only call and return the result of f if obj is defined (not null nor undefined)

    Type parameters

    • T

    • R

    Parameters

    • obj: T | undefined | null
    • f: function
        • (t: T): R
        • Parameters

          • t: T

          Returns R

    Returns R | undefined

pidExists

  • pidExists(pid: number): Promise<boolean>
  • export

    Parameters

    • pid: number

      process id. Required.

    Returns Promise<boolean>

    true if the given process id is in the local process table. The PID may be paused or a zombie, though.

pids

  • pids(): Promise<number[]>
  • export

    Returns Promise<number[]>

    all the Process IDs in the process table.

ratelimit

  • ratelimit<T>(f: function, minDelayMs: number): (Anonymous function)
  • Return a thunk that will call the underlying thunk at most every minDelayMs milliseconds. The thunk will accept a boolean, that, when set, will force the underlying thunk to be called (mostly useful for tests)

    Type parameters

    • T

    Parameters

    • f: function
        • (): T
        • Returns T

    • minDelayMs: number

    Returns (Anonymous function)

serial

  • serial<T>(f: function): function
  • Return a function that will, at most, run the given function once at a time. Calls that occur during prior calls will no-op.

    Type parameters

    • T

    Parameters

    • f: function
        • (): Promise<T>
        • Returns Promise<T>

    Returns function

      • (): Promise<T | undefined>
      • Returns Promise<T | undefined>

setLogger

until

  • until(f: function, timeoutMs: number): Promise<boolean>
  • Run the given thunk until the promise is resolved to true, or the timeout passes.

    Parameters

    • f: function
        • (): boolean | Promise<boolean>
        • Returns boolean | Promise<boolean>

    • timeoutMs: number

    Returns Promise<boolean>

Generated using TypeDoc