WorkerRunner.ts
WorkerRunner.ts overview
Section titled “WorkerRunner.ts overview”Worker-side primitives for worker-like runtimes.
A WorkerRunner receives messages tagged by a numeric port id, sends replies
back through the same transport, and can expose disconnect notifications. The
module also defines the small platform message shape and the
WorkerRunnerPlatform service that starts a platform-specific runner.
Since v4.0.0
Exports Grouped by Category
Section titled “Exports Grouped by Category”models
Section titled “models”PlatformMessage (type alias)
Section titled “PlatformMessage (type alias)”Wire protocol message used by worker platforms: a request carrying input or a close signal.
Signature
type PlatformMessage<I> = readonly [request: 0, I] | readonly [close: 1]Since v4.0.0
WorkerRunner (interface)
Section titled “WorkerRunner (interface)”Platform-neutral worker runner that receives inbound messages by port ID, sends outbound messages, and optionally exposes disconnect notifications.
Signature
export interface WorkerRunner<O = unknown, I = unknown> { readonly run: <A, E, R>( handler: (portId: number, message: I) => Effect.Effect<A, E, R> | void ) => Effect.Effect<void, WorkerError, R> readonly send: (portId: number, message: O, transfers?: ReadonlyArray<unknown>) => Effect.Effect<void> readonly sendUnsafe: (portId: number, message: O, transfers?: ReadonlyArray<unknown>) => void readonly disconnects?: Queue.Dequeue<number> | undefined}Since v4.0.0
WorkerRunnerPlatform (class)
Section titled “WorkerRunnerPlatform (class)”Context service that starts a platform-specific WorkerRunner.
Signature
declare class WorkerRunnerPlatformSince v4.0.0