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

Improvements for HttpContentCodec #3029

Closed 987Nabil closed 1 month ago

987Nabil commented 1 month ago

I think we can do the following, to avoid allocating to many codecs that are more or less all the same.

  1. The different schema based constructors of HttpContentCodec should cache the crated instances. This will reduce the amount of codecs in the running server and also improve the efficiency of the lookupCache
  2. Because of 1. we might want to use ConcurrentHashMap. I am not sure if it is needed, since a concurrent update would only lead to a cache miss. Might be okay to just keep it as is.
  3. Make HttpContentCodec a sealed trait and have a Filtered subtype, that keeps a view on an actual HttpContentCodec instance. This way, when we call only to limit the codec to a certain media type, we can still use the lookupCache of the original codec.
jdegoes commented 1 month ago

/bounty $175

algora-pbc[bot] commented 1 month ago

💎 $175 bounty • ZIO

Steps to solve:

  1. Start working: Comment /attempt #3029 with your implementation plan
  2. Submit work: Create a pull request including /claim #3029 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
🟢 @987Nabil Aug 30, 2024, 9:13:28 PM #3074
🟢 @varshith257 Aug 31, 2024, 11:00:15 AM #3073
987Nabil commented 1 month ago

/attempt #3029

Algora profile Completed bounties Tech Active attempts Options
@987Nabil    80 ZIO bounties
+ 1 bounty from 1 project
Scala
Cancel attempt
varshith257 commented 1 month ago

/attempt #3029

Algora profile Completed bounties Tech Active attempts Options
@varshith257    3 ZIO bounties
+ 6 bounties from 4 projects
TypeScript, Go
Cancel attempt
algora-pbc[bot] commented 1 month ago

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

algora-pbc[bot] commented 1 month ago

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

algora-pbc[bot] commented 1 month ago

🎉🎈 @987Nabil has been awarded $175! 🎈🎊