@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, 03:37 UTC

main
ts 60 lines 1.93 KB
Raw
1 import * as sqs from "@distilled.cloud/aws/sqs";
2 import * as Binding from "alchemy/Binding";
3 import * as Effect from "effect/Effect";
4 import type { Queue } from "./Queue.ts";
5
6 export interface SendMessageRequest extends Omit<sqs.SendMessageRequest, "QueueUrl"> {}
7
8 /**
9 * Runtime binding for `sqs:SendMessage`.
10 *
11 * Bind this operation to a {@link Queue} inside a function runtime to get a
12 * callable that automatically injects the `QueueUrl`. The binding grants the
13 * host function `sqs:SendMessage` on the queue. Provide the `SendMessageHttp`
14 * layer on the Function to implement the binding.
15 * ### Sending Messages
16 * **Example:** Send a Message from a Lambda Function
17 * ```typescript
18 * export class ApiFunction extends Lambda.Function<Lambda.Function>()(
19 * "ApiFunction",
20 * ) {}
21 *
22 * export default ApiFunction.make(
23 * { main: import.meta.url, functionUrl: true },
24 * Effect.gen(function* () {
25 * const queue = yield* SQS.Queue("Jobs");
26 *
27 * // init: bind the operation to the queue (grants sqs:SendMessage)
28 * const sendMessage = yield* SQS.SendMessage(queue);
29 *
30 * return {
31 * fetch: Effect.gen(function* () {
32 * // runtime: QueueUrl is injected automatically
33 * const result = yield* sendMessage({ MessageBody: "hello" });
34 * return yield* HttpServerResponse.json({
35 * messageId: result.MessageId,
36 * });
37 * }).pipe(Effect.orDie),
38 * };
39 * }).pipe(Effect.provide(SQS.SendMessageHttp)),
40 * );
41 * ```
42 *
43 * **Example:** Delay Delivery
44 * ```typescript
45 * yield* sendMessage({ MessageBody: "process later", DelaySeconds: 60 });
46 * ```
47 *
48 * @binding
49 */
50 export interface SendMessage extends Binding.Service<
51 SendMessage,
52 "AWS.SQS.SendMessage",
53 (
54 queue: Queue,
55 ) => Effect.Effect<
56 (request: SendMessageRequest) => Effect.Effect<sqs.SendMessageResult, sqs.SendMessageError>
57 >
58 > {}
59
60 export const SendMessage = Binding.Service<SendMessage>("AWS.SQS.SendMessage");