Skip to Content
Servers and clients

Servers and clients

The pieces that expose stream services over HTTP, consume them from another program, and run the server.

A Streamsy server is three separate choices. The storage Layer provides the stream services. HTTP routes expose some of those services at URLs. A runtime owns the listener or the Worker entry point, the lifetime of the services, and background work. A client is a program that gets its stream services from a server instead of from local storage.

Application program → stream services → local storage Layer
                                     or → RemoteStreams.layer → an existing server

HTTP request → Http.routes or Serve routes → stream services

Runtime → listener or Worker entry point + service lifetime + background work

Two server interfaces

InterfacePackageServesGuide
Http.routes(group, options)@streamsy/coreThe Durable Streams protocol for every stream in a group: create, append, read, and removeExpose the stream protocol
Serve.stream, Serve.state, Serve.value@streamsy/serveRead-only endpoints at application URLs: one stream, one Durable State change feed, or one computed valueServe application reads

Both are Effect HttpRouter route Layers. A server can merge both with Layer.mergeAll, and each needs the stream services of the streams that it reads. Neither creates a stream, runs a projection, or authenticates a caller.

Clients

ClientUsesGuide
An Effect program with RemoteStreams.layerThe protocol routesConnect to a remote server
A browser app with the Durable Streams clientThe protocol routesBrowsers
A browser app that reads Serve endpointsServe routesBrowser clients and CORS

A remote Effect program uses the same stream classes as the server, and its code does not change. A browser app does not load the server's Effect services. It reads the wire format through @durable-streams/client or @durable-streams/state.

Runtimes

RuntimeOwnsGuide
Bun, Node, or Deno processA listener, one scope for storage and background fibers, and a drain at shutdownRun a process server
CloudflareA Worker router, and Durable Objects that each own their storage, routes, and alarmRun on Cloudflare

A process runs until a signal stops it, so it can keep a follow fiber or a delivery loop running. A Durable Object gets no stop signal and can be evicted between requests. It runs background work in alarm turns instead. See Schedule work with alarms.

The routes and the storage contract are the same on every runtime. Only the composition around them changes.

Pick a guide

TaskGuide
Let protocol clients create, append, and read streamsExpose the stream protocol
Give a browser one feed, one state, or one value at an app URLServe application reads
Use another server's streams from an Effect programConnect to a remote server
Start and stop a server on Bun, Node, or DenoRun a process server
Run the routes in a Worker and Durable ObjectsRun on Cloudflare
Run projections or deliveries with no request in flight on CloudflareSchedule work with alarms
Use a stream that another Durable Object ownsConnect Durable Objects
Choose where the data livesChoose storage

On this page