X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FClusterWorker.html;h=b28355977ded6eeb9de3c98eb45246d7a74eb4e0;hb=70353024c44987c467dadcec306c699ce4ae1f06;hp=4476d945541582990753b0308c10eb69adf28196;hpb=a1e5b51ea192bdcad4751d1f4facc19498ee4f1d;p=poolifier.git diff --git a/docs/classes/ClusterWorker.html b/docs/classes/ClusterWorker.html index 4476d945..b2835597 100644 --- a/docs/classes/ClusterWorker.html +++ b/docs/classes/ClusterWorker.html @@ -1,4 +1,4 @@ -ClusterWorker | poolifier
+ClusterWorker | poolifier
-
+

Type Parameters

-
    +
    • -

      Data = unknown

      +

      Data = unknown

      Type of data this worker receives from pool's execution. This can only be serializable data.

    • -

      Response = unknown

      +

      Response = unknown

      Type of response the worker sends back to the main worker. This can only be serializable data.

Hierarchy

+
  • Defined in src/worker/cluster-worker.ts:25
  • @@ -52,221 +52,213 @@ but the minimum number of workers will be guaranteed.

    Constructors

    -
    +
    -
      - +
        +
      • Constructs a new poolifier cluster worker.

        -
        +

        Type Parameters

        -
          +
          • -

            Data = unknown

          • +

            Data = unknown

          • -

            Response = unknown

        +

        Response = unknown

    Parameters

    • -
      fn: ((data: Data) => Response | Promise<Response>)
      -

      Function processed by the worker when the pool's execution function is invoked.

      -
      -
        -
      • -
          -
        • (data: Data): Response | Promise<Response>
        • -
        • -
          -

          Parameters

          -
            -
          • -
            data: Data
          -

          Returns Response | Promise<Response>

    • +
      taskFunctions: WorkerFunction<Data, Response> | TaskFunctions<Data, Response>
      +

      Task function(s) processed by the worker when the pool's execution function is invoked.

      +
    • -
      opts: WorkerOptions = {}
      +
      opts: WorkerOptions = {}

      Options for the worker.

    -

    Returns ClusterWorker<Data, Response>

    +
  • Defined in src/worker/cluster-worker.ts:35
  • Properties

    -
    +
    -
    aliveInterval?: Timeout
    +
    aliveInterval?: Timeout

    Handler id of the aliveInterval worker alive check.

    -
    +
  • Defined in src/worker/abstract-worker.ts:42
  • +
    -
    isMain: boolean
    +
    isMain: boolean

    Whether this is the main worker or not.

    -
    +
  • Defined in src/worker/abstract-worker.ts:54
  • +
    -
    lastTaskTimestamp: number
    +
    lastTaskTimestamp: number

    Timestamp of the last task processed by this worker.

    -
    +
  • Defined in src/worker/abstract-worker.ts:38
  • +
    -
    mainWorker: undefined | null | Worker
    +
    mainWorker: undefined | null | Worker

    Reference to main worker.

    -
    +
  • Defined in src/worker/abstract-worker.ts:58
  • +
    -
    opts: WorkerOptions = ...
    +
    opts: WorkerOptions = ...

    Options for the worker.

    +
  • Defined in src/worker/abstract-worker.ts:59
  • +
    + +
    taskFunctions: Map<string, WorkerFunction<Data, Response>>
    +

    Task function(s) processed by the worker when the pool's execution function is invoked.

    +

    Methods

    -
    +
    -
      - +
        +
      • -
        -

        Returns

        The unique asyncId assigned to the resource.

        -
        -

        Returns number

    -
    +
  • Defined in node_modules/.pnpm/@types+node@20.2.5/node_modules/@types/node/async_hooks.d.ts:306
  • +
    -
      - +
        +
      • Binds the given function to execute to this AsyncResource's scope.

        -

        The returned function will have an asyncResource property referencing -the AsyncResource to which the function is bound.

        Since

        v14.8.0, v12.19.0

        -
        +

        Type Parameters

        -
          +
          • -

            Func extends ((...args: any[]) => any)

        +

        Func extends ((...args) => any)

    Parameters

    • -
      fn: Func
      +
      fn: Func

      The function to bind to the current AsyncResource.

    -

    Returns Func & {
        asyncResource: AsyncResource;
    }

    -
    +
  • Defined in node_modules/.pnpm/@types+node@20.2.5/node_modules/@types/node/async_hooks.d.ts:283
  • +
    -
    -
    +
  • Defined in src/worker/abstract-worker.ts:179
  • +
    -
      - +
        +
      • Call all destroy hooks. This should only ever be called once. An error will be thrown if it is called more than once. This must be manually called. If the resource is left to be collected by the GC then the destroy hooks will never be called.

        - -

        Returns

        A reference to asyncResource.

        -

        Returns ClusterWorker<Data, Response>

    -
    +
  • Defined in node_modules/.pnpm/@types+node@20.2.5/node_modules/@types/node/async_hooks.d.ts:302
  • +
    -
    -
    +
  • Defined in src/worker/abstract-worker.ts:162
  • +
    -
      - +
        +
      • Handles an error and convert it to a string so it can be sent back to the main worker.

        - -

        Returns

        Message of the error.

        Parameters

        • -
          e: string | Error
          +
          e: string | Error

          The error raised by the worker.

        -

        Returns string

    -
    +
  • Defined in src/worker/cluster-worker.ts:56
  • +
    -
      - +
        +
      • Worker message listener.

        @@ -274,65 +266,17 @@ never be called.

        Parameters

        • -
          message: MessageValue<Data, Worker>
          +
          message: MessageValue<Data, Worker>

          Message received.

          -
        • -
        • -
          fn: ((data: Data) => Response | Promise<Response>)
          -

          Function processed by the worker when the pool's execution function is invoked.

          -
          -
            -
          • -
              -
            • (data: Data): Response | Promise<Response>
            • -
            • -
              -

              Parameters

              -
                -
              • -
                data: Data
              -

              Returns Response | Promise<Response>

    -

    Returns void

    -
    - -
      - -
    • -

      Runs the given function synchronously.

      -
      -
      -

      Parameters

      -
        -
      • -
        fn: ((data?: Data) => Response)
        -

        Function that will be executed.

        -
        -
          -
        • -
            -
          • (data?: Data): Response
          • -
          • -
            -

            Parameters

            -
              -
            • -
              Optional data: Data
            -

            Returns Response

      • -
      • -
        message: MessageValue<Data, unknown>
        -

        Input data for the given function.

      Returns void

    -
    +
  • Defined in src/worker/abstract-worker.ts:138
  • +
    -
      - +
        +
      • Runs the given function asynchronously.

        @@ -340,32 +284,21 @@ never be called.

        Parameters

        • -
          fn: ((data?: Data) => Promise<Response>)
          +
          fn: WorkerAsyncFunction<Data, Response>

          Function that will be executed.

          -
          -
            -
          • -
              -
            • (data?: Data): Promise<Response>
            • -
            • -
              -

              Parameters

              -
                -
              • -
                Optional data: Data
              -

              Returns Promise<Response>

        • +
        • -
          message: MessageValue<Data, unknown>
          +
          message: MessageValue<Data, Worker | MessagePort>

          Input data for the given function.

        Returns void

    -
    +
  • Defined in src/worker/abstract-worker.ts:233
  • +
    -
      - +
        +
      • Call the provided function with the provided arguments in the execution context of the async resource. This will establish the context, trigger the AsyncHooks @@ -374,49 +307,71 @@ then restore the original execution context.

        Since

        v9.6.0

        -
        +

        Type Parameters

        -
          +
          • -

            This

          • +

            This

          • -

            Result

        +

        Result

    Parameters

    • -
      fn: ((this: This, ...args: any[]) => Result)
      +
      fn: ((this, ...args) => Result)

      The function to call in the execution context of this async resource.

      • -
          -
        • (this: This, ...args: any[]): Result
        • +
            +
          • (this, ...args): Result
          • Parameters

            • -
              this: This
            • +
              this: This
            • -
              Rest ...args: any[]
            -

            Returns Result

      • +
        Rest ...args: any[]
    +

    Returns Result

  • -
    Optional thisArg: This
    +
    Optional thisArg: This

    The receiver to be used for the function call.

  • -
    Rest ...args: any[]
    +
    Rest ...args: any[]

    Optional arguments to pass to the function.

  • -

    Returns Result

    +
    + +
    +
    -
    -
    +
  • Defined in src/worker/cluster-worker.ts:51
  • +
    -
      - +
        +
      • -
        -

        Returns

        The same triggerAsyncId that is passed to the AsyncResource constructor.

        -
        -

        Returns number

    -
    +
  • Defined in node_modules/.pnpm/@types+node@20.2.5/node_modules/@types/node/async_hooks.d.ts:311
  • +
    -
      - +
        +
      • Binds the given function to the current execution context.

        -

        The returned function will have an asyncResource property referencing -the AsyncResource to which the function is bound.

        Since

        v14.8.0, v12.19.0

        -
        +

        Type Parameters

        -
          +
          • -

            Func extends ((this: ThisArg, ...args: any[]) => any)

          • +

            Func extends ((this, ...args) => any)

          • -

            ThisArg

        +

        ThisArg

    Parameters

    • -
      fn: Func
      +
      fn: Func

      The function to bind to the current execution context.

    • -
      Optional type: string
      +
      Optional type: string

      An optional name to associate with the underlying AsyncResource.

    • -
      Optional thisArg: ThisArg
    -

    Returns Func & {
        asyncResource: AsyncResource;
    }

    +

    Theme

    On This Page

    +
  • constructor
  • +
  • aliveInterval
  • +
  • isMain
  • +
  • lastTaskTimestamp
  • +
  • mainWorker
  • +
  • opts
  • +
  • taskFunctions
  • +
  • asyncId
  • +
  • bind
  • +
  • checkAlive
  • +
  • emitDestroy
  • +
  • getMainWorker
  • +
  • handleError
  • +
  • messageListener
  • +
  • runAsync
  • +
  • runInAsyncScope
  • +
  • runSync
  • +
  • sendToMainWorker
  • +
  • triggerAsyncId
  • +
  • bind
  • +
  • PoolType
  • +
  • AbstractPool
  • +
  • AbstractWorker
  • +
  • CircularArray
  • +
  • ClusterWorker
  • +
  • DynamicClusterPool
  • +
  • DynamicThreadPool
  • +
  • FixedClusterPool
  • +
  • FixedThreadPool
  • +
  • PoolEmitter
  • +
  • Queue
  • +
  • ThreadWorker
  • +
  • WorkerChoiceStrategyContext
  • +
  • ClusterPoolOptions
  • +
  • IPool
  • +
  • IWorker
  • +
  • IWorkerChoiceStrategy
  • +
  • MessageValue
  • +
  • PoolOptions
  • +
  • PromiseResponseWrapper
  • +
  • RequiredStatistics
  • +
  • Task
  • +
  • TasksQueueOptions
  • +
  • TasksUsage
  • +
  • WorkerChoiceStrategyOptions
  • +
  • WorkerNode
  • +
  • WorkerOptions
  • +
  • Draft
  • +
  • ErrorHandler
  • +
  • ExitHandler
  • +
  • KillBehavior
  • +
  • MessageHandler
  • +
  • OnlineHandler
  • +
  • PoolEvent
  • +
  • TaskFunctions
  • +
  • ThreadWorkerWithMessageChannel
  • +
  • WorkerAsyncFunction
  • +
  • WorkerChoiceStrategy
  • +
  • WorkerFunction
  • +
  • WorkerSyncFunction
  • +
  • KillBehaviors
  • +
  • PoolEvents
  • +
  • WorkerChoiceStrategies
  • Generated using TypeDoc

    \ No newline at end of file