Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subscribing queues to topics #6032

Closed
eladb opened this issue Mar 21, 2024 · 8 comments · Fixed by #6132
Closed

Subscribing queues to topics #6032

eladb opened this issue Mar 21, 2024 · 8 comments · Fixed by #6132
Assignees
Labels
✨ enhancement New feature or request good first issue Good for newcomers 🎨 sdk SDK

Comments

@eladb
Copy link
Contributor

eladb commented Mar 21, 2024

Use Case

I'd like to be able to have send notifications sent to a cloud.Topic into a cloud.Queue for processing.

Proposed Solution

Something like this:

bring cloud;

let q = new cloud.Queue();
let t = new cloud.Topic();
t.subscribeQueue(q);

Implementation Notes

In AWS, it is possible to connect SNS to SQS directly.

Component

No response

Community Notes

  • Please vote by adding a 👍 reaction to the issue to help us prioritize.
  • If you are interested to work on this issue, please leave a comment.
  • If this issue is labeled needs-discussion, it means the spec has not been finalized yet. Please reach out on the #dev channel in the Wing Slack.
@eladb eladb added ✨ enhancement New feature or request needs-discussion Further discussion is needed prior to impl labels Mar 21, 2024
@Chriscbr Chriscbr added the 🎨 sdk SDK label Mar 21, 2024
@ekeren
Copy link
Collaborator

ekeren commented Mar 21, 2024

@eladb it seems pretty straightforward, can you elaborate why you added the needs-discussion label?

@eladb
Copy link
Contributor Author

eladb commented Mar 21, 2024

It was automatically added

@staycoolcall911 staycoolcall911 added good first issue Good for newcomers and removed needs-discussion Further discussion is needed prior to impl labels Mar 21, 2024
@marciocadev
Copy link
Collaborator

marciocadev commented Mar 24, 2024

Guys, this is basically what I did in messagefanout

https://github.com/winglang/winglibs/tree/main/messagefanout

bring messagefanout;

let fanout = new messagefanout.MessageFanout();

fanout.addConsumer(inflight (msg: str) => {
  log("Hello {msg}!!!");
});

test "push a message to fanout" {
  fanout.publish("world");
}

@eladb
Copy link
Contributor Author

eladb commented Mar 25, 2024

Very cool @marciocadev - based on feedback from users we see this as something that can be incorporated into the standard library.

Would you like to work on this?

@marciocadev
Copy link
Collaborator

Yes, I can do it ☺️

@marciocadev marciocadev self-assigned this Mar 25, 2024
@marciocadev
Copy link
Collaborator

marciocadev commented Apr 3, 2024

I started implementing in the simulator, which is always the hardest part for me, but I think visually it turned out pretty cool.
I created the queueSubscription method, if you think it should be named differently, let me know.

bring cloud;

let t = new cloud.Topic();

let q1 = new cloud.Queue() as "q1";
t.queueSubscription(q1);
q1.setConsumer(inflight (msg: str) => {
  log("from topic to queue 1: {msg}");
});

let q2 = new cloud.Queue() as "q2";
t.queueSubscription(q2);
q2.setConsumer(inflight (msg: str) => {
  log("from topic to queue 2: {msg}");
});

t.onMessage(inflight (msg: str) => {
  log("from topic: {msg}");
});

image
image

@marciocadev
Copy link
Collaborator

Now I see, I will change to subscribeQueue

@mergify mergify bot closed this as completed in #6132 Apr 5, 2024
mergify bot pushed a commit that referenced this issue Apr 5, 2024
- [x] subscribing queue to topic (sim)
- [x] subscribing queue to topic (tf-aws)
- [x] subscribing queue to topic (awscdk)
- [x] wing test

Closes #6032

## 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
- [ ] Tests added (always)
- [ ] Docs updated (only required for features)
- [ ] 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)*.
@monadabot
Copy link
Contributor

Congrats! 🚀 This was released in Wing 0.67.12.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement New feature or request good first issue Good for newcomers 🎨 sdk SDK
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

6 participants