X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=docs%2Fclasses%2FClusterWorker.html;h=cd636f20e008d02c9f08dd10d99d8feb482841c1;hb=00773faaaac2b2599bdc66823796d0c38b165bde;hp=8dea95ee7683cb407a4b51654609ed78464f414a;hpb=fbc22127e53d3ec0ecbd38ecea25fb92ebef50e7;p=poolifier.git diff --git a/docs/classes/ClusterWorker.html b/docs/classes/ClusterWorker.html index 8dea95ee..cd636f20 100644 --- a/docs/classes/ClusterWorker.html +++ b/docs/classes/ClusterWorker.html @@ -1,521 +1,82 @@ -
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
Optional
statisticsPerformance statistics computation requirements.
+Protected
taskTask function object(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.
+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.
+Lists the properties of the worker's task functions.
+The properties of the worker's task functions.
+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
Readonly
runProtected
Readonly
runRuns the given task function asynchronously.
+Task function that will be executed.
+Input data for the task function.
+Protected
Readonly
runRuns the given task function synchronously.
+Task function that will be executed.
+Input data for the task function.
+Protected
sendProtected
Readonly
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.
+
A cluster worker used by a poolifier
+ClusterPool
.- Preparing search index...
- The search index is not available
poolifier - v4.0.8Class 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 serializable data.
-Response = unknown
-Type of response the worker sends back to the main worker. This can only be serializable data.
-Hierarchy
--- AbstractWorker<Worker, Data, Response>
-
-- ClusterWorker
-
-Index
Constructors
-Properties
-Methods
-Constructors
-constructor
--- new
Cluster Worker<Data, Response>(fn, opts?): ClusterWorker<Data, Response>
--
-
-
-
-
-
-
Constructs a new poolifier cluster worker.
-Type Parameters
---
-
--
-
Data = unknown
Response = unknown
Parameters
---
-
--
-
fn: WorkerFunction<Data, Response>
-Function processed by the worker when the pool's
-execution
function is invoked.opts: WorkerOptions = {}
-Options for the worker.
-Returns ClusterWorker<Data, Response>
Properties
- Interval
-Protected
Optional
Readonly
aliveHandler id of the
-aliveInterval
worker alive check. Main
-Protected
Readonly
isWhether this is the main worker or not.
- Task Timestamp
-Protected
lastTimestamp of the last task processed by this worker.
- Worker
-Protected
mainReference to main worker.
-
-Protected
Readonly
optsOptions for the worker.
-Methods
-async Id
--- async
Id(): number
--
-
-
-
Returns
The unique
-asyncId
assigned to the resource.Returns number
bind
--- bind<Func>(fn): Func & {
--
-
-
-
-
-
-
    asyncResource: AsyncResource;
}
Binds the given function to execute to this
-AsyncResource
's scope.The returned function will have an
- -asyncResource
property referencing -theAsyncResource
to which the function is bound.Since
v14.8.0, v12.19.0
-Type Parameters
---
-
Func extends ((...args) => any)
Parameters
---
-
fn: Func
-The function to bind to the current
-AsyncResource
.Returns Func & {
    asyncResource: AsyncResource;
}
Alive
-Protected
check-- check
Alive(): void
--
-
-
Checks if the worker should be terminated, because its living too long.
-Returns void
emit Destroy
--- emit
Destroy(): ClusterWorker<Data, Response>
--
-
-
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
A reference to
-asyncResource
.Returns ClusterWorker<Data, Response>
Main Worker
-Protected
get-- get
Main Worker(): Worker
--
-
-
Returns the main worker.
- -Returns
Reference to the main worker.
-Returns 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.
- -Returns
Message of the error.
-Parameters
---
-
e: string | Error
-The error raised by the worker.
-Returns string
Listener
-Protected
message-- message
Listener(message, fn): void
--
-
-
-
-
Worker message listener.
-Parameters
---
-
--
-
message: MessageValue<Data, Worker>
-Message received.
-fn: WorkerFunction<Data, Response>
-Function processed by the worker when the pool's
-execution
function is invoked.Returns void
-Protected
run-- run(fn, message): void
--
-
-
-
-
Runs the given function synchronously.
-Parameters
---
-
--
-
fn: WorkerSyncFunction<Data, Response>
-Function that will be executed.
-message: MessageValue<Data, unknown>
-Input data for the given function.
-Returns void
Async
-Protected
run-- run
Async(fn, message): void
--
-
-
-
-
Runs the given function asynchronously.
-Parameters
---
-
--
-
fn: WorkerAsyncFunction<Data, Response>
-Function that will be executed.
-message: MessageValue<Data, unknown>
-Input data for the given function.
-Returns void
run In Async Scope
--- run
In Async Scope<This, Result>(fn, thisArg?, ...args): Result
--
-
-
-
-
-
-
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.
- -Since
v9.6.0
-Type Parameters
---
-
--
-
This
Result
Parameters
---
-
-
--
-
--
-
fn: ((this, ...args) => Result)
-The function to call in the execution context of this async resource.
---
-
-- (this, ...args): Result
--
-
-
-
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
To Main Worker
-Protected
send-- send
To Main Worker(message): void
--
-
-
-
-
Sends a message to the main worker.
-Parameters
---
-
message: MessageValue<Response, unknown>
-The response message.
-Returns void
trigger Async Id
--- trigger
Async Id(): number
--
-
-
-
Returns
The same
-triggerAsyncId
that is passed to theAsyncResource
constructor.Returns number
-Static
bind-- bind<Func, ThisArg>(fn, type?, thisArg?): Func & {
--
-
-
-
-
-
-
    asyncResource: AsyncResource;
}
Binds the given function to the current execution context.
-The returned function will have an
- -asyncResource
property referencing -theAsyncResource
to which the function is bound.Since
v14.8.0, v12.19.0
-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 & {
    asyncResource: AsyncResource;
}
-
-Settings
Member Visibility
Theme
-
-On This Page
-- constructor
-- alive
Interval
-- is
Main
-- last
Task Timestamp
-- main
Worker
-- opts
-- async
Id
-- bind
-- check
Alive
-- emit
Destroy
-- get
Main Worker
-- handle
Error
-- message
Listener
-- run
-- run
Async
-- run
In Async Scope
-- send
To Main Worker
-- trigger
Async Id
-- bind
Generated using TypeDoc
Author
Christopher Quadflieg
+Since
2.0.0
+