zio / zio-http

A next-generation Scala framework for building scalable, correct, and efficient HTTP clients and servers
https://zio.dev/zio-http
Apache License 2.0
787 stars 396 forks source link

Add a hybrid `RequestStreaming` option that streams requests only if they're larger than X bytes #2908

Closed kyri-petrou closed 1 month ago

kyri-petrou commented 3 months ago

Is your feature request related to a problem? Please describe. Currently, zio-http provides 2 config options for RequestStreaming:

  1. Disabled (with a maximum number of bytes that the request can be before rejecting it)
  2. Enabled (requests are streamed regardless of size)

For servers with low latency / high performance requirements, disabling streaming is a favourable option as it's more performant than streaming the requests. However, in some cases we might want to be able to be able to handle very large requests, so it would be good if zio-http provided an option to aggregate the response if it's less than X bytes, and stream it if it's larger than that

Describe the solution you'd like Another case class extending RequestStreaming similar to Disabled but instead of failing the request it streams the bytes instead

Describe alternatives you've considered Enabling streaming and using a middleware to batch the ZStream, but this doesn't perform as well as I would have hoped

jdegoes commented 2 months ago

/bounty $250 but has to ship soon because of final release coming up.

algora-pbc[bot] commented 2 months ago

💎 $250 bounty • ZIO

Steps to solve:

  1. Start working: Comment /attempt #2908 with your implementation plan
  2. Submit work: Create a pull request including /claim #2908 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

Thank you for contributing to zio/zio-http!

Add a bounty • Share on socials

Attempt Started (GMT+0) Solution
🔴 @abhi267266 Aug 3, 2024, 9:26:19 AM WIP
🟢 @Ahmadkhan02 Aug 4, 2024, 8:48:55 PM #3003
abhi267266 commented 2 months ago

/attempt #2908

Ahmadkhan02 commented 2 months ago

/attempt #2908

Algora profile Completed bounties Tech Active attempts Options
@Ahmadkhan02 1 bounty from 1 project
TypeScript, Jupyter Notebook
Cancel attempt
algora-pbc[bot] commented 2 months ago

[!NOTE] The user @abhi267266 is already attempting to complete issue #2908 and claim the bounty. We recommend checking in on @abhi267266's progress, and potentially collaborating, before starting a new solution.

algora-pbc[bot] commented 2 months ago

💡 @Ahmadkhan02 submitted a pull request that claims the bounty. You can visit your bounty board to reward.

algora-pbc[bot] commented 1 month ago

🎉🎈 @Ahmadkhan02 has been awarded $250! 🎈🎊