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

Optimize ServerInboundHandler#writeResponse #3057

Merged
merged 2 commits into from
Aug 27, 2024

Conversation

kyri-petrou
Copy link
Collaborator

@kyri-petrou kyri-petrou commented Aug 27, 2024

Currently, the error handling in ServerInboundHandler#writeResponse requires 3 foldCauseZIOs and 3-4 flatMaps as well as a couple of succeed.

This PR rewrites this logic in order to:

  1. Remove redundant error handling (i.e., ZIO.attempt / ZIO.suspend)
  2. Use foldCauseZIO instead of sandbox + catchAll

This results in just 1 foldCauseZIO in the happy path (success & attemptFastWrite is successful). And as a plus, the code is also much cleaner and easier to follow

@kyri-petrou
Copy link
Collaborator Author

CI failure is "expected". It should be fixed by #3056

@jdegoes
Copy link
Member

jdegoes commented Aug 27, 2024

@kyri-petrou Long overdue cleanup! ❤️

@jdegoes jdegoes merged commit 2afb155 into zio:main Aug 27, 2024
34 checks passed
@kyri-petrou kyri-petrou deleted the optimize-write-response branch August 27, 2024 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants