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.
Constructs a new poolifier cluster worker.
Task function(s) processed by the worker when the pool's execution
function is invoked.
Options for the worker.
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.
Protected
idWorker id.
Adds a task function to the worker. If a task function with the same name already exists, it is replaced.
The name of the task function to add.
The task function to add.
Whether the task function was added or not.
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.
A reference to asyncResource
.
Protected
getReturns the main worker.
Reference to the main worker.
https://nodejs.org/api/errors.html#class-error If the main worker is not set.
Protected
handleProtected
handleHandles a kill message sent by the main worker.
Protected
handleHandles the ready message sent by the main worker.
The ready message.
Protected
handleChecks if the worker has a task function with the given name.
The name of the task function to check.
Whether the worker has a task function with the given name or not.
Protected
messageWorker message listener.
The received message.
Removes a task function from the worker.
The name of the task function to remove.
Whether the task function existed and was removed or not.
Protected
runRuns the given task.
The task to execute.
Protected
runRuns the given task function asynchronously.
Task function that will be executed.
Input data for the task function.
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.
The function to call in the execution context of this async resource.
Rest
...args: any[]Optional
thisArg: ThisThe receiver to be used for the function call.
Rest
...args: any[]Optional arguments to pass to the function.
v9.6.0
Protected
runRuns the given task function synchronously.
Task function that will be executed.
Input data for the task function.
Protected
sendProtected
sendSends a message to main worker.
The response message.
Sets the default task function to use in the worker.
The name of the task function to use as default task function.
Whether the default task function was set or not.
Static
bindBinds the given function to the current execution context.
The function to bind to the current execution context.
Optional
type: stringAn optional name to associate with the underlying AsyncResource
.
Optional
thisArg: ThisArgv14.8.0, v12.19.0
Generated using TypeDoc
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