| 1 | import * as sqs from "@distilled.cloud/aws/sqs"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { Queue } from "./Queue.ts"; |
| 5 | |
| 6 | export interface DeleteMessageBatchRequest extends Omit< |
| 7 | sqs.DeleteMessageBatchRequest, |
| 8 | "QueueUrl" |
| 9 | > {} |
| 10 | |
| 11 | /** |
| 12 | * Runtime binding for `sqs:DeleteMessageBatch`. |
| 13 | * |
| 14 | * Bind this operation to a {@link Queue} inside a function runtime to delete |
| 15 | * up to 10 received messages per call with per-entry success/failure results. |
| 16 | * The binding grants the host function `sqs:DeleteMessage` on the queue. |
| 17 | * Provide the `DeleteMessageBatchHttp` layer on the Function to implement the |
| 18 | * binding. |
| 19 | * ### Deleting Message Batches |
| 20 | * **Example:** Delete a Batch of Processed Messages |
| 21 | * ```typescript |
| 22 | * // init (provide SQS.DeleteMessageBatchHttp on the Function) |
| 23 | * const deleteMessageBatch = yield* SQS.DeleteMessageBatch(queue); |
| 24 | * |
| 25 | * // runtime: acknowledge messages received via ReceiveMessage |
| 26 | * const result = yield* deleteMessageBatch({ |
| 27 | * Entries: messages.map((message, index) => ({ |
| 28 | * Id: `${index}`, |
| 29 | * ReceiptHandle: message.ReceiptHandle!, |
| 30 | * })), |
| 31 | * }); |
| 32 | * // result.Successful / result.Failed |
| 33 | * ``` |
| 34 | * |
| 35 | * @binding |
| 36 | */ |
| 37 | export interface DeleteMessageBatch extends Binding.Service< |
| 38 | DeleteMessageBatch, |
| 39 | "AWS.SQS.DeleteMessageBatch", |
| 40 | ( |
| 41 | queue: Queue, |
| 42 | ) => Effect.Effect< |
| 43 | ( |
| 44 | request: DeleteMessageBatchRequest, |
| 45 | ) => Effect.Effect< |
| 46 | sqs.DeleteMessageBatchResult, |
| 47 | sqs.DeleteMessageBatchError |
| 48 | > |
| 49 | > |
| 50 | > {} |
| 51 | |
| 52 | export const DeleteMessageBatch = Binding.Service<DeleteMessageBatch>( |
| 53 | "AWS.SQS.DeleteMessageBatch", |
| 54 | ); |