Skip to content

NodeClusterHttp

Node.js HTTP and WebSocket layers for Effect Cluster runners.

The main layer builds a sharding layer for HTTP or WebSocket transport, choosing serialization, runner health checks, runner storage, message storage, and optional client-only mode from the supplied options. layerHttpServer provides the Node HTTP server used by cluster runners, and this module re-exports the Kubernetes HTTP client layer used by runner health checks.

3 exports Added in v4.0.0 Source

Layers

layer

Added in v4.0.0 Source

Builds the Node cluster HTTP/WebSocket sharding layer, configuring runner transport, RPC serialization, message storage, runner health checks, and optional client-only mode.

Signature

declare function layer<ClientOnly extends boolean = false, Storage extends "local" | "sql" | "byo" = never>(options: {
  readonly clientOnly?: ClientOnly;
  readonly runnerHealth?: "ping" | "k8s";
  readonly runnerHealthK8s?: {
    readonly labelSelector?: string;
    readonly namespace?: string;
  };
  readonly serialization?: "msgpack" | "ndjson";
  readonly serializationMaxBufferSize?: number | "unbounded";
  readonly shardingConfig?: Partial<{
    readonly assignedShardGroups: readonly Array<string>;
    readonly availableShardGroups: readonly Array<string>;
    readonly entityMailboxCapacity: number | "unbounded";
    readonly entityMaxIdleTime: Input;
    readonly entityMessagePollInterval: Input;
    readonly entityRegistrationTimeout: Input;
    readonly entityReplyPollInterval: Input;
    readonly entityTerminationTimeout: Input;
    readonly preemptiveShutdown: boolean;
    readonly refreshAssignmentsInterval: Input;
    readonly runnerAddress: Option<RunnerAddress>;
    readonly runnerHealthCheckInterval: Input;
    readonly runnerListenAddress: Option<RunnerAddress>;
    readonly runnerShardWeight: number;
    readonly sendRetryInterval: Input;
    readonly shardLockDisableAdvisory: boolean;
    readonly shardLockExpiration: Input;
    readonly shardLockRefreshInterval: Input;
    readonly shardsPerGroup: number;
    readonly simulateRemoteSerialization: boolean;
  }>;
  readonly storage?: Storage;
  readonly transport: "http" | "websocket";
}): ClientOnly extends true ? Layer<Sharding | Runners | "byo" extends Storage ? never : MessageStorage, ConfigError, "local" extends Storage ? never : "byo" extends Storage ? MessageStorage | RunnerStorage : SqlClient> : Layer<Sharding | Runners | "byo" extends Storage ? never : MessageStorage, ConfigError | ServeError, "local" extends Storage ? never : "byo" extends Storage ? MessageStorage | RunnerStorage : SqlClient>

Provides the HTTP server and Node HTTP services used by cluster runners, listening on ShardingConfig.runnerListenAddress or runnerAddress.

Signature

declare const layerHttpServer: Layer.Layer<
  HttpPlatform | Etag.Generator | NodeServices | HttpServer,
  ServeError,
  ShardingConfig.ShardingConfig
>;

Provides a K8sHttpClient backed by the Undici HTTP client and the Kubernetes-aware dispatcher.

Signature

declare const layerK8sHttpClient: Layer.Layer<K8sHttpClient.K8sHttpClient>;