Options
All
  • Public
  • Public/Protected
  • All
Menu

A Junknet client implementation using a provided connection factory. It distributes the given jobs among daemons it knows about.

Hierarchy

  • EventEmitter
    • GenericClient

Implements

Index

Constructors

constructor

  • Create a client whose responsibility is to finish jobs. It won't start until it knows about some daemons.

    Parameters

    • connect: ConnectionFactory

      A connection factory compatible with the daemons you will use.

    • streams: ProcessStreams

      A common source and sink used by all remote jobs.

    • orderer: JobOrderer

      A job orderer that tracks the jobs to be completed.

    Returns GenericClient

Properties

Readonly Private #connect

Readonly Private #jobs

Readonly Private #streams

#streams: ProcessStreams

Readonly Static captureRejectionSymbol

captureRejectionSymbol: typeof captureRejectionSymbol

Static captureRejections

captureRejections: boolean

Sets or gets the default captureRejection value for all emitters.

Static defaultMaxListeners

defaultMaxListeners: number

Readonly Static errorMonitor

errorMonitor: typeof errorMonitor

This symbol shall be used to install a listener for only monitoring 'error' events. Listeners installed using this symbol are called before the regular 'error' listeners are called.

Installing a listener using this symbol does not change the behavior once an 'error' event is emitted, therefore the process will still crash if no regular 'error' listener is installed.

Methods

addListener

  • addListener(event: string | symbol, listener: (...args: any[]) => void): GenericClient
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns GenericClient

Private assignJobToDaemon

  • Asks the daemon to work on the job. Sends network request and handles response.

    Parameters

    • job: Job

      The job to assign.

    • daemon: Connection

      The daemon to which to assign the job.

    Returns Promise<void>

Private daemonThread

  • An agent that claims jobs and runs them using the given daemon. It closes the connection and cleans up resources before resolving.

    Parameters

    • daemon: Connection

      The daemon that is available.

    Returns Promise<void>

    Asynchronously, when there are no more remaining jobs.

emit

  • emit(event: string | symbol, ...args: any[]): boolean
  • Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

eventNames

  • eventNames(): (string | symbol)[]
  • Returns (string | symbol)[]

Private finish

  • finish(success: boolean): void
  • Notify the caller of completion. It's safe to call this multiple times.

    Parameters

    • success: boolean

      Whether the overall operation succeeded.

    Returns void

getMaxListeners

  • getMaxListeners(): number
  • Returns number

introduce

  • introduce(host: string, port: number): void
  • Add a new daemon to the swarm. The client may now give jobs to this daemon.

    override

    Parameters

    • host: string

      hostname or IP address of daemon

    • port: number

      port number of daemon on the host

    Returns void

listenerCount

  • listenerCount(event: string | symbol): number
  • Parameters

    • event: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

off

  • off(event: string | symbol, listener: (...args: any[]) => void): GenericClient
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns GenericClient

on

  • on(event: string | symbol, listener: (...args: any[]) => void): GenericClient
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns GenericClient

once

  • once(event: string | symbol, listener: (...args: any[]) => void): GenericClient
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns GenericClient

prependListener

  • prependListener(event: string | symbol, listener: (...args: any[]) => void): GenericClient
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns GenericClient

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: (...args: any[]) => void): GenericClient
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns GenericClient

quit

  • quit(): void
  • Notify all threads to exit and clean up resources. The overall operation is considered to have failed.

    Returns void

rawListeners

  • rawListeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

removeAllListeners

  • Parameters

    • Optional event: string | symbol

    Returns GenericClient

removeListener

  • removeListener(event: string | symbol, listener: (...args: any[]) => void): GenericClient
  • Parameters

    • event: string | symbol
    • listener: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns GenericClient

setMaxListeners

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • deprecated

    since v4.0.0

    Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number

Static on

  • on(emitter: EventEmitter, event: string): AsyncIterableIterator<any>
  • Parameters

    • emitter: EventEmitter
    • event: string

    Returns AsyncIterableIterator<any>

Static once

  • once(emitter: NodeEventTarget, event: string | symbol): Promise<any[]>
  • once(emitter: DOMEventTarget, event: string): Promise<any[]>
  • Parameters

    • emitter: NodeEventTarget
    • event: string | symbol

    Returns Promise<any[]>

  • Parameters

    • emitter: DOMEventTarget
    • event: string

    Returns Promise<any[]>

Generated using TypeDoc