Overview
Streamsy is a toolkit for working with Durable Streams in Effect
Streamsy is an Effect implementation of the Durable Streams protocol:
- Declare byte, json or state streams.
- Create, Read and Append with effects.
- Checkpointed reads with Projections
- Provide storage via layers
- Serve the http 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)))));Install
The example above needs only @streamsy/core and effect. Streamsy requires Effect 4.
bun add @streamsy/core effectWhere Next?
| Section | Contents |
|---|---|
| Streams | Declare, create, read, and write streams |
| Projections | Derive streams and state from other streams |
| Storage | Choose a storage Layer, use SQLite, or write a storage adapter |
| Servers and clients | Serve streams over HTTP, connect to a server, and run a server |
| Reference | Every export, by package |
| Examples | Runnable example applications |