1import * as sqs from "@distilled.cloud/aws/sqs";
2import * as Effect from "effect/Effect";
3import * as Binding from "../../Binding.ts";
4import type { Queue } from "./Queue.ts";
5
6export interface ChangeMessageVisibilityRequest extends Omit<
7 sqs.ChangeMessageVisibilityRequest,
8 "QueueUrl"
9> {}
10
11/**
12 * Runtime binding for `sqs:ChangeMessageVisibility`.
13 *
14 * Bind this operation to a {@link Queue} inside a function runtime to extend
15 * or shrink the visibility timeout of an in-flight message — e.g. extend it
16 * while a slow job is still processing, or set it to `0` to release the
17 * message back to the queue immediately. The binding grants the host
18 * function `sqs:ChangeMessageVisibility` on the queue. Provide the
19 * `ChangeMessageVisibilityHttp` layer on the Function to implement the
20 * binding.
21 * ### Changing Message Visibility
22 * **Example:** Release a Message Back to the Queue
23 * ```typescript
24 * // init (provide SQS.ChangeMessageVisibilityHttp on the Function)
25 * const changeMessageVisibility = yield* SQS.ChangeMessageVisibility(queue);
26 *
27 * // runtime: make the message immediately receivable again
28 * yield* changeMessageVisibility({
29 * ReceiptHandle: message.ReceiptHandle!,
30 * VisibilityTimeout: 0,
31 * });
32 * ```
33 *
34 * **Example:** Extend Processing Time for a Slow Job
35 * ```typescript
36 * yield* changeMessageVisibility({
37 * ReceiptHandle: message.ReceiptHandle!,
38 * VisibilityTimeout: 600,
39 * });
40 * ```
41 *
42 * @binding
43 */
44export interface ChangeMessageVisibility extends Binding.Service<
45 ChangeMessageVisibility,
46 "AWS.SQS.ChangeMessageVisibility",
47 (
48 queue: Queue,
49 ) => Effect.Effect<
50 (
51 request: ChangeMessageVisibilityRequest,
52 ) => Effect.Effect<
53 sqs.ChangeMessageVisibilityResponse,
54 sqs.ChangeMessageVisibilityError
55 >
56 >
57> {}
58
59export const ChangeMessageVisibility = Binding.Service<ChangeMessageVisibility>(
60 "AWS.SQS.ChangeMessageVisibility",
61);