HTTP

Remote client

Provide stream services from a remote Durable Streams host with the remote Layer.

RemoteStreams.layer(group, options) gives the stream services of a group from a remote host.

import { Layer } from "effect";
import { FetchHttpClient } from "effect/http";
import { RemoteStreams } from "@streamsy/core/remote";
import { game } from "./streams.ts";

const remote = RemoteStreams.layer(game, {
  baseUrl: "https://streams.example.com/streams",
  capabilities: { expectedOffset: true, producer: true },
}).pipe(Layer.provide(FetchHttpClient.layer));

A program runs over remote with no change.

Options

OptionValue
baseUrlThe protocol prefix of the host
headersHeaders for each request
capabilities.expectedOffsetSends Stream-Expected-Offset
capabilities.producerSends the producer headers

Capabilities are statements about the host. The Layer does not discover them.

Limits

FeatureOver remote
WritesNeed append or full access on the host
Projection.followWorks. One poll for each input, bounded by repairIntervalMs (default 30 s)
Projection inputs and outputsInputs work with any Commit; existing remote outputs work with Commit.producer
CheckpointStoreProvide a standalone store, such as CheckpointStore.layerMemory

RemoteStreams.layerProtocol(options) gives the generic reader and writer, for protocol tools.

Browsers

Browser applications use the Durable Streams TypeScript client and @durable-streams/state.

On this page