-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce `aws.QueueRef` as a way to add an external queue reference to an application: ```js bring aws; bring cloud; let myQueue = new aws.QueueRef("arn:aws:sqs:...."); // <-- ARN of an existing SQS queue new cloud.Function(inflight () => { myQueue.push("new message"); }); ``` This works both when running in the simulator and when running on AWS. The Wing Console also includes some metadata about the queue such as the queue URL and the AWS Console URL: ![image](https://github.com/winglang/wing/assets/598796/fec3a609-6f7e-42c9-93ec-1768c197ca07) ### Issues * Related to #5879 (only implements queue and we need additional resources). * Related to #5170 ### Misc Added an option `link: bool` to `ui.FIeld` to indicate that the value returned is a link. We should make this a clickable link in the Wing Console. ## Checklist - [x] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted) - [x] Description explains motivation and solution - [x] Tests added (always) - [x] Docs updated (only required for features) - [x] Added `pr/e2e-full` label if this feature requires end-to-end testing *By submitting this pull request, I confirm that my contribution is made under the terms of the [Wing Cloud Contribution License](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
- Loading branch information
Showing
19 changed files
with
1,746 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
bring cloud; | ||
bring aws; | ||
bring util; | ||
|
||
// a really cool way to test a "ref" resource: basically, we define a cloud.Queue | ||
// and then we define a `QueueRef` that references it's ARN. nice, ha? | ||
|
||
let c = new cloud.Counter(); | ||
let q = new cloud.Queue(); | ||
|
||
q.setConsumer(inflight () => { | ||
c.inc(); | ||
}); | ||
|
||
// this will only work if we are testing on tf-aws | ||
if let arn = aws.Queue.from(q)?.queueArn { | ||
let qref = new aws.QueueRef(arn); | ||
|
||
new cloud.Function(inflight () => { | ||
qref.push("hello"); | ||
qref.pop(); | ||
}); | ||
|
||
test "can push to an external queue (QueueRef)" { | ||
qref.push("m1"); | ||
qref.push("m2"); | ||
qref.push("m3"); | ||
util.waitUntil(() => { | ||
return c.peek() == 3; | ||
}); | ||
} | ||
} | ||
|
||
if util.env("WING_TARGET") == "sim" { | ||
bring expect; | ||
|
||
let dummyArn = "arn:aws:sqs:us-east-1:111111111111:Queue-11111111"; | ||
let qr = new aws.QueueRef(dummyArn); | ||
|
||
test "queueArn returns the arn" { | ||
expect.equal(dummyArn, qr.queueArn); | ||
} | ||
|
||
test "push() sends a request to aws, fails because we are using a dummy queue" { | ||
let var err = false; | ||
try { | ||
qr.push("foo"); | ||
} catch e { | ||
err = true; | ||
} | ||
|
||
assert(err); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.