Skip to content

RunnerServer

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.

4 exports Added in v4.0.0 Source

Layers

layer

Added in v4.0.0 Source

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

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,
  | ShardingConfig
  | Runners.RpcClientProtocol
  | MessageStorage.MessageStorage
  | RunnerStorage.RunnerStorage
>;

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

Signature

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

Layer that provides RunnerServer together with Runners and Sharding clients.

Signature

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