Module
Defined in: core/src/module.ts:43
Module - Represents a worker process with configuration and communication.
Example
Section titled “Example”const worker = new Module('worker') .executable('python', ['worker.py']) .method('process', { codec: msgpackCodec }) .event('progress');
// After manager.spawn():const result = await worker.send('process', data);worker.onEvent('progress', console.log);Extends
Section titled “Extends”SpawnError<S,ChildProcess>
Type Parameters
Section titled “Type Parameters”S extends SpawnError = SpawnError
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Module<
S>():Module<S>
Returns
Section titled “Returns”Module<S>
Inherited from
Section titled “Inherited from”ModuleCore<S, ChildProcess>.constructor
Methods
Section titled “Methods”event()
Section titled “event()”event<
N,C>(name,config?):Module<AddEvent<S,N,C>>
Defined in: core/src/module.ts:97
Register an event.
Type Parameters
Section titled “Type Parameters”N extends string
C extends Codec = Codec
Parameters
Section titled “Parameters”N
config?
Section titled “config?”any
Returns
Section titled “Returns”Module<AddEvent<S, N, C>>
method()
Section titled “method()”Register a method (implementation: shared core).
Call Signature
Section titled “Call Signature”method<
N,CReq,CRes,RT>(name,config):Module<AddMethod<S,N,CReq,CRes,RT>>
Defined in: core/src/module.ts:60
Register a method with dual codecs (full control).
Use when request and response need different codecs, or when using asymmetric codecs like Arrow.
Type Parameters
Section titled “Type Parameters”N extends string
CReq extends Codec
CRes extends Codec
RT extends ResponseType = "result"
Parameters
Section titled “Parameters”N
config
Section titled “config”any
Returns
Section titled “Returns”Module<AddMethod<S, N, CReq, CRes, RT>>
Call Signature
Section titled “Call Signature”method<
N,C,RT>(name,config?):Module<AddMethodSymmetric<S,N,C,RT>>
Defined in: core/src/module.ts:73
Register a method with a single codec (symmetric shorthand).
Type Parameters
Section titled “Type Parameters”N extends string
C extends Codec = Codec
RT extends ResponseType = "result"
Parameters
Section titled “Parameters”N
config?
Section titled “config?”any
Returns
Section titled “Returns”Module<AddMethodSymmetric<S, N, C, RT>>