Skip to content

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.

2 exports Added in v4.0.0 Source

Layers

layer

Added in v4.0.0 Source

Provides the Bun WorkerPlatform together with a Worker.Spawner created from the supplied worker spawning function.

Signature

declare function layer(spawn: (id: number) => Worker): Layer<WorkerPlatform | Spawner>;

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