Skip to content

Commit

Permalink
Merge of #4355
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Oct 1, 2023
2 parents 361d546 + 61e3c5b commit e7f903a
Show file tree
Hide file tree
Showing 16 changed files with 32 additions and 22 deletions.
9 changes: 7 additions & 2 deletions libs/wingsdk/src/target-awscdk/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as cloud from "../cloud";
import * as core from "../core";
import { convertBetweenHandlers } from "../shared/convert";
import { calculateQueuePermissions } from "../shared-aws/permissions";
import { IInflightHost, Node } from "../std";
import { IInflightHost, Node, Duration as StdDuration } from "../std";

/**
* AWS implementation of `cloud.Queue`.
Expand All @@ -17,9 +17,11 @@ import { IInflightHost, Node } from "../std";
*/
export class Queue extends cloud.Queue {
private readonly queue: SQSQueue;
private readonly timeout: StdDuration;

constructor(scope: Construct, id: string, props: cloud.QueueProps = {}) {
super(scope, id, props);
this.timeout = props.timeout ?? StdDuration.fromSeconds(30);

this.queue = new SQSQueue(this, "Default", {
visibilityTimeout: props.timeout
Expand Down Expand Up @@ -51,7 +53,10 @@ export class Queue extends cloud.Queue {
this.node.scope!, // ok since we're not a tree root
`${this.node.id}-SetConsumer-${hash}`,
functionHandler,
props
{
...props,
timeout: this.timeout,
}
);

// TODO: remove this constraint by adding generic permission APIs to cloud.Function
Expand Down
9 changes: 7 additions & 2 deletions libs/wingsdk/src/target-tf-aws/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as core from "../core";
import { convertBetweenHandlers } from "../shared/convert";
import { NameOptions, ResourceNames } from "../shared/resource-names";
import { calculateQueuePermissions } from "../shared-aws/permissions";
import { IInflightHost, Node } from "../std";
import { Duration, IInflightHost, Node } from "../std";

/**
* Queue names are limited to 80 characters.
Expand Down Expand Up @@ -57,7 +57,12 @@ export class Queue extends cloud.Queue {
this.node.scope!, // ok since we're not a tree root
`${this.node.id}-SetConsumer-${hash}`,
functionHandler,
props
{
...props,
timeout: Duration.fromSeconds(
this.queue.visibilityTimeoutSeconds ?? 30
),
}
);

// TODO: remove this constraint by adding generic permission APIs to cloud.Function
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ exports[`queue with a consumer function 2`] = `
],
},
"Runtime": "nodejs18.x",
"Timeout": 60,
"Timeout": 30,
},
"Type": "AWS::Lambda::Function",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ exports[`messages are not requeued if the function fails after retention timeout
"Sending messages (messages=[\\"BAD MESSAGE\\"], subscriber=sim-1).",
"Invoke (payload=\\"{\\\\\\"messages\\\\\\":[\\\\\\"BAD MESSAGE\\\\\\"]}\\").",
"Subscriber error - returning 1 messages to queue: ERROR",
"1 messages pushed back to queue after visibility timeout.",
"wingsdk.sim.EventMapping deleted.",
]
`;

Expand Down
2 changes: 1 addition & 1 deletion libs/wingsdk/test/target-sim/queue.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ test("messages are not requeued if the function fails after retention timeout",
"Push (messages=BAD MESSAGE).",
"Sending messages (messages=[\\"BAD MESSAGE\\"], subscriber=sim-1).",
"Subscriber error - returning 1 messages to queue: ERROR",
"1 messages pushed back to queue after visibility timeout.",
"wingsdk.cloud.Queue deleted.",
]
`);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ exports[`function with a queue binding 3`] = `
"runtime": "nodejs18.x",
"s3_bucket": "\${aws_s3_bucket.Code.bucket}",
"s3_key": "\${aws_s3_object.Queue-SetConsumer-5cb7e554_S3Object_074547A5.key}",
"timeout": 60,
"timeout": "\${aws_sqs_queue.Queue.visibility_timeout_seconds}",
"vpc_config": {
"security_group_ids": [],
"subnet_ids": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ exports[`queue with a consumer function 2`] = `
"runtime": "nodejs18.x",
"s3_bucket": "\${aws_s3_bucket.Code.bucket}",
"s3_key": "\${aws_s3_object.Queue-SetConsumer-c5395e41_S3Object_D8D7B631.key}",
"timeout": 60,
"timeout": "\${aws_sqs_queue.Queue.visibility_timeout_seconds}",
"vpc_config": {
"security_group_ids": [],
"subnet_ids": [],
Expand Down
10 changes: 5 additions & 5 deletions tools/hangar/__snapshots__/plugins.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ exports[`Plugin examples > AWS target plugins > permission-boundary.js 1`] = `
"runtime": "nodejs18.x",
"s3_bucket": "\${aws_s3_bucket.Code.bucket}",
"s3_key": "\${aws_s3_object.cloudQueue-SetConsumer-cdafee6e_S3Object_8868B9FB.key}",
"timeout": 60,
"timeout": "\${aws_sqs_queue.cloudQueue.visibility_timeout_seconds}",
"vpc_config": {
"security_group_ids": [],
"subnet_ids": [],
Expand Down Expand Up @@ -331,7 +331,7 @@ exports[`Plugin examples > AWS target plugins > replicate-s3.js 1`] = `
"runtime": "nodejs18.x",
"s3_bucket": "\${aws_s3_bucket.Code.bucket}",
"s3_key": "\${aws_s3_object.cloudQueue-SetConsumer-cdafee6e_S3Object_8868B9FB.key}",
"timeout": 60,
"timeout": "\${aws_sqs_queue.cloudQueue.visibility_timeout_seconds}",
"vpc_config": {
"security_group_ids": [],
"subnet_ids": [],
Expand Down Expand Up @@ -607,7 +607,7 @@ exports[`Plugin examples > AWS target plugins > tf-backend.js > azurerm backend
"runtime": "nodejs18.x",
"s3_bucket": "\${aws_s3_bucket.Code.bucket}",
"s3_key": "\${aws_s3_object.cloudQueue-SetConsumer-cdafee6e_S3Object_8868B9FB.key}",
"timeout": 60,
"timeout": "\${aws_sqs_queue.cloudQueue.visibility_timeout_seconds}",
"vpc_config": {
"security_group_ids": [],
"subnet_ids": [],
Expand Down Expand Up @@ -765,7 +765,7 @@ exports[`Plugin examples > AWS target plugins > tf-backend.js > gcp backend 1`]
"runtime": "nodejs18.x",
"s3_bucket": "\${aws_s3_bucket.Code.bucket}",
"s3_key": "\${aws_s3_object.cloudQueue-SetConsumer-cdafee6e_S3Object_8868B9FB.key}",
"timeout": 60,
"timeout": "\${aws_sqs_queue.cloudQueue.visibility_timeout_seconds}",
"vpc_config": {
"security_group_ids": [],
"subnet_ids": [],
Expand Down Expand Up @@ -923,7 +923,7 @@ exports[`Plugin examples > AWS target plugins > tf-backend.js > s3 backend 1`] =
"runtime": "nodejs18.x",
"s3_bucket": "\${aws_s3_bucket.Code.bucket}",
"s3_key": "\${aws_s3_object.cloudQueue-SetConsumer-cdafee6e_S3Object_8868B9FB.key}",
"timeout": 60,
"timeout": "\${aws_sqs_queue.cloudQueue.visibility_timeout_seconds}",
"vpc_config": {
"security_group_ids": [],
"subnet_ids": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ module.exports = function({ }) {
"runtime": "nodejs18.x",
"s3_bucket": "${aws_s3_bucket.Code.bucket}",
"s3_key": "${aws_s3_object.cloudQueue-SetConsumer-cdafee6e_S3Object_8868B9FB.key}",
"timeout": 60,
"timeout": "${aws_sqs_queue.cloudQueue.visibility_timeout_seconds}",
"vpc_config": {
"security_group_ids": [],
"subnet_ids": []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ module.exports = function({ $headers }) {
"runtime": "nodejs18.x",
"s3_bucket": "${aws_s3_bucket.Code.bucket}",
"s3_key": "${aws_s3_object.cloudQueue-SetConsumer-cdafee6e_S3Object_8868B9FB.key}",
"timeout": 60,
"timeout": "${aws_sqs_queue.cloudQueue.visibility_timeout_seconds}",
"vpc_config": {
"security_group_ids": [],
"subnet_ids": []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ module.exports = function({ $bucket, $counter }) {
"runtime": "nodejs18.x",
"s3_bucket": "${aws_s3_bucket.Code.bucket}",
"s3_key": "${aws_s3_object.cloudQueue-SetConsumer-cdafee6e_S3Object_8868B9FB.key}",
"timeout": 60,
"timeout": "${aws_sqs_queue.cloudQueue.visibility_timeout_seconds}",
"vpc_config": {
"security_group_ids": [],
"subnet_ids": []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ module.exports = function({ $bucket }) {
"runtime": "nodejs18.x",
"s3_bucket": "${aws_s3_bucket.Code.bucket}",
"s3_key": "${aws_s3_object.cloudQueue-SetConsumer-cdafee6e_S3Object_8868B9FB.key}",
"timeout": 60,
"timeout": "${aws_sqs_queue.cloudQueue.visibility_timeout_seconds}",
"vpc_config": {
"security_group_ids": [],
"subnet_ids": []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ module.exports = function({ }) {
"runtime": "nodejs18.x",
"s3_bucket": "${aws_s3_bucket.Code.bucket}",
"s3_key": "${aws_s3_object.cloudQueue-SetConsumer-86898773_S3Object_630353AD.key}",
"timeout": 180,
"timeout": "${aws_sqs_queue.cloudQueue.visibility_timeout_seconds}",
"vpc_config": {
"security_group_ids": [],
"subnet_ids": []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ module.exports = function({ $queue, $r, $r2, $util_Util }) {
"runtime": "nodejs18.x",
"s3_bucket": "${aws_s3_bucket.Code.bucket}",
"s3_key": "${aws_s3_object.cloudQueue-SetConsumer-cdafee6e_S3Object_8868B9FB.key}",
"timeout": 3,
"timeout": "${aws_sqs_queue.cloudQueue.visibility_timeout_seconds}",
"vpc_config": {
"security_group_ids": [
"${aws_security_group.exRedis_securityGroup_3948C3F2.id}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ module.exports = function({ }) {
"runtime": "nodejs18.x",
"s3_bucket": "${aws_s3_bucket.Code.bucket}",
"s3_key": "${aws_s3_object.BigPublisher_cloudQueue-SetConsumer-c50bc9ef_S3Object_D9D9B438.key}",
"timeout": 60,
"timeout": "${aws_sqs_queue.BigPublisher_cloudQueue_2EE8871A.visibility_timeout_seconds}",
"vpc_config": {
"security_group_ids": [],
"subnet_ids": []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ module.exports = function({ }) {
"runtime": "nodejs18.x",
"s3_bucket": "${aws_s3_bucket.Code.bucket}",
"s3_key": "${aws_s3_object.cloudQueue-SetConsumer-cdafee6e_S3Object_8868B9FB.key}",
"timeout": 60,
"timeout": "${aws_sqs_queue.cloudQueue.visibility_timeout_seconds}",
"vpc_config": {
"security_group_ids": [],
"subnet_ids": []
Expand Down

0 comments on commit e7f903a

Please sign in to comment.