X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FClusterWorker.html;h=8dea95ee7683cb407a4b51654609ed78464f414a;hb=15e4d8f3cafe9f7412913b0e440921e813bdf3cd;hp=7fc568909f11c18eef88d72542a2d065b428b057;hpb=71a64eca52278c2396cf7cb6e6c53fce3704f5ab;p=poolifier.git diff --git a/docs/classes/ClusterWorker.html b/docs/classes/ClusterWorker.html index 7fc56890..8dea95ee 100644 --- a/docs/classes/ClusterWorker.html +++ b/docs/classes/ClusterWorker.html @@ -1,4 +1,4 @@ -ClusterWorker | poolifier
+ClusterWorker | poolifier
-
+
  • poolifier
  • @@ -30,21 +30,21 @@ but the minimum number of workers will be guaranteed.

    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

      -
    • AbstractWorker<Worker, Data, Response> +
    • AbstractWorker<Worker, Data, Response>
      • ClusterWorker
    +
  • Defined in src/worker/cluster-worker.ts:21
@@ -52,38 +52,38 @@ but the minimum number of workers will be guaranteed.

Constructors

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

      @@ -91,95 +91,84 @@ but the minimum number of workers will be guaranteed.

      Type Parameters

      • -

        Data = unknown

      • +

        Data = unknown

      • -

        Response = unknown

+

Response = unknown

Parameters

  • -
    fn: ((data: Data) => Response)
    +
    fn: WorkerFunction<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 = {}
    +
    opts: WorkerOptions = {}

    Options for the worker.

  • -

    Returns ClusterWorker<Data, Response>

    Properties

    -
    +
    -
    aliveInterval?: Timeout
    -

    Handler Id of the aliveInterval worker alive check.

    +
    aliveInterval?: Timeout
    +

    Handler id of the aliveInterval worker alive check.

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

    Whether this is the main worker or not.

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

    Timestamp of the last task processed by this worker.

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

    Reference to main worker.

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

    Options for the worker.

    +
  • Defined in src/worker/abstract-worker.ts:51
  • 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 @@ -191,33 +180,33 @@ the AsyncResource to which the function is bound.

        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 src/worker/abstract-worker.ts:156
  • +
    -
      - +
        +
      • 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 @@ -226,70 +215,69 @@ never be called.

        Returns

        A reference to asyncResource.

        -

        Returns ClusterWorker<Data, Response>

    -
    +
    -
    -
    +
  • Defined in src/worker/abstract-worker.ts:139
  • +
    -
      - +
        +
      • -
        -

        Inherit Doc

        +

        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:50
  • +
    -
      - +
        +
      • +

        Worker message listener.

        +

        Parameters

        • -
          value: MessageValue<Data, Worker>
        • -
        • -
          fn: ((data: Data) => Response)
          -
            -
          • -
              -
            • (data: Data): Response
            • -
            • -
              -

              Parameters

              -
                +
                message: MessageValue<Data, Worker>
                +

                Message received.

                +
              • -
                data: Data
              -

              Returns Response

        +
        fn: WorkerFunction<Data, Response>
        +

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

        +

    Returns void

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

        @@ -297,32 +285,21 @@ never be called.

        Parameters

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

          Function that will be executed.

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

              Parameters

              -
                -
              • -
                Optional data: Data
              -

              Returns Response

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

    Input data for the given function.

  • Returns void

    -
    +
  • Defined in src/worker/abstract-worker.ts:181
  • +
    -
    -
    +
  • Defined in src/worker/abstract-worker.ts:208
  • +
    -
    +

    Result

    Parameters

    +

    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

    +
    -
    -
    +
    -
      - +
        +
      • Binds the given function to the current execution context.

        The returned function will have an asyncResource property referencing @@ -446,30 +414,31 @@ the AsyncResource to which the function is bound.

        Type Parameters

        • -

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

        • +

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

        • -

          ThisArg

    +

    ThisArg

    Parameters

    -

    Returns Func & {
        asyncResource: AsyncResource;
    }