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
| 1 | import * as Layer from "effect/Layer"; |
| 2 | import { QueueSinkFromWriteQueue } from "./QueueSinkBatch.ts"; |
| 3 | import { WriteQueueLocal } from "./WriteQueueLocal.ts"; |
| 4 | |
| 5 | /** |
| 6 | * Implementation of the {@link QueueSink} service that pushes over the |
| 7 | * Queues bulk-push HTTP API with the **current credentials** |
| 8 | * ({@link WriteQueueLocal}) — for draining a Stream into a queue from an |
| 9 | * Action or other deploy-time Effect, with no Worker host. |
| 10 | * ### Providing the Layer |
| 11 | * **Example:** Seed a queue from an Action |
| 12 | * ```typescript |
| 13 | * const Seed = Alchemy.Action( |
| 14 | * "Seed", |
| 15 | * Effect.gen(function* () { |
| 16 | * const sink = yield* Cloudflare.Queues.QueueSink(queue); |
| 17 | * return Effect.fn(function* () { |
| 18 | * yield* Stream.range(1, 500).pipe( |
| 19 | * Stream.map((id) => ({ event: "seed", id })), |
| 20 | * Stream.run(sink), |
| 21 | * ); |
| 22 | * }); |
| 23 | * }).pipe(Effect.provide(Cloudflare.Queues.QueueSinkLocal)), |
| 24 | * ); |
| 25 | * ``` |
| 26 | * |
| 27 | * @layer |
| 28 | * @provides Cloudflare.Queues.QueueSink |
| 29 | * @product Queues |
| 30 | * @category Storage & Databases |
| 31 | */ |
| 32 | export const QueueSinkLocal = QueueSinkFromWriteQueue.pipe(Layer.provide(WriteQueueLocal)); |