X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FClusterWorker.html;h=7c3ace7521a5a3464c530636cd86579110548a5f;hb=b2ec8632edaea1f4ee24a532e61ca6e5619b7bfb;hp=1fbbeec0a002fdbf5a66813ac81197d806d4d540;hpb=6be0ab6d5c78c8e91cc4668d3d03db95f15cbfab;p=poolifier.git diff --git a/docs/classes/ClusterWorker.html b/docs/classes/ClusterWorker.html index 1fbbeec0..7c3ace75 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.
+Performance 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): TaskFunctionOperationResult
+-
+
+
+
+
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 TaskFunctionOperationResult
Whether the task function was added or not.
+ +async Id
@@ -194,7 +238,7 @@ but the minimum number of workers will be guaranteed.
bind
@@ -221,19 +265,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
@@ -249,7 +281,7 @@ never be called.
Protected
get@@ -259,14 +291,16 @@ never be called.
Returns Worker
Reference to the main worker.
- Error
-Protected
handle-- handle
Error(e): string
+
+- handle
Error(error): string
-
@@ -274,16 +308,101 @@ never be called.
-
-
Handles an error and convert it to a string so it can be sent back to the main worker.
Parameters
e: string | Error
+error: string | Error
The error raised by the worker.
Returns string
Message of the error.
+Returns string
The error message.
Overrides AbstractWorker.handleError
+Inherited from AbstractWorker.handleError
++- Defined in src/worker/abstract-worker.ts:485
Kill Message
+Protected
handle+- handle
Kill Message(_message): void
+-
+
+
+
+
+
Handles a kill message sent by the main worker.
+Parameters
++-
+
_message: MessageValue<Data, unknown>
Returns void
+Inherited from AbstractWorker.handleKillMessage
-- Defined in src/worker/cluster-worker.ts:52
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
Task Function Operation Message
+Protected
handle+- handle
Task Function Operation Message(message): void
+-
+
+
+
+
Parameters
++-
+
message: MessageValue<Data, unknown>
Returns void
Inherited from AbstractWorker.handleTaskFunctionOperationMessage
++- Defined in src/worker/abstract-worker.ts:326
has Task Function
++- has
Task Function(name): TaskFunctionOperationResult
+-
+
+
+
+
+
Checks if the worker has a task function with the given name.
+Parameters
++-
+
+
name: string
+The name of the task function to check.
+Returns TaskFunctionOperationResult
Whether the worker has a task function with the given name or not.
+ +Inherited from AbstractWorker.hasTaskFunction
++- Defined in src/worker/abstract-worker.ts:162
list Task Function Names
++- list
Task Function Names(): string[]
+-
+
+
+
Lists the names of the worker's task functions.
+Returns string[]
The names of the worker's task functions.
+ +Inherited from AbstractWorker.listTaskFunctionNames
++- Defined in src/worker/abstract-worker.ts:243
Protected
message@@ -295,40 +414,81 @@ never be called.-
-
Parameters
message: MessageValue<Data, Data, Worker>
-Message received.
+message: MessageValue<Data, unknown>
+The received message.
Returns void
Inherited from AbstractWorker.messageListener
-- Defined in src/worker/abstract-worker.ts:149
remove Task Function
++- remove
Task Function(name): TaskFunctionOperationResult
+-
+
+
+
+
+
Removes a task function from the worker.
+Parameters
++-
+
+
name: string
+The name of the task function to remove.
+Returns TaskFunctionOperationResult
Whether the task function existed and was removed or not.
+ +Inherited from AbstractWorker.removeTaskFunction
++- Defined in src/worker/abstract-worker.ts:214
+Protected
run+- run(task): void
+-
+
+
+
+
+
Runs the given task.
+Parameters
++-
+
+
task: Task<Data>
+The task to execute.
+Returns void
+Inherited from AbstractWorker.run
++- Defined in src/worker/abstract-worker.ts:494
Protected
run-- run
Async(fn, message): void
+- run
Async(fn, task): void
-
-
-
-
-
-
+- Defined in src/worker/abstract-worker.ts:555
+- Defined in node_modules/.pnpm/@types+node@20.8.9/node_modules/@types/node/async_hooks.d.ts:299
Sync
+
\ No newline at end of file
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, unknown, 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:255
run In Async Scope
@@ -383,44 +543,56 @@ then restore the original execution context.
Inherited from AbstractWorker.runInAsyncScope
-- Defined in node_modules/.pnpm/@types+node@20.3.0/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:521
+
+
To Main Worker
- send
To Main Worker(message): void
-
-
-
-
@@ -428,7 +600,28 @@ then restore the original execution context.
+- Defined in src/worker/cluster-worker.ts:68
+
+
+- Defined in node_modules/.pnpm/@types+node@20.8.9/node_modules/@types/node/async_hooks.d.ts:319
+ - Defined in node_modules/.pnpm/@types+node@20.8.9/node_modules/@types/node/async_hooks.d.ts:278
-
+
-
-
\ No newline at end of file
+
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, unknown, 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:222
Task Function Names To Main Worker
+Protected
send+- send
Task Function Names To Main Worker(): void
+-
+
+
+
Sends task function names to the main worker.
+Returns void
+Inherited from AbstractWorker.sendTaskFunctionNamesToMainWorker
++- Defined in src/worker/abstract-worker.ts:473
Protected
sendSends a message to the main worker.
+Sends a message to main worker.
Parameters
message: MessageValue<Response, unknown, Worker | MessagePort>
+message: MessageValue<Response, unknown>
The response message.
Overrides AbstractWorker.sendToMainWorker
-- Defined in src/worker/cluster-worker.ts:47
set Default Task Function
++- set
Default Task Function(name): TaskFunctionOperationResult
+-
+
+
+
+
+
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 TaskFunctionOperationResult
Whether the default task function was set or not.
+ +Inherited from AbstractWorker.setDefaultTaskFunction
++- Defined in src/worker/abstract-worker.ts:270
trigger Async Id
@@ -439,7 +632,7 @@ then restore the original execution context.
Inherited from AbstractWorker.triggerAsyncId
-- Defined in node_modules/.pnpm/@types+node@20.3.0/node_modules/@types/node/async_hooks.d.ts:311
Static
bind@@ -475,12 +668,12 @@ then restore the original execution context.
Inherited from AbstractWorker.bind
-- Defined in node_modules/.pnpm/@types+node@20.3.0/node_modules/@types/node/async_hooks.d.ts:277
-
+Settings
Settings
Member Visibility
Generated using TypeDoc
Generated using TypeDoc