@lafken/queue 0.11.15 → 0.11.17
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.
|
@@ -8,6 +8,16 @@ import type { LambdaMetadata, LambdaProps, QueueNames, QueueReferenceNames, Reso
|
|
|
8
8
|
* - `url`: Same as `id`: the URL for the created Amazon SQS queue.
|
|
9
9
|
*/
|
|
10
10
|
export type QueueOutputAttributes = 'arn' | 'id' | 'url';
|
|
11
|
+
export interface DlqProps {
|
|
12
|
+
/**
|
|
13
|
+
* Maximum number of times a message can be received before being moved to the DLQ.
|
|
14
|
+
*/
|
|
15
|
+
maxReceiveCount: number;
|
|
16
|
+
/**
|
|
17
|
+
* Message retention period in seconds for the DLQ.
|
|
18
|
+
*/
|
|
19
|
+
retentionPeriod?: number;
|
|
20
|
+
}
|
|
11
21
|
export interface StandardProps {
|
|
12
22
|
/**
|
|
13
23
|
* Delivery delay in seconds.
|
|
@@ -96,6 +106,14 @@ export interface StandardProps {
|
|
|
96
106
|
* ref: 'order'
|
|
97
107
|
*/
|
|
98
108
|
ref?: QueueReferenceNames;
|
|
109
|
+
/**
|
|
110
|
+
* Dead Letter Queue configuration.
|
|
111
|
+
*
|
|
112
|
+
* When specified, a DLQ is created and the main queue is configured
|
|
113
|
+
* with a redrive policy to move unprocessable messages after the defined
|
|
114
|
+
* number of receive attempts.
|
|
115
|
+
*/
|
|
116
|
+
dlq?: DlqProps;
|
|
99
117
|
}
|
|
100
118
|
export interface FifoProps extends StandardProps {
|
|
101
119
|
/**
|
|
@@ -11,6 +11,7 @@ declare const Queue_base: (new (...args: any[]) => {
|
|
|
11
11
|
export declare class Queue extends Queue_base {
|
|
12
12
|
private props;
|
|
13
13
|
constructor(scope: AppModule, id: string, props: QueueProps);
|
|
14
|
+
private addDeadLetterQueue;
|
|
14
15
|
private addEventSource;
|
|
15
16
|
private validateEventParams;
|
|
16
17
|
private getParams;
|
|
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Queue = void 0;
|
|
4
4
|
const lambda_event_source_mapping_1 = require("@cdktn/provider-aws/lib/lambda-event-source-mapping");
|
|
5
5
|
const sqs_queue_1 = require("@cdktn/provider-aws/lib/sqs-queue");
|
|
6
|
+
const sqs_queue_redrive_policy_1 = require("@cdktn/provider-aws/lib/sqs-queue-redrive-policy");
|
|
6
7
|
const common_1 = require("@lafken/common");
|
|
7
8
|
const resolver_1 = require("@lafken/resolver");
|
|
9
|
+
const queue_utils_1 = require("./queue.utils");
|
|
8
10
|
const attributeAllowedTypes = new Set(['String', 'Number']);
|
|
9
11
|
const bodyParsedTypes = new Set(['String', 'Object', 'Array']);
|
|
10
12
|
const bodyUnparsedTypes = new Set(['String']);
|
|
@@ -13,7 +15,7 @@ class Queue extends resolver_1.lafkenResource.make(sqs_queue_1.SqsQueue) {
|
|
|
13
15
|
constructor(scope, id, props) {
|
|
14
16
|
const { handler } = props;
|
|
15
17
|
super(scope, `${id}-queue`, {
|
|
16
|
-
name:
|
|
18
|
+
name: (0, queue_utils_1.sqsName)(handler.queueName, handler.isFifo ? '.fifo' : ''),
|
|
17
19
|
fifoQueue: handler.isFifo,
|
|
18
20
|
contentBasedDeduplication: handler.contentBasedDeduplication,
|
|
19
21
|
visibilityTimeoutSeconds: handler.visibilityTimeout,
|
|
@@ -25,10 +27,29 @@ class Queue extends resolver_1.lafkenResource.make(sqs_queue_1.SqsQueue) {
|
|
|
25
27
|
if (handler.ref) {
|
|
26
28
|
this.register('queue', handler.ref);
|
|
27
29
|
}
|
|
30
|
+
this.addDeadLetterQueue(id);
|
|
28
31
|
this.validateEventParams();
|
|
29
32
|
this.addEventSource(id);
|
|
30
33
|
new resolver_1.ResourceOutput(this, handler.outputs);
|
|
31
34
|
}
|
|
35
|
+
addDeadLetterQueue(id) {
|
|
36
|
+
const { handler } = this.props;
|
|
37
|
+
if (!handler.dlq)
|
|
38
|
+
return;
|
|
39
|
+
const dlqName = (0, queue_utils_1.sqsName)(handler.queueName, `-dlq${handler.isFifo ? '.fifo' : ''}`);
|
|
40
|
+
const dlq = new sqs_queue_1.SqsQueue(this, `${id}-dlq`, {
|
|
41
|
+
name: dlqName,
|
|
42
|
+
fifoQueue: handler.isFifo,
|
|
43
|
+
messageRetentionSeconds: handler.dlq.retentionPeriod,
|
|
44
|
+
});
|
|
45
|
+
new sqs_queue_redrive_policy_1.SqsQueueRedrivePolicy(this, `${id}-redrive-policy`, {
|
|
46
|
+
queueUrl: this.url,
|
|
47
|
+
redrivePolicy: JSON.stringify({
|
|
48
|
+
deadLetterTargetArn: dlq.arn,
|
|
49
|
+
maxReceiveCount: handler.dlq.maxReceiveCount,
|
|
50
|
+
}),
|
|
51
|
+
});
|
|
52
|
+
}
|
|
32
53
|
addEventSource(id) {
|
|
33
54
|
const { handler, resourceMetadata } = this.props;
|
|
34
55
|
const lambdaHandler = new resolver_1.LambdaHandler(this, `${id}-handler`, {
|
|
@@ -77,9 +98,6 @@ class Queue extends resolver_1.lafkenResource.make(sqs_queue_1.SqsQueue) {
|
|
|
77
98
|
if (param.source === 'attribute' && !attributeAllowedTypes.has(param.type)) {
|
|
78
99
|
throw new Error(`Attribute params only support ${[...attributeAllowedTypes].join(', ')} values`);
|
|
79
100
|
}
|
|
80
|
-
if (param.source === 'body' && param.parse && !bodyParsedTypes.has(param.type)) {
|
|
81
|
-
throw new Error(`Body params only support ${[...bodyParsedTypes].join(', ')} values`);
|
|
82
|
-
}
|
|
83
101
|
if (param?.source === 'body' && !param.parse && !bodyUnparsedTypes.has(param.type)) {
|
|
84
102
|
throw new Error(`Body params only support ${[...bodyUnparsedTypes].join(', ')} values`);
|
|
85
103
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function sqsName(base: string, suffix: string): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lafken/queue",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.17",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Define SQS queues and consumers using TypeScript decorators - automatic infrastructure generation with Lafken",
|
|
6
6
|
"keywords": [
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@aws-sdk/client-sqs": "^3.1037.0",
|
|
56
56
|
"aws-lambda": "^1.0.7",
|
|
57
57
|
"reflect-metadata": "^0.2.2",
|
|
58
|
-
"@lafken/resolver": "0.11.
|
|
58
|
+
"@lafken/resolver": "0.11.17"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@cdktn/provider-aws": "^23.9.0",
|
|
@@ -69,13 +69,13 @@
|
|
|
69
69
|
"typescript": "6.0.3",
|
|
70
70
|
"unplugin-swc": "^1.5.9",
|
|
71
71
|
"vitest": "^4.1.5",
|
|
72
|
-
"@lafken/common": "0.11.
|
|
72
|
+
"@lafken/common": "0.11.17"
|
|
73
73
|
},
|
|
74
74
|
"peerDependencies": {
|
|
75
75
|
"@cdktn/provider-aws": ">=23.0.0",
|
|
76
76
|
"cdktn": ">=0.22.0",
|
|
77
77
|
"constructs": "^10.4.5",
|
|
78
|
-
"@lafken/common": "0.11.
|
|
78
|
+
"@lafken/common": "0.11.17"
|
|
79
79
|
},
|
|
80
80
|
"engines": {
|
|
81
81
|
"node": ">=20.19"
|