Skip to content
Effect 4.0 is here. One ecosystem. Zero dependencies.

EntityProxyServer unstable

Serves the proxy APIs generated from clustered entities.

Proxy handlers read the target entityId, call the entity client, and forward the payload to the matching entity RPC method. This module provides handlers for HTTP API groups created by EntityProxy.toHttpApiGroup and RPC handler services for RPC groups created by EntityProxy.toRpcGroup. Both normal requests and discard requests are forwarded to the underlying entity client.

3 exports Since v4.0.0 Source

Layers

Since v4.0.0

Creates HTTP API handlers for an entity proxy group.

Details

Each generated endpoint reads the entityId path parameter and forwards the request payload to the corresponding entity client method, including discard endpoints.

Signature

declare function layerHttpApi<ApiId extends string, Groups extends Constraint, Identifier extends string, Type extends string, Rpcs extends Any>(api: HttpApi<ApiId, Groups>, identifier: Identifier, entity: Entity<Type, Rpcs>): Layer<Service<ApiId, Identifier>, never, Sharding | ServicesServer<Rpcs> | ServicesClient<Rpcs>>
Since v4.0.0

Creates RPC handlers for the group produced by EntityProxy.toRpcGroup.

Details

The handlers forward each prefixed proxy RPC to the target entity client using the entityId embedded in the proxy payload.

Signature

declare function layerRpcHandlers<Type extends string, Rpcs extends Any>(entity: Entity<Type, Rpcs>): Layer<RpcHandlers<Rpcs, Type>, never, Sharding | ServicesServer<Rpcs> | ServicesClient<Rpcs>>

Services

RpcHandlers

type unstable
Since v4.0.0

Union of RPC handler services required to serve the proxy RPCs for an entity.

Details

Includes both the normal prefixed RPC handler and its discard variant.

Signature

type RpcHandlers<Rpcs extends Rpc.Any, Prefix extends string> = Rpcs extends Rpc.Rpc<infer _Tag, infer _Payload, infer _Success, infer _Error, infer _Middleware, infer _Requires> ? Rpc.Handler<`${Prefix}.${_Tag}`> | Rpc.Handler<`${Prefix}.${_Tag}Discard`> : never