Module
Defined in: procwire-bun-core/src/module.ts:58
Module - Represents a worker process with configuration and communication.
This is the Bun.js version; the API is identical to @procwire/core.
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,BunSubprocess>
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, BunSubprocess>.constructor
Methods
Section titled “Methods”event()
Section titled “event()”event<
N,C>(name,config?):Module<AddEvent<S,N,C>>
Defined in: procwire-bun-core/src/module.ts:104
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: procwire-bun-core/src/module.ts:67
Register a method with dual codecs (full control).
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: procwire-bun-core/src/module.ts:80
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>>