Custom transports
Custom transports and direct execution#
Most applications should use the native HTTP or WebSocket client Layers. SSR, tests, workers, and embedded environments can run the same server path without serialization or network I/O:
const AppClientInProcess = PipelineClient.layerClientInProcess(
AppClient,
AppRpcs,
{
id: "app",
middleware: [PipelineTelemetry.make(), PipelineSql.transaction()]
}
).pipe(Layer.provide(AppLive))
const flags = Effect.gen(function*() {
const rpc = yield* AppClient
return { posts: yield* rpc.listPosts({ limit: 20 }) }
}).pipe(Effect.provide(AppClientInProcess))An in-process client still runs validation, middleware, authentication headers, limits, handlers, batching, and transactions. It executes through the server rather than calling handlers directly.
Streams and persistent capabilities require WebSocket.
Framework adapters can also provide a PipelineTransport directly:
const rpc = yield* PipelineClient.make(AppRpcs, {
id: "app",
transport: (request, options) =>
PipelineServer.handle(AppRpcs, request, {
id: "app",
metadata: {
client: new Rpc.ServerClient(1),
requestId: "local",
headers: options?.headers ?? Headers.empty
}
}).pipe(Effect.provideContext(AppContext))
})This path is useful for unit tests and framework adapters. Native streaming and connection-scoped capabilities require the WebSocket transport.