X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FClusterWorker.html;h=4c7c8415679518334f11da70c0341d878d38e0ce;hb=8f279193e13c76ab6a8f795e4bb0b591e8c2b4af;hp=ea603c4f1811029915895e0b9ec49393a042c2c8;hpb=273b76d87560482b4114668a705e42d54b3ce3b0;p=poolifier.git diff --git a/docs/classes/ClusterWorker.html b/docs/classes/ClusterWorker.html index ea603c4f..4c7c8415 100644 --- a/docs/classes/ClusterWorker.html +++ b/docs/classes/ClusterWorker.html @@ -1,110 +1,82 @@ -
A cluster worker used by a poolifier
+ClusterPool
.- Preparing search index...
- The search index is not available
poolifier - v4.0.13Class 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.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 structured-cloneable data.
-Response = unknown
Type of response the worker sends back to the main worker. This can only be structured-cloneable data.
-Hierarchy
Index
Constructors
Properties
Accessors
Methods
Constructors
constructor
Constructs a new poolifier cluster worker.
-Type Parameters
Data = unknown
Response = unknown
Parameters
taskFunctions: TaskFunction<Data, Response> | TaskFunctions<Data, Response>
Task function(s) processed by the worker when the pool's
-execution
function is invoked.opts: WorkerOptions = {}
Options for the worker.
-Returns ClusterWorker<Data, Response>
Properties
Protected
Optional
activeHandler id of the
-activeInterval
worker activity check.Protected
Readonly
isWhether this is the main worker or not.
-Protected
lastTimestamp of the last task processed by this worker.
-Protected
optsOptions for the worker.
-Protected
statisticsPerformance statistics computation requirements.
-Protected
taskTask function(s) processed by the worker when the pool's
-execution
function is invoked.Accessors
Protected
idWorker id.
-Returns number
Methods
add Task Function
Adds a task function to the worker. +
Type Parameters
Type of data this worker receives from pool's execution. This can only be structured-cloneable data.
+Type of response the worker sends back to the main worker. This can only be structured-cloneable data.
+Hierarchy (view full)
Index
Constructors
Properties
Accessors
Methods
Constructors
constructor
Constructs a new poolifier cluster worker.
+Type Parameters
Parameters
Task function(s) processed by the worker when the pool's
+execution
function is invoked.Options for the worker.
+Returns ClusterWorker<Data, Response>
Properties
Protected
Optional
activeHandler id of the
+activeInterval
worker activity check.Protected
Readonly
isWhether this is the main worker or not.
+Protected
lastTimestamp of the last task processed by this worker.
+Protected
optsOptions for the worker.
+Protected
Optional
statisticsPerformance statistics computation requirements.
+Protected
taskTask function object(s) processed by the worker when the pool's
+execution
function is invoked.Accessors
Protected
idWorker id.
+Returns number
Methods
add Task Function
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.
+Parameters
The name of the task function to add.
+The task function to add.
Returns TaskFunctionOperationResult
Whether the task function was added or not.
-async Id
Returns number
The unique
-asyncId
assigned to the resource.bind
Binds the given function to execute to this
-AsyncResource
's scope.Type Parameters
Func extends ((...args) => any)
Parameters
fn: Func
The function to bind to the current
-AsyncResource
.Returns Func
Since
v14.8.0, v12.19.0
-emit Destroy
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 thedestroy
hooks will -never be called.Returns ClusterWorker<Data, Response>
A reference to
-asyncResource
.Protected
getReturns the main worker.
-Returns Worker
Reference to the main worker.
+Protected
getReturns the main worker.
+Returns Worker
Reference to the main worker.
Throws
https://nodejs.org/api/errors.html#class-error If the main worker is not set.
-Protected
handleHandles an error and convert it to a string so it can be sent back to the main worker.
-Parameters
error: string | Error
The error raised by the worker.
+Protected
handleHandles an error and convert it to a string so it can be sent back to the main worker.
+Parameters
The error raised by the worker.
Returns string
The error message.
-Protected
handleHandles a kill message sent by the main worker.
-Parameters
_message: MessageValue<Data, unknown>
Returns void
Protected
handleHandles the ready message sent by the main worker.
-Parameters
message: MessageValue<Data, unknown>
The ready message.
-Returns void
Protected
handleParameters
message: MessageValue<Data, unknown>
Returns void
has Task Function
Checks if the worker has a task function with the given name.
-Parameters
name: string
The name of the task function to check.
+Protected
handleHandles a kill message sent by the main worker.
+Parameters
Returns void
Protected
handleHandles the ready message sent by the main worker.
+Parameters
The ready message.
+Returns void
Protected
handleParameters
Returns void
has Task Function
Checks if the worker has a task function with the given name.
+Parameters
The name of the task function to check.
Returns TaskFunctionOperationResult
Whether the worker has a task function with the given name or not.
-list Task Function Names
Lists the names of the worker's task functions.
-Returns string[]
The names of the worker's task functions.
-Protected
messageWorker message listener.
-Parameters
message: MessageValue<Data, unknown>
The received message.
-Returns void
remove Task Function
Removes a task function from the worker.
-Parameters
name: string
The name of the task function to remove.
+list Task Functions Properties
Lists the properties of the worker's task functions.
+Returns TaskFunctionProperties[]
The properties of the worker's task functions.
+Protected
messageWorker message listener.
+Parameters
The received message.
+Returns void
remove Task Function
Removes a task function from the worker.
+Parameters
The name of the task function to remove.
Returns TaskFunctionOperationResult
Whether the task function existed and was removed or not.
-Protected
runRuns the given task.
-Parameters
task: Task<Data>
The task to execute.
-Returns void
Protected
runRuns the given task function asynchronously.
-Parameters
fn: TaskAsyncFunction<Data, Response>
Task function that will be executed.
-task: Task<Data>
Input data for the task function.
-Returns void
run In Async Scope
Call the provided function with the provided arguments in the execution context -of the async resource. This will establish the context, trigger the AsyncHooks -before callbacks, call the function, trigger the AsyncHooks after callbacks, and -then restore the original execution context.
-Type Parameters
This
Result
Parameters
fn: ((this, ...args) => Result)
The function to call in the execution context of this async resource.
-Parameters
this: This
Rest
...args: any[]Returns Result
Optional
thisArg: ThisThe receiver to be used for the function call.
-Rest
...args: any[]Optional arguments to pass to the function.
-Returns Result
Since
v9.6.0
-Protected
runRuns the given task function synchronously.
-Parameters
fn: TaskSyncFunction<Data, Response>
Task function that will be executed.
-task: Task<Data>
Input data for the task function.
-Returns void
Protected
sendSends task function names to the main worker.
-Returns void
Protected
sendSends a message to main worker.
-Parameters
message: MessageValue<Response, unknown>
The response message.
-Returns void
set Default Task Function
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.
+Protected
Readonly
runRuns the given task.
+Parameters
The task to execute.
+Returns void
Protected
Readonly
runRuns the given task function asynchronously.
+Parameters
Task function that will be executed.
+Input data for the task function.
+Returns void
Protected
Readonly
runRuns the given task function synchronously.
+Parameters
Task function that will be executed.
+Input data for the task function.
+Returns void
Protected
sendSends task functions properties to the main worker.
+Returns void
Protected
Readonly
sendSends a message to main worker.
+Parameters
The response message.
+Returns void
set Default Task Function
Sets the default task function to use in the worker.
+Parameters
The name of the task function to use as default task function.
Returns TaskFunctionOperationResult
Whether the default task function was set or not.
-trigger Async Id
Returns number
The same
-triggerAsyncId
that is passed to theAsyncResource
constructor.Static
bindBinds the given function to the current execution context.
-Type Parameters
Func extends ((this, ...args) => any)
ThisArg
Parameters
fn: Func
The function to bind to the current execution context.
-Optional
type: stringAn optional name to associate with the underlying
-AsyncResource
.Optional
thisArg: ThisArgReturns Func
Since
v14.8.0, v12.19.0
-Settings
Member Visibility
Theme
On This Page
Generated using TypeDoc
Settings
Member Visibility
Theme
On This Page