BunWorker.ts
BunWorker.ts overview
Section titled “BunWorker.ts overview”Parent-side worker support for Bun applications.
layerPlatform provides the WorkerPlatform used to communicate with
globalThis.Worker instances through Effect’s worker protocol. layer
combines that platform with a Spawner built from a callback that creates a
worker for each worker id. The platform forwards worker messages and errors,
asks workers to close on scope finalization, and terminates them if graceful
shutdown times out.
Since v4.0.0
Exports Grouped by Category
Section titled “Exports Grouped by Category”layers
Section titled “layers”Provides the Bun WorkerPlatform together with a Worker.Spawner created
from the supplied worker spawning function.
Signature
declare const layer: (spawn: (id: number) => globalThis.Worker) => Layer.Layer<Worker.WorkerPlatform | Worker.Spawner>Since v4.0.0
layerPlatform
Section titled “layerPlatform”Provides the Bun WorkerPlatform, wiring worker messages and errors into
Effect workers and requesting graceful worker shutdown during scope
finalization before terminating on timeout.
Signature
declare const layerPlatform: Layer.Layer<Worker.WorkerPlatform, never, never>Since v4.0.0