X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FClusterWorker.html;h=bfe02d95cda7dfd3bc9133083ecb396a02a286cf;hb=4e1212db1d198963828820471bde6902277d0388;hp=6aa60182b1f58d24081995d6f2a4571a4709a246;hpb=8d20e449d72975f6add9177d1097d5a204d14f71;p=poolifier.git diff --git a/docs/classes/ClusterWorker.html b/docs/classes/ClusterWorker.html index 6aa60182..bfe02d95 100644 --- a/docs/classes/ClusterWorker.html +++ b/docs/classes/ClusterWorker.html @@ -1,13 +1,13 @@ -
Type of data this worker receives from pool's execution. This can only be serializable data.
+Type of data this worker receives from pool's execution. This can only be structured-cloneable data.
Response = unknown
-Type of response the worker sends back to the main worker. This can only be serializable data.
+Type of response the worker sends back to the main worker. This can only be structured-cloneable data.
-
+Index
Index
Constructors
-Properties
-Accessors
+Methods
-Constructors
constructor
+constructor
Parameters
taskFunctions: WorkerFunction<Data, Response> | TaskFunctions<Data, Response>
+taskFunctions: TaskFunction<Data, Response> | TaskFunctions<Data, Response>
Task function(s) processed by the worker when the pool's
execution
function is invoked.Properties
- Interval
-Protected
Optional
Readonly
aliveHandler id of the
+aliveInterval
worker alive check. Interval
+Protected
Optional
activeHandler id of the
activeInterval
worker activity check.Protected
Readonly
isProtected
last Worker
-Protected
mainReference to main worker.
-
-Protected
Readonly
opts
+Protected
optsOptions for the worker.
+Protected
statisticsPerformance statistics computation requirements.
+ Functions
-Protected
taskTask function(s) processed by the worker when the pool's
execution
function is invoked.Accessors
+
+Protected
id+- get id(): number
+-
+
+
Worker id.
+Returns number
+Methods
+add Task Function
++- add
Task Function(name, fn): boolean
+-
+
+
+
+
+
Adds a task function to the worker. +If a task function with the same name already exists, it is replaced.
+Parameters
++-
+
+
+-
+
+
name: string
+The name of the task function to add.
+fn: TaskFunction<Data, Response>
+The task function to add.
+Returns boolean
Whether the task function was added or not.
+ +Throws
https://nodejs.org/api/errors.html#class-typeerror If the
+ +name
parameter is not a string or an empty string.Throws
https://nodejs.org/api/errors.html#class-error If the
+ +name
parameter is the default task function reserved name.Throws
https://nodejs.org/api/errors.html#class-typeerror If the
+fn
parameter is not a function.async Id
@@ -184,7 +243,7 @@ but the minimum number of workers will be guaranteed.
bind
@@ -211,19 +270,7 @@ but the minimum number of workers will be guaranteed.
Alive
-Protected
check-- check
Alive(): void
--
-
-
Checks if the worker should be terminated, because its living too long.
-Returns void
-emit Destroy
@@ -239,7 +286,7 @@ never be called.
Protected
get@@ -249,13 +296,15 @@ never be called.
Returns Worker
Reference to the main worker.
- Error
-Protected
handle+- handle
Error(e): string
-
-
+
Handles an error and convert it to a string so it can be sent back to the main worker.
@@ -268,12 +317,88 @@ never be called.The error raised by the worker.
Returns string
Message of the error.
+Returns string
The error message.
+ +Inherited from AbstractWorker.handleError
++- Defined in src/worker/abstract-worker.ts:466
Kill Message
+Protected
handle+- handle
Kill Message(message): void
+-
+
+
+
+
+
Handles a kill message sent by the main worker.
+Parameters
++-
+
+
message: MessageValue<Data, unknown>
+The kill message.
+Returns void
+Inherited from AbstractWorker.handleKillMessage
++- Defined in src/worker/abstract-worker.ts:351
Ready Message
+Protected
handle+- handle
Ready Message(message): void
+-
+
+
+
+
+
Handles the ready message sent by the main worker.
+Parameters
++-
+
+
message: MessageValue<Data, unknown>
+The ready message.
+Returns void
+Overrides AbstractWorker.handleReadyMessage
++- Defined in src/worker/cluster-worker.ts:45
has Task Function
++- has
Task Function(name): boolean
+-
+
+
+
+
+
+
Checks if the worker has a task function with the given name.
+Parameters
++-
+
+
name: string
+The name of the task function to check.
+Returns boolean
Whether the worker has a task function with the given name or not.
+ +Throws
https://nodejs.org/api/errors.html#class-typeerror If the
+name
parameter is not a string or an empty string.Inherited from AbstractWorker.hasTaskFunction
++- Defined in src/worker/abstract-worker.ts:177
list Task Functions
++- list
Task Functions(): string[]
+-
+
+
-
Lists the names of the worker's task functions.
+Returns string[]
The names of the worker's task functions.
Overrides AbstractWorker.handleError
+Inherited from AbstractWorker.listTaskFunctions
-- Defined in src/worker/cluster-worker.ts:55
Protected
message@@ -285,40 +410,89 @@ never be called.-
-
Parameters
message: MessageValue<Data, Worker>
-Message received.
+message: MessageValue<Data, unknown>
+The received message.
Returns void
Inherited from AbstractWorker.messageListener
-- Defined in src/worker/abstract-worker.ts:141
remove Task Function
++- remove
Task Function(name): boolean
+-
+
+
+
+
+
+
Removes a task function from the worker.
+Parameters
++-
+
+
name: string
+The name of the task function to remove.
+Returns boolean
Whether the task function existed and was removed or not.
+ +Throws
https://nodejs.org/api/errors.html#class-typeerror If the
+ +name
parameter is not a string or an empty string.Throws
https://nodejs.org/api/errors.html#class-error If the
+ +name
parameter is the default task function reserved name.Throws
https://nodejs.org/api/errors.html#class-error If the
+name
parameter is the task function used as default task function.Inherited from AbstractWorker.removeTaskFunction
++- Defined in src/worker/abstract-worker.ts:231
+Protected
run+- run(task): void
+-
+
+
+
+
+
+
Runs the given task.
+Parameters
++-
+
+
task: Task<Data>
+The task to execute.
+Returns void
+Throws
https://nodejs.org/api/errors.html#class-error If the task function is not found.
+Inherited from AbstractWorker.run
++- Defined in src/worker/abstract-worker.ts:476
Protected
run-- run
Async(fn, message): void
+- run
Async(fn, task): void
-
-
-
-
-
-
+- Defined in src/worker/abstract-worker.ts:541
+- Defined in node_modules/.pnpm/@types+node@20.5.9/node_modules/@types/node/async_hooks.d.ts:294
Sync
+
Runs the given function asynchronously.
+Runs the given task function asynchronously.
Parameters
fn: WorkerAsyncFunction<Data, Response>
-Function that will be executed.
+fn: TaskAsyncFunction<Data, Response>
+Task function that will be executed.
message: MessageValue<Data, Worker | MessagePort>
-Input data for the given function.
+task: Task<Data>
+Input data for the task function.
Returns void
Inherited from AbstractWorker.runAsync
-- Defined in src/worker/abstract-worker.ts:240
run In Async Scope
@@ -373,44 +547,56 @@ then restore the original execution context.
Inherited from AbstractWorker.runInAsyncScope
-- Defined in node_modules/.pnpm/@types+node@20.2.5/node_modules/@types/node/async_hooks.d.ts:294
Protected
run-- run
Sync(fn, message): void
+- run
Sync(fn, task): void
-
-
-
-
-
-
+- Defined in src/worker/abstract-worker.ts:504
+
+
To Main Worker
- send
To Main Worker(message): void
-
-
-
-
@@ -418,7 +604,34 @@ then restore the original execution context.
+- Defined in src/worker/cluster-worker.ts:70
+
+
+- Defined in node_modules/.pnpm/@types+node@20.5.9/node_modules/@types/node/async_hooks.d.ts:311
+ - Defined in node_modules/.pnpm/@types+node@20.5.9/node_modules/@types/node/async_hooks.d.ts:277
+
+
+
+
-
Runs the given function synchronously.
+Runs the given task function synchronously.
Parameters
fn: WorkerSyncFunction<Data, Response>
-Function that will be executed.
+fn: TaskSyncFunction<Data, Response>
+Task function that will be executed.
message: MessageValue<Data, Worker | MessagePort>
-Input data for the given function.
+task: Task<Data>
+Input data for the task function.
Returns void
Inherited from AbstractWorker.runSync
-- Defined in src/worker/abstract-worker.ts:207
Task Functions List To Main Worker
+Protected
send+- send
Task Functions List To Main Worker(): void
+-
+
+
+
Sends the list of task function names to the main worker.
+Returns void
+Inherited from AbstractWorker.sendTaskFunctionsListToMainWorker
++- Defined in src/worker/abstract-worker.ts:453
Protected
sendSends a message to the main worker.
+Sends a message to main worker.
Parameters
message: MessageValue<Response, Worker | MessagePort>
+message: MessageValue<Response, unknown>
The response message.
Overrides AbstractWorker.sendToMainWorker
-- Defined in src/worker/cluster-worker.ts:50
set Default Task Function
++- set
Default Task Function(name): boolean
+-
+
+
+
+
+
+
Sets the default task function to use in the worker.
+Parameters
++-
+
+
name: string
+The name of the task function to use as default task function.
+Returns boolean
Whether the default task function was set or not.
+ +Throws
https://nodejs.org/api/errors.html#class-typeerror If the
+ +name
parameter is not a string or an empty string.Throws
https://nodejs.org/api/errors.html#class-error If the
+ +name
parameter is the default task function reserved name.Throws
https://nodejs.org/api/errors.html#class-error If the
+name
parameter is a non-existing task function.Inherited from AbstractWorker.setDefaultTaskFunction
++- Defined in src/worker/abstract-worker.ts:285
trigger Async Id
@@ -429,7 +642,7 @@ then restore the original execution context.
Inherited from AbstractWorker.triggerAsyncId
-- Defined in node_modules/.pnpm/@types+node@20.2.5/node_modules/@types/node/async_hooks.d.ts:311
Static
bind@@ -465,20 +678,20 @@ then restore the original execution context.
Inherited from AbstractWorker.bind
-- Defined in node_modules/.pnpm/@types+node@20.2.5/node_modules/@types/node/async_hooks.d.ts:277
-
+Settings
Settings
Member Visibility
Theme
@@ -486,75 +699,59 @@ then restore the original execution context.
- constructor
-- alive
Interval
+- active
Interval
- is
Main
- last
Task Timestamp
-- main
Worker
- opts
+- statistics
- task
Functions
+- id
+- add
Task Function
- async
Id
- bind
-- check
Alive
- emit
Destroy
- get
Main Worker
-- handle
Error
+- handle
Error
+- handle
Kill Message
+- handle
Ready Message
+- has
Task Function
+- list
Task Functions
- message
Listener
+- remove
Task Function
+- run
- run
Async
- run
In Async Scope
- run
Sync
+- send
Task Functions List To Main Worker
- send
To Main Worker
+- set
Default Task Function
- trigger
Async Id
- bind
Generated using TypeDoc
Generated using TypeDoc