(
protocol: Layer.Layer<RpcClient.Protocol>
): Layer.Layer<RpcClient.Protocol>The standard way to set the RPC client transport: hand it any RpcClient.Protocol layer and
it becomes the ambient transport that every nodeless Hyperlink.client — and each node's
peers fold — reads. This is the primitive; protocolHttp / protocolWebsocket
build the two common protocols, and ws / http are per-node
shortcuts layered on top. Provide it once and the whole app agrees on a wire:
Effect.provide(app, Hyperlink.layerProtocol(Hyperlink.protocolWebsocket())); // one knob
Effect.provide(app, Hyperlink.layerProtocol(Hyperlink.protocolHttp("http://edge/rpc")));export const const layerProtocol: (
protocol: Layer.Layer<RpcClient.Protocol>
) => Layer.Layer<RpcClient.Protocol>
The standard way to set the RPC client transport: hand it any RpcClient.Protocol layer and
it becomes the ambient transport that every nodeless
Hyperlink.client
— and each node's
peers
fold — reads. This is the primitive;
protocolHttp
/
protocolWebsocket
build the two common protocols, and
ws
/
http
are per-node
shortcuts layered on top. Provide it once and the whole app agrees on a wire:
Effect.provide(app, Hyperlink.layerProtocol(Hyperlink.protocolWebsocket())); // one knob
Effect.provide(app, Hyperlink.layerProtocol(Hyperlink.protocolHttp("http://edge/rpc")));
layerProtocol = (
protocol: Layer.Layer<
RpcClient.Protocol,
never,
never
>
(parameter) protocol: {
build: (memoMap: Layer.MemoMap, scope: Scope.Scope) => Effect.Effect<Context.Context<RpcClient.Protocol>, never, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
protocol: import LayerLayer.interface Layer<in ROut, out E = never, out RIn = never>A Layer describes how to build one or more services for dependency injection.
When to use
Use to model construction of application services for dependency injection,
especially when services have dependencies, can fail during construction, or
need scoped setup and release.
Details
A Layer<ROut, E, RIn> represents ROut as the services this layer
provides, E as the possible errors during layer construction, and RIn as
the services this layer requires as dependencies.
Layer<import RpcClientRpcClient.class Protocolclass Protocol {
key: Identifier;
Service: {
run: (clientId: number, f: (data: FromServerEncoded) => Effect.Effect<void>) => Effect.Effect<never>;
send: (clientId: number, request: FromClientEncoded, transferables?: ReadonlyArray<globalThis.Transferable>) => Effect.Effect<void, RpcClientError>;
supportsAck: boolean;
supportsTransferables: boolean;
};
}
Defines the service interface for an RPC client transport, responsible for running the
receive loop and sending encoded client messages.
When to use
Use to provide the transport boundary for RPC clients over HTTP, WebSocket,
workers, sockets, or custom protocols.
Protocol>,
): import LayerLayer.interface Layer<in ROut, out E = never, out RIn = never>A Layer describes how to build one or more services for dependency injection.
When to use
Use to model construction of application services for dependency injection,
especially when services have dependencies, can fail during construction, or
need scoped setup and release.
Details
A Layer<ROut, E, RIn> represents ROut as the services this layer
provides, E as the possible errors during layer construction, and RIn as
the services this layer requires as dependencies.
Layer<import RpcClientRpcClient.class Protocolclass Protocol {
key: Identifier;
Service: {
run: (clientId: number, f: (data: FromServerEncoded) => Effect.Effect<void>) => Effect.Effect<never>;
send: (clientId: number, request: FromClientEncoded, transferables?: ReadonlyArray<globalThis.Transferable>) => Effect.Effect<void, RpcClientError>;
supportsAck: boolean;
supportsTransferables: boolean;
};
}
Defines the service interface for an RPC client transport, responsible for running the
receive loop and sending encoded client messages.
When to use
Use to provide the transport boundary for RPC clients over HTTP, WebSocket,
workers, sockets, or custom protocols.
Protocol> => protocol: Layer.Layer<
RpcClient.Protocol,
never,
never
>
(parameter) protocol: {
build: (memoMap: Layer.MemoMap, scope: Scope.Scope) => Effect.Effect<Context.Context<RpcClient.Protocol>, never, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
protocol;