@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 32 lines 1.12 KB
Raw
1 import * as Layer from "effect/Layer";
2 import { StreamSinkFromWriteStream } from "./StreamSinkBatch.ts";
3 import { WriteStreamLocal } from "./WriteStreamLocal.ts";
4
5 /**
6 * Implementation of the {@link StreamSink} service that appends over the
7 * stream's HTTP input with the **current credentials**
8 * ({@link WriteStreamLocal}) — for draining a Stream into K2 from an Action
9 * or other deploy-time Effect. The stream needs `http: true`.
10 * ### Providing the Layer
11 * **Example:** Seed a stream from an Action
12 * ```typescript
13 * const Seed = Alchemy.Action(
14 * "Seed",
15 * Effect.gen(function* () {
16 * const sink = yield* Cloudflare.K2.StreamSink(Orders);
17 * return Effect.fn(function* () {
18 * yield* Stream.range(1, 500).pipe(
19 * Stream.map((id) => ({ content: JSON.stringify({ id }) })),
20 * Stream.run(sink),
21 * );
22 * });
23 * }).pipe(Effect.provide(Cloudflare.K2.StreamSinkLocal)),
24 * );
25 * ```
26 *
27 * @layer
28 * @provides Cloudflare.K2.StreamSink
29 * @product K2
30 * @category Storage & Databases
31 */
32 export const StreamSinkLocal = StreamSinkFromWriteStream.pipe(Layer.provide(WriteStreamLocal));