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, 06:00 UTC
| 1 | import * as Lambda from "@alchemy.run/aws/Lambda"; |
| 2 | import * as SQS from "@alchemy.run/aws/SQS"; |
| 3 | import * as Effect from "effect/Effect"; |
| 4 | import * as HttpServerResponse from "effect/http/HttpServerResponse"; |
| 5 | import * as Layer from "effect/Layer"; |
| 6 | |
| 7 | // One Function whose queue switches between standard and FIFO across deploys. |
| 8 | // Switching `fifo` replaces the queue, so the second deploy must move the |
| 9 | // EventSourceMapping onto the new queue. |
| 10 | export class EventSourceMappingReplaceFunction extends Lambda.Function<EventSourceMappingReplaceFunction>()( |
| 11 | "EventSourceMappingReplaceFunction", |
| 12 | ) {} |
| 13 | |
| 14 | const make = (fifo: boolean) => |
| 15 | EventSourceMappingReplaceFunction.make( |
| 16 | { |
| 17 | main: import.meta.url, |
| 18 | functionUrl: false, |
| 19 | }, |
| 20 | Effect.gen(function* () { |
| 21 | const queue = yield* SQS.Queue("EventSourceMappingReplaceQueue", fifo ? { fifo: true } : {}); |
| 22 | |
| 23 | yield* SQS.consumeQueueMessages(queue, () => Effect.void); |
| 24 | |
| 25 | return { |
| 26 | fetch: Effect.gen(function* () { |
| 27 | return HttpServerResponse.text("ok"); |
| 28 | }).pipe(Effect.orDie), |
| 29 | }; |
| 30 | }).pipe(Effect.provide(Layer.mergeAll(Lambda.QueueEventSource))), |
| 31 | ); |
| 32 | |
| 33 | export const StandardQueueLive = make(false); |
| 34 | export const FifoQueueLive = make(true); |
| 35 | |
| 36 | export default StandardQueueLive; |