Skip to main content

StreamWorker

:StreamWorker

StreamWorker class - intended for internal use

This class provides control over the subprocesses, including:

  • spawning
  • communicating
  • delivering streams

Kind: static class Internal:

new StreamWorker()

Private constructor

streamWorker.spawn() : StreamWorker ⇄

Spawns the worker if necessary and provides the port information to it.

Kind: instance method of StreamWorker

streamWorker.delegate(input, delegateFunc, [plugins]) : DataStream

Delegates a stream to the child using tcp socket.

The stream gets serialized using JSON and passed on to the sub-process. The sub-process then performs transforms on the stream and pushes them back to the main process. The stream gets deserialized and outputted to the returned DataStream.

Kind: instance method of StreamWorker Returns: DataStream - stream after transforms and back to the main process.

ParamTypeDefaultDescription
inputDataStreamstream to be delegated
delegateFuncArray.<TeeCallback> | ArrayArray of transforms or arrays describing ['module', 'method']
[plugins]Array.<any>[]List of plugins to load in the child

StreamWorker:fork([count]) : Array.<StreamWorker> ⇄

Spawns (Preforks) a given number of subprocesses and returns the worker asynchronously.

Kind: static method of StreamWorker Returns: Array.<StreamWorker> - list of StreamWorkers

ParamTypeDefaultDescription
[count]numberos.cpus().lengthNumber of processes to spawn. If other subprocesses are active only the missing ones will be spawned.

StreamWorker:_getWorker() : StreamWorker ⇄

Picks next worker (not necessarily free one!)

Kind: static method of StreamWorker

Was it helpful?

Didn't find information needed?

Join our Scramjet Community on Discord, where you can get help from our engineers directly.