1 | import { ConsumerOptions, StopOptions, UpdatableOptions } from "./types.js";
|
2 | import { TypedEventEmitter } from "./emitter.js";
|
3 | /**
|
4 | * [Usage](https://bbc.github.io/sqs-consumer/index.html#usage)
|
5 | */
|
6 | export declare class Consumer extends TypedEventEmitter {
|
7 | private pollingTimeoutId;
|
8 | private stopped;
|
9 | private queueUrl;
|
10 | private handleMessage;
|
11 | private handleMessageBatch;
|
12 | private preReceiveMessageCallback?;
|
13 | private postReceiveMessageCallback?;
|
14 | private sqs;
|
15 | private handleMessageTimeout;
|
16 | private attributeNames;
|
17 | private messageAttributeNames;
|
18 | private shouldDeleteMessages;
|
19 | private alwaysAcknowledge;
|
20 | private batchSize;
|
21 | private visibilityTimeout;
|
22 | private terminateVisibilityTimeout;
|
23 | private waitTimeSeconds;
|
24 | private authenticationErrorTimeout;
|
25 | private pollingWaitTimeMs;
|
26 | private pollingCompleteWaitTimeMs;
|
27 | private heartbeatInterval;
|
28 | private isPolling;
|
29 | private stopRequestedAtTimestamp;
|
30 | abortController: AbortController;
|
31 | private extendedAWSErrors;
|
32 | constructor(options: ConsumerOptions);
|
33 | /**
|
34 | * Creates a new SQS consumer.
|
35 | */
|
36 | static create(options: ConsumerOptions): Consumer;
|
37 | /**
|
38 | * Start polling the queue for messages.
|
39 | */
|
40 | start(): void;
|
41 | /**
|
42 | * A reusable options object for sqs.send that's used to avoid duplication.
|
43 | */
|
44 | private get sqsSendOptions();
|
45 | /**
|
46 | * Stop polling the queue for messages (pre existing requests will still be made until concluded).
|
47 | */
|
48 | stop(options?: StopOptions): void;
|
49 | /**
|
50 | * Wait for final poll and in flight messages to complete.
|
51 | * @private
|
52 | */
|
53 | private waitForPollingToComplete;
|
54 | /**
|
55 | * Returns the current status of the consumer.
|
56 | * This includes whether it is running or currently polling.
|
57 | */
|
58 | get status(): {
|
59 | isRunning: boolean;
|
60 | isPolling: boolean;
|
61 | };
|
62 | /**
|
63 | * Validates and then updates the provided option to the provided value.
|
64 | * @param option The option to validate and then update
|
65 | * @param value The value to set the provided option to
|
66 | */
|
67 | updateOption(option: UpdatableOptions, value: ConsumerOptions[UpdatableOptions]): void;
|
68 | /**
|
69 | * Emit one of the consumer's error events depending on the error received.
|
70 | * @param err The error object to forward on
|
71 | * @param message The message that the error occurred on
|
72 | */
|
73 | private emitError;
|
74 | /**
|
75 | * Poll for new messages from SQS
|
76 | */
|
77 | private poll;
|
78 | /**
|
79 | * Send a request to SQS to retrieve messages
|
80 | * @param params The required params to receive messages from SQS
|
81 | */
|
82 | private receiveMessage;
|
83 | /**
|
84 | * Handles the response from AWS SQS, determining if we should proceed to
|
85 | * the message handler.
|
86 | * @param response The output from AWS SQS
|
87 | */
|
88 | private handleSqsResponse;
|
89 | /**
|
90 | * Process a message that has been received from SQS. This will execute the message
|
91 | * handler and delete the message once complete.
|
92 | * @param message The message that was delivered from SQS
|
93 | */
|
94 | private processMessage;
|
95 | /**
|
96 | * Process a batch of messages from the SQS queue.
|
97 | * @param messages The messages that were delivered from SQS
|
98 | */
|
99 | private processMessageBatch;
|
100 | /**
|
101 | * Trigger a function on a set interval
|
102 | * @param heartbeatFn The function that should be triggered
|
103 | */
|
104 | private startHeartbeat;
|
105 | /**
|
106 | * Change the visibility timeout on a message
|
107 | * @param message The message to change the value of
|
108 | * @param timeout The new timeout that should be set
|
109 | */
|
110 | private changeVisibilityTimeout;
|
111 | /**
|
112 | * Change the visibility timeout on a batch of messages
|
113 | * @param messages The messages to change the value of
|
114 | * @param timeout The new timeout that should be set
|
115 | */
|
116 | private changeVisibilityTimeoutBatch;
|
117 | /**
|
118 | * Trigger the applications handleMessage function
|
119 | * @param message The message that was received from SQS
|
120 | */
|
121 | private executeHandler;
|
122 | /**
|
123 | * Execute the application's message batch handler
|
124 | * @param messages The messages that should be forwarded from the SQS queue
|
125 | */
|
126 | private executeBatchHandler;
|
127 | /**
|
128 | * Delete a single message from SQS
|
129 | * @param message The message to delete from the SQS queue
|
130 | */
|
131 | private deleteMessage;
|
132 | /**
|
133 | * Delete a batch of messages from the SQS queue.
|
134 | * @param messages The messages that should be deleted from SQS
|
135 | */
|
136 | private deleteMessageBatch;
|
137 | }
|