RpcServer.ts overview
Since v1.0.0
Exports Grouped by Category
constructors
toWebHandler
Construct an http web handler from an RpcGroup
.
Signature
declare const toWebHandler: <Rpcs extends Rpc.Any, LE>(
group: RpcGroup.RpcGroup<Rpcs>,
options: {
readonly layer: Layer.Layer<
| Rpc.ToHandler<Rpcs>
| Rpc.Middleware<Rpcs>
| RpcSerialization.RpcSerialization
| HttpRouter.HttpRouter.DefaultServices,
LE
>
readonly disableTracing?: boolean | undefined
readonly spanPrefix?: string | undefined
readonly middleware?: (httpApp: HttpApp.Default) => HttpApp.Default<never, HttpRouter.HttpRouter.DefaultServices>
readonly memoMap?: Layer.MemoMap
}
) => {
readonly handler: (request: globalThis.Request, context?: Context.Context<never> | undefined) => Promise<Response>
readonly dispose: () => Promise<void>
}
Since v1.0.0
http app
toHttpApp
Signature
declare const toHttpApp: <Rpcs extends Rpc.Any>(
group: RpcGroup.RpcGroup<Rpcs>,
options?: { readonly disableTracing?: boolean | undefined; readonly spanPrefix?: string | undefined } | undefined
) => Effect.Effect<
HttpApp.Default<never, Scope.Scope>,
never,
Scope.Scope | RpcSerialization.RpcSerialization | Rpc.ToHandler<Rpcs> | Rpc.Middleware<Rpcs>
>
Since v1.0.0
toHttpAppWebsocket
Signature
declare const toHttpAppWebsocket: <Rpcs extends Rpc.Any>(
group: RpcGroup.RpcGroup<Rpcs>,
options?: { readonly disableTracing?: boolean | undefined; readonly spanPrefix?: string | undefined } | undefined
) => Effect.Effect<
HttpApp.Default<never, Scope.Scope>,
never,
Scope.Scope | RpcSerialization.RpcSerialization | Rpc.ToHandler<Rpcs> | Rpc.Middleware<Rpcs>
>
Since v1.0.0
protocol
Protocol (class)
Signature
declare class Protocol
Since v1.0.0
layerProtocolHttp
A rpc protocol that uses streaming http for communication.
Signature
declare const layerProtocolHttp: <I = HttpRouter.Default>(options: {
readonly path: HttpRouter.PathInput
readonly routerTag?: HttpRouter.HttpRouter.TagClass<I, string, any, any>
}) => Layer.Layer<Protocol, never, RpcSerialization.RpcSerialization>
Since v1.0.0
layerProtocolSocketServer
A rpc protocol that uses SocketServer
for communication.
Signature
declare const layerProtocolSocketServer: Layer.Layer<Protocol, never, any>
Since v1.0.0
layerProtocolWebsocket
A rpc protocol that uses websockets for communication.
Signature
declare const layerProtocolWebsocket: <I = HttpRouter.Default>(options: {
readonly path: HttpRouter.PathInput
readonly routerTag?: HttpRouter.HttpRouter.TagClass<I, string, any, any>
}) => Layer.Layer<Protocol, never, RpcSerialization.RpcSerialization>
Since v1.0.0
layerProtocolWorkerRunner
Signature
declare const layerProtocolWorkerRunner: Layer.Layer<Protocol, WorkerError, WorkerRunner.PlatformRunner>
Since v1.0.0
makeProtocolHttp
Signature
declare const makeProtocolHttp: any
Since v1.0.0
makeProtocolSocketServer
Signature
declare const makeProtocolSocketServer: any
Since v1.0.0
makeProtocolWebsocket
Signature
declare const makeProtocolWebsocket: <I = HttpRouter.Default>(options: {
readonly path: HttpRouter.PathInput
readonly routerTag?: Context.Tag<I, HttpRouter.HttpRouter.Service<any, any>>
}) => Effect.Effect<Protocol["Type"], never, RpcSerialization.RpcSerialization | I>
Since v1.0.0
makeProtocolWithHttpApp
Signature
declare const makeProtocolWithHttpApp: Effect.Effect<
{ readonly protocol: Protocol["Type"]; readonly httpApp: HttpApp.Default<never, Scope.Scope> },
never,
RpcSerialization.RpcSerialization
>
Since v1.0.0
makeProtocolWithHttpAppWebsocket
Signature
declare const makeProtocolWithHttpAppWebsocket: Effect.Effect<
{ readonly protocol: Protocol["Type"]; readonly httpApp: HttpApp.Default<never, Scope.Scope> },
never,
RpcSerialization.RpcSerialization
>
Since v1.0.0
makeProtocolWorkerRunner
Signature
declare const makeProtocolWorkerRunner: Effect.Effect<any, WorkerError, any>
Since v1.0.0
server
RpcServer (interface)
Signature
export interface RpcServer<A extends Rpc.Any> {
readonly write: (clientId: number, message: FromClient<A>) => Effect.Effect<void>
readonly disconnect: (clientId: number) => Effect.Effect<void>
}
Since v1.0.0
layer
Signature
declare const layer: <Rpcs extends Rpc.Any>(
group: RpcGroup.RpcGroup<Rpcs>,
options?: {
readonly disableTracing?: boolean | undefined
readonly spanPrefix?: string | undefined
readonly concurrency?: number | "unbounded" | undefined
}
) => Layer.Layer<never, never, Protocol | Rpc.ToHandler<Rpcs> | Rpc.Middleware<Rpcs>>
Since v1.0.0
make
Signature
declare const make: <Rpcs extends Rpc.Any>(
group: RpcGroup.RpcGroup<Rpcs>,
options?:
| {
readonly disableTracing?: boolean | undefined
readonly spanPrefix?: string | undefined
readonly concurrency?: number | "unbounded" | undefined
}
| undefined
) => Effect.Effect<never, never, Protocol | Rpc.ToHandler<Rpcs> | Rpc.Middleware<Rpcs>>
Since v1.0.0
makeNoSerialization
Signature
declare const makeNoSerialization: <Rpcs extends Rpc.Any>(
group: RpcGroup.RpcGroup<Rpcs>,
options: {
readonly onFromServer: (response: FromServer<Rpcs>) => Effect.Effect<void>
readonly disableTracing?: boolean | undefined
readonly disableSpanPropagation?: boolean | undefined
readonly spanPrefix?: string | undefined
readonly disableClientAcks?: boolean | undefined
readonly concurrency?: number | "unbounded" | undefined
}
) => Effect.Effect<RpcServer<Rpcs>, never, Rpc.ToHandler<Rpcs> | Rpc.Middleware<Rpcs> | Scope.Scope>
Since v1.0.0