sqs-producer
Version:
Enqueues messages onto a given SQS queue
41 lines (40 loc) • 1.58 kB
TypeScript
import { SQSClient, type SendMessageBatchResultEntry } from "@aws-sdk/client-sqs";
import type { Message, ProducerOptions } from "./types.js";
/**
* [Usage](https://bbc.github.io/sqs-producer/index.html#usage)
*/
export declare class Producer {
static create: (options: ProducerOptions) => Producer;
queueUrl: string;
batchSize: number;
sqs: SQSClient;
region?: string;
constructor(options: ProducerOptions);
/**
* Returns the number of messages in the queue.
* @returns A promise that resolves to the number of messages in the queue.
*/
queueSize(): Promise<number>;
/**
* Send a message to the queue.
* @param messages - A single message or an array of messages.
* @returns A promise that resolves to the result of the send operation.
*/
send(messages: string | Message | (string | Message)[]): Promise<SendMessageBatchResultEntry[]>;
/**
* Validate the producer options.
* @param options - The producer options to validate.
* @throws Error if any required options are missing or invalid.
*/
private validate;
/**
* Send a batch of messages to the queue.
* @param failedMessages - An array of failed message IDs.
* @param successfulMessages - An array of successful message results.
* @param messages - An array of messages to send.
* @param startIndex - The index of the first message in the batch.
* @returns A promise that resolves to the result of the send operation.
* @throws FailedMessagesError
*/
private sendBatch;
}