X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FClusterWorker.html;h=b7b63d870a37dfa01dce7a2da3988d30bc365f69;hb=d49303bcd1dc86f36030dff08796f869681d4eae;hp=ea6c5d88bab97a92d61cfe79e314f0c19a235b0f;hpb=d0f1dce33156fdb99f0ca3627839001909419497;p=poolifier.git diff --git a/docs/classes/ClusterWorker.html b/docs/classes/ClusterWorker.html index ea6c5d88..b7b63d87 100644 --- a/docs/classes/ClusterWorker.html +++ b/docs/classes/ClusterWorker.html @@ -1,83 +1,561 @@ -ClusterWorker | poolifier
Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ClusterWorker<Data, Response>

-

A cluster worker used by a poolifier ClusterPool.

-

When this worker is inactive for more than the given maxInactiveTime, +ClusterWorker | poolifier

+
+ +
+
+
+
+ +

Class ClusterWorker<Data, Response>

+
+

A cluster worker used by a poolifier ClusterPool.

+

When this worker is inactive for more than the given maxInactiveTime, it will send a termination request to its main worker.

If you use a DynamicClusterPool the extra workers that were created will be terminated, but the minimum number of workers will be guaranteed.

-
template DataType

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

-
template ResponseType

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

-
author

Christopher Quadflieg

-
since

2.0.0

-

Type parameters

  • Data = unknown

  • Response = unknown

Hierarchy

Index

Constructors

constructor

  • -

    Constructs a new poolifier cluster worker.

    -

    Type parameters

    • Data = unknown

    • Response = unknown

    Parameters

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

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

      -
        • (data: Data): Response
        • Parameters

          • data: Data

          Returns Response

    • opts: WorkerOptions = {}
      -

      Options for the worker.

      -

    Returns ClusterWorker<Data, Response>

Properties

Protected Optional Readonly aliveInterval

aliveInterval?: Timeout
-

Handler Id of the aliveInterval worker alive check.

-

Protected lastTaskTimestamp

lastTaskTimestamp: number
-

Timestamp of the last task processed by this worker.

-

Protected mainWorker

mainWorker: undefined | null | Worker

Readonly opts

opts: WorkerOptions = ...

Methods

asyncId

  • asyncId(): number
  • Returns number

    The unique asyncId assigned to the resource.

    -

bind

  • bind<Func>(fn: Func): Func & { asyncResource: AsyncResource }
  • -

    Binds the given function to execute to this AsyncResource's scope.

    -

    The returned function will have an asyncResource property referencing + +

    Author

    Christopher Quadflieg

    + +

    Since

    2.0.0

    +
+
+

Type Parameters

+
    +
  • +

    Data = unknown

    +

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

    +
  • +
  • +

    Response = unknown

    +

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

    +
+
+

Hierarchy

+
+
+
+
+ +
+
+

Constructors

+
+ +
    + +
  • +

    Constructs a new poolifier cluster worker.

    +
    +
    +

    Type Parameters

    +
      +
    • +

      Data = unknown

    • +
    • +

      Response = unknown

    +
    +

    Parameters

    +
      +
    • +
      fn: ((data: Data) => Response)
      +

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

      +
      +
        +
      • +
          +
        • (data: Data): Response
        • +
        • +
          +

          Parameters

          +
            +
          • +
            data: Data
          +

          Returns Response

    • +
    • +
      opts: WorkerOptions = {}
      +

      Options for the worker.

      +
    +

    Returns ClusterWorker<Data, Response>

+
+

Properties

+
+ +
aliveInterval?: Timeout
+

Handler id of the aliveInterval worker alive check.

+
+
+ +
isMain: boolean
+

Whether this is the main worker or not.

+
+
+ +
lastTaskTimestamp: number
+

Timestamp of the last task processed by this worker.

+
+
+ +
mainWorker: undefined | null | Worker
+

Reference to main worker.

+
+
+ +
opts: WorkerOptions = ...
+

Options for the worker.

+
+
+

Methods

+
+ +
    + +
  • +
    +

    Returns

    The unique asyncId assigned to the resource.

    +
    +

    Returns number

+
+ +
    + +
  • +

    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

Parameters

Returns Func & { asyncResource: AsyncResource }

Protected checkAlive

  • checkAlive(): void

emitDestroy

  • -

    Call all destroy hooks. This should only ever be called once. An error will + +

    Since

    v14.8.0, v12.19.0

    +
    +
    +

    Type Parameters

    +
      +
    • +

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

    +
    +

    Parameters

    +
      +
    • +
      fn: Func
      +

      The function to bind to the current AsyncResource.

      +
    +

    Returns Func & {
        asyncResource: AsyncResource;
    }

+
+ +
+
+ +
    + +
  • +

    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 ClusterWorker<Data, Response>

A reference to asyncResource.

-

Protected getMainWorker

Protected handleError

Protected run

Protected runAsync

runInAsyncScope

+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +

Type parameters

Parameters

Returns Result

Protected sendToMainWorker

triggerAsyncId

Static bind

+
+ +
+
+ +
+
+ +

Generated using TypeDoc

\ No newline at end of file + +

Since

v14.8.0, v12.19.0

+ +
+

Type Parameters

+
+
+

Parameters

+
+

Returns Func & {
    asyncResource: AsyncResource;
}

+
+ +
+
+

Generated using TypeDoc

+
\ No newline at end of file