| 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 ChangeMessageVisibilityBatchRequest extends Omit< |
| 7 | sqs.ChangeMessageVisibilityBatchRequest, |
| 8 | "QueueUrl" |
| 9 | > {} |
| 10 | |
| 11 | /** |
| 12 | * Runtime binding for `sqs:ChangeMessageVisibilityBatch`. |
| 13 | * |
| 14 | * Bind this operation to a {@link Queue} inside a function runtime to change |
| 15 | * the visibility timeout of up to 10 in-flight messages per call with |
| 16 | * per-entry success/failure results. The binding grants the host function |
| 17 | * `sqs:ChangeMessageVisibility` on the queue. Provide the |
| 18 | * `ChangeMessageVisibilityBatchHttp` layer on the Function to implement the |
| 19 | * binding. |
| 20 | * ### Changing Message Visibility |
| 21 | * **Example:** Release a Batch of Messages Back to the Queue |
| 22 | * ```typescript |
| 23 | * // init (provide SQS.ChangeMessageVisibilityBatchHttp on the Function) |
| 24 | * const changeMessageVisibilityBatch = |
| 25 | * yield* SQS.ChangeMessageVisibilityBatch(queue); |
| 26 | * |
| 27 | * // runtime |
| 28 | * const result = yield* changeMessageVisibilityBatch({ |
| 29 | * Entries: messages.map((message, index) => ({ |
| 30 | * Id: `${index}`, |
| 31 | * ReceiptHandle: message.ReceiptHandle!, |
| 32 | * VisibilityTimeout: 0, |
| 33 | * })), |
| 34 | * }); |
| 35 | * // result.Successful / result.Failed |
| 36 | * ``` |
| 37 | * |
| 38 | * @binding |
| 39 | */ |
| 40 | export interface ChangeMessageVisibilityBatch extends Binding.Service< |
| 41 | ChangeMessageVisibilityBatch, |
| 42 | "AWS.SQS.ChangeMessageVisibilityBatch", |
| 43 | ( |
| 44 | queue: Queue, |
| 45 | ) => Effect.Effect< |
| 46 | ( |
| 47 | request: ChangeMessageVisibilityBatchRequest, |
| 48 | ) => Effect.Effect< |
| 49 | sqs.ChangeMessageVisibilityBatchResult, |
| 50 | sqs.ChangeMessageVisibilityBatchError |
| 51 | > |
| 52 | > |
| 53 | > {} |
| 54 | |
| 55 | export const ChangeMessageVisibilityBatch = |
| 56 | Binding.Service<ChangeMessageVisibilityBatch>( |
| 57 | "AWS.SQS.ChangeMessageVisibilityBatch", |
| 58 | ); |