List of objects to be used as TaskExecutors
Adds a TaskExecutor instance to this WorkerInterface
. If this is the first TaskExecutor, the interface
will start handling messages from the worker's owner and throwing errors for unrecognized tasks.
Object to add.
Handles messages from the worker's owner, once a message is received, it looks for a task and a matching TaskExecutor for it. If an executor for a task is found and the task succeeds, the result of the task is sent back as a message to the worker's owner, an error message with an explanation is sent otherwise.
Event from the worker's owner.
Registers this instance to listen for message
events from the worker's owner.
Removes a [TaskExecutor]] from this WorkerInterface
. If, after removing the specified object, there are no more
executors left, the interface will stop handling messages from the worker's owner.
The object to remove.
Utility function to send an error message back to the worker's owner.
The reason for the error.
Utility function to send a success message back to the worker's owner.
An object that will be sent with the message.
Transferable objects, if any.
Unregisters this instance from listening for message
events from the worker's owner.
Generated using TypeDoc
Interface meant to be used within a Worker to handle messages through the use of objects that comply with the rules set by TaskExecutor. Messages are ony handled if at least one TaskExecutor has been added.
This class is not meant to be used directly, instead, the
WorkerInterface
module exports a single instance of this class.