cosmo
cosmo copied to clipboard
Add support for response compression
Component(s)
router
Is your feature request related to a problem? Please describe.
As a user, I'd like to be able to compress data between the client <-> router and router <-> subgraphs to save bandwidth and improve performance.
Describe the solution you'd like
Request compression is done transparently. The user of the router doesn't need to configure anything. The exchange is done through HTTP headers Accept-Encoding and Content-Encoding. The implementation should support Gzip, Deflate and Brotli as compression methods.
We need to extend the router to decompress client requests and extend the engine transport to compress outgoing requests to subgraphs. A very reasonable choice for gzip could be https://github.com/klauspost/compress/tree/master/gzhttp which also serve as good inspiration for the other methods.
Requirements:
- No CGO.
- Functionality must be provided in separate Go modules with unit tests and integration test. See test suite.
- Use compression defaults that favor a good mix between compute time and space savings.
Describe alternatives you've considered
No response
Additional context
We use gin as http framework. The router engine transport can be found here https://github.com/wundergraph/cosmo/blob/main/router/core/transport.go
Previous issue #153
WunderGraph commits fully to Open Source and we want to make sure that we can help you as fast as possible. The roadmap is driven by our customers and we have to prioritize issues that are important to them. You can influence the priority by becoming a customer. Please contact us here.
/bounty $200
~~## 💎 $100 bounty • WunderGraph Cosmo~~
~~### Steps to solve:~~
~~1. Start working: Comment /attempt #602 with your implementation plan~~
~~2. Submit work: Create a pull request including /claim #602 in the PR body to claim the bounty~~
~~3. Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts~~
~~Important~~ ~~Bounty is up for challenger for those who can independently solve the task. We're here to support you with a final review and architectural assistance, but it's designed to be a solo challenge. Certain tasks require a deep understanding of the technology and ecosystem. Please consider this before diving in and spending your time on it. You are subject to a maximum attempt of 3 and you have 3 weeks after first attempt to complete the challenge. After that, you can no longer participate in the selected bounty.~~
~~Thank you for contributing to wundergraph/cosmo!~~
~~Add a bounty • Share on socials~~
| Attempt | Started (GMT+0) | Solution |
|---|---|---|
| 🔴 @ibishal | Mar 5, 2024, 9:56:36 PM | WIP |
| 🟢 @pi600 | Mar 5, 2024, 9:57:23 PM | WIP |
| 🟢 @Rutik7066 | Apr 11, 2024, 4:16:20 AM | #723 |
@StarpTech do we need prehandler and posthandler to decode and encode the request body?
/attempt #602
| Algora profile | Completed bounties | Tech | Active attempts | Options |
|---|---|---|---|---|
| @Rutik7066 | 5 bounties from 4 projects | Go, Rust, TypeScript & more |
Cancel attempt |
[!NOTE] The user @pi600 is already attempting to complete issue #602 and claim the bounty. We recommend checking in on @pi600's progress, and potentially collaborating, before starting a new solution.
💡 @Rutik7066 submitted a pull request that claims the bounty. You can visit your bounty board to reward.
Hi @StarpTech I have raised the draft PR. I would appreciate your help with further development. I need to know where I should use compression and decompression functions to achieve the desired results.
Hi @Rutik7066, I really like your ambitions but please respect the bounty requirements. We picked small tasks which should be solved alone. If you believe this task is too complicated, please move on with another one.
We're here to support you with a final review and architectural assistance, but it's designed to be a solo challenge.
Hi @StarpTech I need you help in architectural understanding in know in I have to add it as prehandler and posthandler. But I am unable to understand where other prehandler and posthandler is added.
@Rutik7066 take a look at the referenced issue https://github.com/wundergraph/cosmo/issues/153 We want to support client response compression. This means, a middleware needs to be implemented that overwrites responseWriter to support the compression algorithm. You can use https://github.com/go-chi/chi/blob/master/middleware/compress.go This is already almost the full story. If I assistant you more, I could the address the bounty myself 😄
@Rutik7066 take a look at the referenced issue https://github.com/wundergraph/cosmo/issues/153 We want to support client response compression. This means, a middleware needs to be implemented that overwrites responseWriter to support the compression algorithm. You can use https://github.com/go-chi/chi/blob/master/middleware/compress.go This is already almost the full story. If I assistant you more, I could the address the bounty myself 😄
Got it 🫡
Hi @StarpTech work is completed. Could you please review PR
I'm interested in taking a shot at this, adding my name to the queue!
I'm interested in taking a shot at this, adding my name to the queue!
PR submitted already everything is done. I am waiting for @StarpTech to review the PR
Hi @StarpTech could you please review the PR
Hi @Rutik7066 , there is a lot going on right now. I promise to review it at the beginning of next week. Thank you for your patience.
I have decreased the scope of the ticket and therefore also the reward. Thanks for the contribution @Rutik7066
@StarpTech what?
@StarpTech I think you know I worked because of 200$ bounty price right. If anything from my side needs to be corrected or completed then you should tell me instead of this thing.
Hi @Rutik7066,
I appreciate the effort you put into the project. However, it's important to note that the requirements were clearly outlined from the start. We've provided significant guidance throughout this process, which wasn't the intent of the bounty. You have completed response compression, which is only half of the requirement, and therefore received $100 as a reward.
The issue is closed.
Thank you for your understanding and contribution.