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

(WIP) Read body in IO pool #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

kalekale
Copy link
Contributor

This is a bit silly, but it works.

@kalekale kalekale force-pushed the feature/body-in-io-pool branch from d3a7336 to d00820e Compare November 23, 2019 09:49
(handler)
(response/send-response exchange)))]
(if (fn? (:body request))
((:body request) handler request)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but is not optimal in perf I believe: :body is looked up twice, and as it's backed by the slow Potemkin lazy-map, we lose 2*70ns here. I would suggest:

  • adding the :body to pohjavirta.request.Request for fast access (few nanos)
  • maybe add a Protocol like pohjavirta.request.HandleWithBody that has (handle-with-body [_ handler]) function that is invoked in pohjavirta.server and would do things behind the scenes. To remove the if completely, there could be AsyncPartialRequest and SyncPartialRequest that have their own implementation of HandleWithBody, as we know how to parse the body already when server is created (with :dispatch or not).

(fn [handler request]
(-> exchange
.getRequestReceiver
(.receiveFullBytes (proxy [Receiver$FullBytesCallback] []
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't reify be faster here?

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.

3 participants