@aws-sdk/lib-sqs 0.0.0-stage → 3.1159.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-cjs/index.js +712 -0
- package/dist-es/Message.js +42 -0
- package/dist-es/SQSPoller.js +630 -0
- package/dist-es/errors.js +32 -0
- package/dist-es/index.js +3 -0
- package/dist-es/types.js +1 -0
- package/dist-types/Message.d.ts +52 -0
- package/dist-types/SQSPoller.d.ts +92 -0
- package/dist-types/errors.d.ts +45 -0
- package/dist-types/index.d.ts +28 -0
- package/dist-types/ts3.4/Message.d.ts +29 -0
- package/dist-types/ts3.4/SQSPoller.d.ts +61 -0
- package/dist-types/ts3.4/errors.d.ts +45 -0
- package/dist-types/ts3.4/index.d.ts +11 -0
- package/dist-types/ts3.4/types.d.ts +83 -0
- package/dist-types/types.d.ts +236 -0
- package/package.json +59 -4
- package/README.md +0 -3
package/dist-es/index.js
ADDED
package/dist-es/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Message as SQSMessage, MessageAttributeValue, MessageSystemAttributeName } from "@aws-sdk/client-sqs";
|
|
2
|
+
import type { PollerMessage } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Callbacks the poller injects so Message can perform SQS operations
|
|
5
|
+
* without holding a reference to the client.
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export interface MessageCallbacks {
|
|
9
|
+
enqueueDelete: (msg: Message) => void;
|
|
10
|
+
keep: (receiptHandle: string) => void;
|
|
11
|
+
release: (receiptHandle: string) => Promise<void>;
|
|
12
|
+
changeVisibility: (receiptHandle: string, timeoutMs: number) => Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Wrapper around an SQS `Message` with convenience methods.
|
|
16
|
+
*
|
|
17
|
+
* Instances are created internally by {@link SQSPoller}. Consumers
|
|
18
|
+
* should not instantiate this class directly.
|
|
19
|
+
*
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
export declare class Message implements PollerMessage {
|
|
23
|
+
readonly raw: SQSMessage;
|
|
24
|
+
readonly body: string | undefined;
|
|
25
|
+
readonly messageId: string;
|
|
26
|
+
readonly receiptHandle: string;
|
|
27
|
+
readonly attributes: Partial<Record<MessageSystemAttributeName, string>>;
|
|
28
|
+
readonly messageAttributes: Record<string, MessageAttributeValue>;
|
|
29
|
+
readonly receivedAt: Date;
|
|
30
|
+
private readonly _callbacks;
|
|
31
|
+
private _handled;
|
|
32
|
+
/**
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
constructor(raw: SQSMessage, callbacks: MessageCallbacks);
|
|
36
|
+
/**
|
|
37
|
+
* Whether `enqueueDelete`, `keep`, or `release` has already run.
|
|
38
|
+
* @internal
|
|
39
|
+
*/
|
|
40
|
+
get handled(): boolean;
|
|
41
|
+
/** Queue this message for batch deletion. */
|
|
42
|
+
enqueueDelete(): void;
|
|
43
|
+
/** Acknowledge the message without deleting it from the queue. */
|
|
44
|
+
keep(): void;
|
|
45
|
+
/** Release the message back to the queue immediately (visibility → 0). */
|
|
46
|
+
release(): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Change the visibility timeout of this message. Stops automatic extension for it.
|
|
49
|
+
* @param timeoutMs - New visibility timeout, rounded up to whole seconds for SQS.
|
|
50
|
+
*/
|
|
51
|
+
changeVisibility(timeoutMs: number): Promise<void>;
|
|
52
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { PollerConfig, PollerStats, SerializablePollerStats, SQSPollerEvents, SQSPollerEventName, PollerMessage } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Managed long-polling loop for SQS queues with auto-delete, backoff,
|
|
4
|
+
* visibility heartbeat, and graceful shutdown.
|
|
5
|
+
*
|
|
6
|
+
* Two consumption models (mutually exclusive):
|
|
7
|
+
* 1. Event-based: `poller.on("message", handler); poller.start();`
|
|
8
|
+
* 2. Async iteration: `for await (const msg of poller) { ... }`
|
|
9
|
+
*
|
|
10
|
+
* In async iteration, each message is auto-deleted when the loop advances. Exiting
|
|
11
|
+
* early (`break`, `return`, or a throw) leaves the current message undeleted; call
|
|
12
|
+
* `msg.enqueueDelete()` first if it was processed.
|
|
13
|
+
*
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export declare class SQSPoller implements AsyncIterable<PollerMessage> {
|
|
17
|
+
private readonly _client;
|
|
18
|
+
private readonly _config;
|
|
19
|
+
private readonly _stats;
|
|
20
|
+
private _run;
|
|
21
|
+
private readonly _externalSignal?;
|
|
22
|
+
private _deleteBatch;
|
|
23
|
+
private _deleteTimer;
|
|
24
|
+
private _pendingFlushes;
|
|
25
|
+
private readonly _heartbeatTimers;
|
|
26
|
+
private readonly _heartbeatsInFlight;
|
|
27
|
+
private readonly _listeners;
|
|
28
|
+
constructor(config: PollerConfig);
|
|
29
|
+
get running(): boolean;
|
|
30
|
+
get inFlight(): number;
|
|
31
|
+
getStats(): Readonly<PollerStats>;
|
|
32
|
+
toJSON(): SerializablePollerStats;
|
|
33
|
+
toString(): string;
|
|
34
|
+
/** Register a listener. Returns a function that removes it. */
|
|
35
|
+
on<K extends SQSPollerEventName>(event: K, listener: SQSPollerEvents[K]): () => void;
|
|
36
|
+
/** Remove a listener, or all listeners for an event if `listener` is omitted. */
|
|
37
|
+
off<K extends SQSPollerEventName>(event: K, listener?: SQSPollerEvents[K]): this;
|
|
38
|
+
/** Start polling. Non-blocking. */
|
|
39
|
+
start(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Stop polling, and resolve once this run has shut down.
|
|
42
|
+
*
|
|
43
|
+
* @param graceful - When `true`, waits up to `shutdownTimeoutMs` for in-flight work (handlers
|
|
44
|
+
* in event mode, or the current loop body in async iteration), then flushes pending deletes.
|
|
45
|
+
* When `false`, stops without waiting; calling it during a graceful shutdown cuts that short.
|
|
46
|
+
* Don't `await` this from inside a `message` handler or a `for await` body, since shutdown
|
|
47
|
+
* waits for that work to finish. Use `void poller.stop()`, or `break`, instead.
|
|
48
|
+
* @returns The final stats. Does nothing if the poller isn't running.
|
|
49
|
+
*/
|
|
50
|
+
stop(graceful?: boolean): Promise<PollerStats>;
|
|
51
|
+
/**
|
|
52
|
+
* Exiting the loop early (`break`, `return`, or a throw) does not auto-delete the
|
|
53
|
+
* current message, since the three are indistinguishable here. Call
|
|
54
|
+
* `msg.enqueueDelete()` before exiting if the message was processed.
|
|
55
|
+
*/
|
|
56
|
+
[Symbol.asyncIterator](): AsyncGenerator<PollerMessage, void, undefined>;
|
|
57
|
+
private _iterate;
|
|
58
|
+
private _assertCanStart;
|
|
59
|
+
/** A run started while the previous one is still shutting down waits for it to finish. */
|
|
60
|
+
private _beginRun;
|
|
61
|
+
private _teardown;
|
|
62
|
+
/** Resolves with how `work` ended: finished, timed out after shutdownTimeoutMs, or cut short by stop(false). */
|
|
63
|
+
private _waitFor;
|
|
64
|
+
private _waitForDrain;
|
|
65
|
+
private _emitShutdownTimeout;
|
|
66
|
+
private _pollLoop;
|
|
67
|
+
private _processMessage;
|
|
68
|
+
/** Returns false if `beforeRequest` threw or rejected, which stops the run. */
|
|
69
|
+
private _runBeforeRequest;
|
|
70
|
+
/** Returns true if the idle timeout was reached, which stops the run. */
|
|
71
|
+
private _handleEmpty;
|
|
72
|
+
private _handlePollError;
|
|
73
|
+
private _recordReceived;
|
|
74
|
+
private _receiveMessages;
|
|
75
|
+
private _enqueueDelete;
|
|
76
|
+
private _flushDeleteBatch;
|
|
77
|
+
private _trackFlush;
|
|
78
|
+
private _awaitPendingFlushes;
|
|
79
|
+
private _startHeartbeat;
|
|
80
|
+
/** Resolves once any extension request already in flight for this message settles. */
|
|
81
|
+
private _stopHeartbeat;
|
|
82
|
+
/** Stops this run's heartbeats only, and waits out their in-flight extensions so none land after `stopped`. */
|
|
83
|
+
private _stopHeartbeats;
|
|
84
|
+
private _wrapMessage;
|
|
85
|
+
private _isAborted;
|
|
86
|
+
private _checkIdleTimeout;
|
|
87
|
+
private _effectiveIdlePollInterval;
|
|
88
|
+
private _backoff;
|
|
89
|
+
private _delay;
|
|
90
|
+
private _emit;
|
|
91
|
+
private _emitAsync;
|
|
92
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { BatchResultErrorEntry } from "@aws-sdk/client-sqs";
|
|
2
|
+
/**
|
|
3
|
+
* Base error class for all poller errors.
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export declare class PollerError extends Error {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
constructor(message: string, options?: {
|
|
9
|
+
cause?: Error;
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Thrown when a poller operation exceeds its time limit.
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export declare class TimeoutError extends PollerError {
|
|
17
|
+
readonly name: string;
|
|
18
|
+
readonly timeoutMs: number;
|
|
19
|
+
constructor(message: string, timeoutMs: number, options?: {
|
|
20
|
+
cause?: Error;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Thrown when `DeleteMessageBatch` reports failures.
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export declare class DeleteError extends PollerError {
|
|
28
|
+
readonly name: string;
|
|
29
|
+
readonly failures: BatchResultErrorEntry[];
|
|
30
|
+
readonly messageIds: string[];
|
|
31
|
+
constructor(message: string, failures: BatchResultErrorEntry[], messageIds?: string[], options?: {
|
|
32
|
+
cause?: Error;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Thrown when extending a message's visibility timeout fails.
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
export declare class VisibilityExtensionError extends PollerError {
|
|
40
|
+
readonly name: string;
|
|
41
|
+
readonly messageId: string;
|
|
42
|
+
constructor(message: string, messageId: string, options?: {
|
|
43
|
+
cause?: Error;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQS message poller with auto-delete, backoff, and graceful shutdown.
|
|
3
|
+
*
|
|
4
|
+
* @example Event-based
|
|
5
|
+
* ```typescript
|
|
6
|
+
* const poller = new SQSPoller({ queueUrl: "https://sqs.us-east-1.amazonaws.com/1/q" });
|
|
7
|
+
* const unsub = poller.on("message", async (msg) => console.log(msg.body));
|
|
8
|
+
* poller.on("error", (err) => console.error(err));
|
|
9
|
+
* poller.start();
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* @example Async iteration
|
|
13
|
+
* ```typescript
|
|
14
|
+
* for await (const msg of poller) {
|
|
15
|
+
* console.log(msg.body);
|
|
16
|
+
* if (msg.body === "last") {
|
|
17
|
+
* msg.enqueueDelete(); // exiting early skips auto-delete for this message
|
|
18
|
+
* break;
|
|
19
|
+
* }
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @packageDocumentation
|
|
24
|
+
*/
|
|
25
|
+
export { SQSPoller } from "./SQSPoller";
|
|
26
|
+
export { Message } from "./Message";
|
|
27
|
+
export { PollerError, DeleteError, TimeoutError, VisibilityExtensionError } from "./errors";
|
|
28
|
+
export type { PollerConfig, PollerStats, SerializablePollerStats, SQSPollerEvents, SQSPollerEventName, PollerMessage, } from "./types";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Message as SQSMessage,
|
|
3
|
+
MessageAttributeValue,
|
|
4
|
+
MessageSystemAttributeName,
|
|
5
|
+
} from "@aws-sdk/client-sqs";
|
|
6
|
+
import { PollerMessage } from "./types";
|
|
7
|
+
export interface MessageCallbacks {
|
|
8
|
+
enqueueDelete: (msg: Message) => void;
|
|
9
|
+
keep: (receiptHandle: string) => void;
|
|
10
|
+
release: (receiptHandle: string) => Promise<void>;
|
|
11
|
+
changeVisibility: (receiptHandle: string, timeoutMs: number) => Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export declare class Message implements PollerMessage {
|
|
14
|
+
readonly raw: SQSMessage;
|
|
15
|
+
readonly body: string | undefined;
|
|
16
|
+
readonly messageId: string;
|
|
17
|
+
readonly receiptHandle: string;
|
|
18
|
+
readonly attributes: Partial<Record<MessageSystemAttributeName, string>>;
|
|
19
|
+
readonly messageAttributes: Record<string, MessageAttributeValue>;
|
|
20
|
+
readonly receivedAt: Date;
|
|
21
|
+
private readonly _callbacks;
|
|
22
|
+
private _handled;
|
|
23
|
+
constructor(raw: SQSMessage, callbacks: MessageCallbacks);
|
|
24
|
+
readonly handled: boolean;
|
|
25
|
+
enqueueDelete(): void;
|
|
26
|
+
keep(): void;
|
|
27
|
+
release(): Promise<void>;
|
|
28
|
+
changeVisibility(timeoutMs: number): Promise<void>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PollerConfig,
|
|
3
|
+
PollerStats,
|
|
4
|
+
SerializablePollerStats,
|
|
5
|
+
SQSPollerEvents,
|
|
6
|
+
SQSPollerEventName,
|
|
7
|
+
PollerMessage,
|
|
8
|
+
} from "./types";
|
|
9
|
+
export declare class SQSPoller implements AsyncIterable<PollerMessage> {
|
|
10
|
+
private readonly _client;
|
|
11
|
+
private readonly _config;
|
|
12
|
+
private readonly _stats;
|
|
13
|
+
private _run;
|
|
14
|
+
private readonly _externalSignal?;
|
|
15
|
+
private _deleteBatch;
|
|
16
|
+
private _deleteTimer;
|
|
17
|
+
private _pendingFlushes;
|
|
18
|
+
private readonly _heartbeatTimers;
|
|
19
|
+
private readonly _heartbeatsInFlight;
|
|
20
|
+
private readonly _listeners;
|
|
21
|
+
constructor(config: PollerConfig);
|
|
22
|
+
readonly running: boolean;
|
|
23
|
+
readonly inFlight: number;
|
|
24
|
+
getStats(): Readonly<PollerStats>;
|
|
25
|
+
toJSON(): SerializablePollerStats;
|
|
26
|
+
toString(): string;
|
|
27
|
+
on<K extends SQSPollerEventName>(event: K, listener: SQSPollerEvents[K]): () => void;
|
|
28
|
+
off<K extends SQSPollerEventName>(event: K, listener?: SQSPollerEvents[K]): this;
|
|
29
|
+
start(): void;
|
|
30
|
+
stop(graceful?: boolean): Promise<PollerStats>;
|
|
31
|
+
[Symbol.asyncIterator](): AsyncGenerator<PollerMessage, void, undefined>;
|
|
32
|
+
private _iterate;
|
|
33
|
+
private _assertCanStart;
|
|
34
|
+
private _beginRun;
|
|
35
|
+
private _teardown;
|
|
36
|
+
private _waitFor;
|
|
37
|
+
private _waitForDrain;
|
|
38
|
+
private _emitShutdownTimeout;
|
|
39
|
+
private _pollLoop;
|
|
40
|
+
private _processMessage;
|
|
41
|
+
private _runBeforeRequest;
|
|
42
|
+
private _handleEmpty;
|
|
43
|
+
private _handlePollError;
|
|
44
|
+
private _recordReceived;
|
|
45
|
+
private _receiveMessages;
|
|
46
|
+
private _enqueueDelete;
|
|
47
|
+
private _flushDeleteBatch;
|
|
48
|
+
private _trackFlush;
|
|
49
|
+
private _awaitPendingFlushes;
|
|
50
|
+
private _startHeartbeat;
|
|
51
|
+
private _stopHeartbeat;
|
|
52
|
+
private _stopHeartbeats;
|
|
53
|
+
private _wrapMessage;
|
|
54
|
+
private _isAborted;
|
|
55
|
+
private _checkIdleTimeout;
|
|
56
|
+
private _effectiveIdlePollInterval;
|
|
57
|
+
private _backoff;
|
|
58
|
+
private _delay;
|
|
59
|
+
private _emit;
|
|
60
|
+
private _emitAsync;
|
|
61
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { BatchResultErrorEntry } from "@aws-sdk/client-sqs";
|
|
2
|
+
export declare class PollerError extends Error {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
constructor(
|
|
5
|
+
message: string,
|
|
6
|
+
options?: {
|
|
7
|
+
cause?: Error;
|
|
8
|
+
},
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
export declare class TimeoutError extends PollerError {
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly timeoutMs: number;
|
|
14
|
+
constructor(
|
|
15
|
+
message: string,
|
|
16
|
+
timeoutMs: number,
|
|
17
|
+
options?: {
|
|
18
|
+
cause?: Error;
|
|
19
|
+
},
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
export declare class DeleteError extends PollerError {
|
|
23
|
+
readonly name: string;
|
|
24
|
+
readonly failures: BatchResultErrorEntry[];
|
|
25
|
+
readonly messageIds: string[];
|
|
26
|
+
constructor(
|
|
27
|
+
message: string,
|
|
28
|
+
failures: BatchResultErrorEntry[],
|
|
29
|
+
messageIds?: string[],
|
|
30
|
+
options?: {
|
|
31
|
+
cause?: Error;
|
|
32
|
+
},
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
export declare class VisibilityExtensionError extends PollerError {
|
|
36
|
+
readonly name: string;
|
|
37
|
+
readonly messageId: string;
|
|
38
|
+
constructor(
|
|
39
|
+
message: string,
|
|
40
|
+
messageId: string,
|
|
41
|
+
options?: {
|
|
42
|
+
cause?: Error;
|
|
43
|
+
},
|
|
44
|
+
);
|
|
45
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { SQSPoller } from "./SQSPoller";
|
|
2
|
+
export { Message } from "./Message";
|
|
3
|
+
export { PollerError, DeleteError, TimeoutError, VisibilityExtensionError } from "./errors";
|
|
4
|
+
export {
|
|
5
|
+
PollerConfig,
|
|
6
|
+
PollerStats,
|
|
7
|
+
SerializablePollerStats,
|
|
8
|
+
SQSPollerEvents,
|
|
9
|
+
SQSPollerEventName,
|
|
10
|
+
PollerMessage,
|
|
11
|
+
} from "./types";
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SQSClient,
|
|
3
|
+
SQSClientConfig,
|
|
4
|
+
Message as SQSMessage,
|
|
5
|
+
MessageAttributeValue,
|
|
6
|
+
MessageSystemAttributeName,
|
|
7
|
+
BatchResultErrorEntry,
|
|
8
|
+
} from "@aws-sdk/client-sqs";
|
|
9
|
+
export {
|
|
10
|
+
SQSClient,
|
|
11
|
+
SQSClientConfig,
|
|
12
|
+
SQSMessage,
|
|
13
|
+
MessageAttributeValue,
|
|
14
|
+
MessageSystemAttributeName,
|
|
15
|
+
BatchResultErrorEntry,
|
|
16
|
+
};
|
|
17
|
+
export interface PollerConfig {
|
|
18
|
+
queueUrl: string;
|
|
19
|
+
client?: SQSClient;
|
|
20
|
+
clientConfig?: SQSClientConfig;
|
|
21
|
+
receiveWaitTimeMs?: number;
|
|
22
|
+
receiveBatchSize?: number;
|
|
23
|
+
activePollIntervalMs?: number;
|
|
24
|
+
idlePollIntervalMs?: number;
|
|
25
|
+
idleTimeoutMs?: number;
|
|
26
|
+
maxConcurrency?: number;
|
|
27
|
+
visibilityTimeoutMs?: number;
|
|
28
|
+
extendTimeout?: boolean;
|
|
29
|
+
extendTimeoutAdvanceMs?: number;
|
|
30
|
+
maxTimeoutExtensionMs?: number;
|
|
31
|
+
deleteMessages?: boolean;
|
|
32
|
+
deleteBatchSize?: number;
|
|
33
|
+
deleteWaitMs?: number;
|
|
34
|
+
systemAttributeNames?: MessageSystemAttributeName[];
|
|
35
|
+
messageAttributeNames?: string[];
|
|
36
|
+
backoffMs?: number;
|
|
37
|
+
maxBackoffMs?: number;
|
|
38
|
+
abortSignal?: AbortSignal;
|
|
39
|
+
shutdownTimeoutMs?: number;
|
|
40
|
+
beforeRequest?: (stats: PollerStats) => void | Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
export interface PollerStats {
|
|
43
|
+
requestCount: number;
|
|
44
|
+
receivedMessageCount: number;
|
|
45
|
+
deletedMessageCount: number;
|
|
46
|
+
errorCount: number;
|
|
47
|
+
lastMessageReceivedAt: Date | null;
|
|
48
|
+
pollingStartedAt: Date | null;
|
|
49
|
+
pollingStoppedAt: Date | null;
|
|
50
|
+
}
|
|
51
|
+
export interface SerializablePollerStats {
|
|
52
|
+
requestCount: number;
|
|
53
|
+
receivedMessageCount: number;
|
|
54
|
+
deletedMessageCount: number;
|
|
55
|
+
errorCount: number;
|
|
56
|
+
lastMessageReceivedAt: string | null;
|
|
57
|
+
pollingStartedAt: string | null;
|
|
58
|
+
pollingStoppedAt: string | null;
|
|
59
|
+
pollingDurationMs: number;
|
|
60
|
+
}
|
|
61
|
+
export interface SQSPollerEvents {
|
|
62
|
+
message: (message: PollerMessage) => void | Promise<void>;
|
|
63
|
+
empty: () => void;
|
|
64
|
+
idle: () => void;
|
|
65
|
+
stopped: (stats: PollerStats) => void;
|
|
66
|
+
error: (error: Error) => void;
|
|
67
|
+
timeoutExtended: (message: PollerMessage) => void;
|
|
68
|
+
heartbeatExpired: (message: PollerMessage) => void;
|
|
69
|
+
}
|
|
70
|
+
export type SQSPollerEventName = keyof SQSPollerEvents;
|
|
71
|
+
export interface PollerMessage {
|
|
72
|
+
readonly raw: SQSMessage;
|
|
73
|
+
readonly body: string | undefined;
|
|
74
|
+
readonly messageId: string;
|
|
75
|
+
readonly receiptHandle: string;
|
|
76
|
+
readonly attributes: Partial<Record<MessageSystemAttributeName, string>>;
|
|
77
|
+
readonly messageAttributes: Record<string, MessageAttributeValue>;
|
|
78
|
+
readonly receivedAt: Date;
|
|
79
|
+
enqueueDelete(): void;
|
|
80
|
+
keep(): void;
|
|
81
|
+
release(): Promise<void>;
|
|
82
|
+
changeVisibility(timeoutMs: number): Promise<void>;
|
|
83
|
+
}
|