BunWorker
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.
Layers
Signature
declare function layer(spawn: (id: number) => Worker): Layer<WorkerPlatform | Spawner>;layerPlatform
Added in v4.0.0
Source
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<WorkerPlatform, never, never>;
Provides the Bun
WorkerPlatformtogether with aWorker.Spawnercreated from the supplied worker spawning function.