Skip to content

RunnerServer.ts

Provides server-side layers for the cluster runner protocol.

Runner protocol handlers receive ping, notification, request, stream, and envelope messages from other runners. They forward those messages into Sharding and coordinate persisted replies through MessageStorage. This module includes the handler layer, a transport-independent RPC server layer, a full server layer that also provides runner clients, and a client-only layer for applications that do not serve runner RPCs.

Since v4.0.0



Creates the runner RPC server layer, which receives messages from other runners, forwards them to the Sharding layer, and responds to Ping requests.

When to use

Use when a runner process should accept runner-to-runner protocol messages over a provided server RpcServer.Protocol.

Gotchas

This layer does not choose or provide the wire transport; provide a transport-specific RpcServer.Protocol separately.

See

  • layerHandlers for the lower-level handler layer used when the RPC server is supplied elsewhere
  • layerWithClients for a runner server layer that also provides the Sharding and Runners clients
  • layerClientOnly for embedding a cluster client without serving runner RPCs

Signature

declare const layer: Layer.Layer<never, never, RpcServer.Protocol | Sharding.Sharding | MessageStorage.MessageStorage>

Source

Since v4.0.0

Creates a client-only Runners layer.

When to use

Use to embed a cluster client inside another Effect application without registering with the ShardManager or receiving shard assignments.

Signature

declare const layerClientOnly: Layer.Layer<
Sharding.Sharding | Runners.Runners,
never,
MessageStorage.MessageStorage | RunnerStorage.RunnerStorage | ShardingConfig | Runners.RpcClientProtocol
>

Source

Since v4.0.0

Layer that handles runner protocol RPCs by forwarding requests to Sharding and MessageStorage.

Signature

declare const layerHandlers: Layer.Layer<
Handler<"Ping"> | Handler<"Notify"> | Handler<"Effect"> | Handler<"Stream"> | Handler<"Envelope">,
never,
Sharding.Sharding | MessageStorage.MessageStorage
>

Source

Since v4.0.0

Layer that provides RunnerServer together with Runners and Sharding clients.

Signature

declare const layerWithClients: Layer.Layer<
Sharding.Sharding | Runners.Runners,
never,
| RpcServer.Protocol
| MessageStorage.MessageStorage
| RunnerStorage.RunnerStorage
| ShardingConfig
| Runners.RpcClientProtocol
| RunnerHealth.RunnerHealth
>

Source

Since v4.0.0