Overview
Streamsy is an Effect implementation of the Durable Streams protocol, with typed streams, projections, and hosts for Bun and Cloudflare.
Streamsy is an Effect implementation of the Durable Streams protocol.
import { Effect, Schema, Stream } from "effect";
import { MemoryStorage, Streamsy } from "@streamsy/core";
class Notes extends Streamsy.json<Notes>()("App/Notes", "notes", {
params: {},
schema: Schema.Struct({ text: Schema.String }),
}) {}
const program = Effect.gen(function* () {
const notes = yield* Notes;
yield* notes.create({});
yield* notes.append({}, [{ text: "hello" }]);
return yield* notes.read({}).pipe(
Stream.flatMap((batch) => Stream.fromIterable(batch.items)),
Stream.runCollect,
);
});
await Effect.runPromise(program.pipe(Effect.provide(MemoryStorage.layer(Streamsy.group(Notes)))));The stream class is a service key. The program asks for the service, and the Layer decides where the streams are kept.
Packages
| Package | Contents |
|---|---|
@streamsy/core | Stream classes, groups, the memory Layer, protocol routes, the remote Layer |
@streamsy/storage | SQLite storage for Bun and for Durable Objects |
@streamsy/projection | Checkpointed projections over one or more streams |
@streamsy/serve | Serve routes, Bun and Cloudflare hosts, and the action outbox |
Sections
| Section | Contents |
|---|---|
| Tutorial | One small application, from a stream to a deploy |
| Streams | Declare, create, read, and write streams |
| Projections | Derive streams and state from other streams |
| HTTP | Protocol routes, Serve routes, the remote client |
| Hosting | Layers, storage, Bun, and Cloudflare |
| Demos | Runnable example applications |
Effect runs on the server. In the browser, use the Durable Streams TypeScript client.