sailfork / t3code-github / .repos/ alchemy-effect/ packages/ aws/ src/ SQS/ PurgeQueue.ts

import type * as sqs from "@distilled.cloud/aws/sqs";
import * as Binding from "alchemy/Binding";
import * as Effect from "effect/Effect";
import type { Queue } from "./Queue.ts";

/**
 * Runtime binding for `sqs:PurgeQueue`.
 *
 * Bind this operation to a {@link Queue} inside a function runtime to delete
 * every message in the queue in one call. The purge takes up to 60 seconds
 * to complete, and only one purge per queue is allowed every 60 seconds
 * (a second call fails with the typed `PurgeQueueInProgress` error). The
 * binding grants the host function `sqs:PurgeQueue` on the queue. Provide
 * the `PurgeQueueHttp` layer on the Function to implement the binding.
 * ### Purging a Queue
 * **Example:** Purge All Messages
 * ```typescript
 * // init (provide SQS.PurgeQueueHttp on the Function)
 * const purgeQueue = yield* SQS.PurgeQueue(queue);
 *
 * // runtime: drop everything currently in the queue
 * yield* purgeQueue();
 * ```
 *
 * @binding
 */
export interface PurgeQueue extends Binding.Service<
  PurgeQueue,
  "AWS.SQS.PurgeQueue",
  (queue: Queue) => Effect.Effect<() => Effect.Effect<sqs.PurgeQueueResponse, sqs.PurgeQueueError>>
> {}

export const PurgeQueue = Binding.Service<PurgeQueue>("AWS.SQS.PurgeQueue");