Skip to content

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.

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);

S extends SpawnError = SpawnError

new Module<S>(): Module<S>

Module<S>

ModuleCore<S, BunSubprocess>.constructor

event<N, C>(name, config?): Module<AddEvent<S, N, C>>

Defined in: procwire-bun-core/src/module.ts:104

Register an event.

N extends string

C extends Codec = Codec

N

any

Module<AddEvent<S, N, C>>


Register a method (implementation: shared core).

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).

N extends string

CReq extends Codec

CRes extends Codec

RT extends ResponseType = "result"

N

any

Module<AddMethod<S, N, CReq, CRes, RT>>

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).

N extends string

C extends Codec = Codec

RT extends ResponseType = "result"

N

any

Module<AddMethodSymmetric<S, N, C, RT>>