The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as Lambda from "@alchemy.run/aws/Lambda"; |
| 2 | import * as SQS from "@alchemy.run/aws/SQS"; |
| 3 | import * as Duration from "effect/Duration"; |
| 4 | import * as Effect from "effect/Effect"; |
| 5 | import * as HttpServerResponse from "effect/http/HttpServerResponse"; |
| 6 | import * as Layer from "effect/Layer"; |
| 7 | |
| 8 | // A 30-second Function reading a queue left at SQS's 30-second default |
| 9 | // visibility timeout. Lambda runs it for 31 seconds (`timeoutMargin`), which |
| 10 | // AWS refuses for an SQS event source. |
| 11 | export class EventSourceMappingVisibilityFunction extends Lambda.Function<EventSourceMappingVisibilityFunction>()( |
| 12 | "EventSourceMappingVisibilityFunction", |
| 13 | ) {} |
| 14 | |
| 15 | export default EventSourceMappingVisibilityFunction.make( |
| 16 | { |
| 17 | main: import.meta.url, |
| 18 | functionUrl: false, |
| 19 | timeout: Duration.seconds(30), |
| 20 | }, |
| 21 | Effect.gen(function* () { |
| 22 | const queue = yield* SQS.Queue("EventSourceMappingVisibilityQueue"); |
| 23 | |
| 24 | yield* SQS.consumeQueueMessages(queue, () => Effect.void); |
| 25 | |
| 26 | return { |
| 27 | fetch: Effect.gen(function* () { |
| 28 | return HttpServerResponse.text("ok"); |
| 29 | }).pipe(Effect.orDie), |
| 30 | }; |
| 31 | }).pipe(Effect.provide(Layer.mergeAll(Lambda.QueueEventSource))), |
| 32 | ); |