Scott Swarthout

effect-rpc-pipeline

A TypeScript library for composing dependent Effect RPC calls into a single network request.

Use the arrow keys to move a light. Press Escape to return the lights to their starting positions.

When one API call needs the result of another, a client typically waits for the first response before sending the next request. This library lets the client express that dependency in a typed pipeline. The server executes the sequence using the application’s existing schemas and handlers.

Two lookups in one round trip

In this example, the profile lookup requires a user ID. The pipeline passes the ID directly from the user handler to the profile handler on the server.

Sequential · 2 network round trips

  1. Fetch userAsk the server for the user.
  2. Receive user IDRead the ID from the response.
  3. Fetch profileSend the ID in a second request.

Pipelined · 1 network round trip

  1. Send both callsSpecify that the second call needs the ID from the first.
  2. Resolve on the serverThe profile handler gets the user ID.
  3. Return selected fieldsRead the requested fields in one response.

A pipeline can include independent calls as well. Each handler still controls its own database access, so developers can batch database reads separately.