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
Concurrency Strategy is Unclear #4
Comments
Should it be the case that the http server just spews out new tasks for all incoming requests? What if the Handler trait received an 'incoming’ function, with a default implementation to stay single tasked? From: Jonathan Reem It appears to me that parallel connections block on handler.handle here https://github.com/seanmonstar/hyper/blob/master/src/server/mod.rs#L55. This seems weird to me. I would much rather Handler: Clone, and for Handler to simply be copied for each request. That way, downstream users of this library have maximum control of what concurrency forms they want. — |
I think the best solution would be to expose a stream of Request/Response pairs as an Iterator, much like TcpStream, and then registered handlers would just receive this stream and can decide on whatever concurrency strategy they want. I think this is the most flexible approach we could take, especially considering that it's unlikely most users will interact with hyper directly so providing flexibility to frameworks is key. |
…) pairs. This allows downstream users to have total control of their concurrency strategy, while also exposing a very nice, streaming interface for frameworks to build on. This also resolves issues surrounding the use of IoResult as the return type of Handler::handle, because handlers now have complete control over how to handle internal failure. Fixes hyperium#3 Fixes hyperium#4
It appears to me that parallel connections block on
handler.handle
here https://github.com/seanmonstar/hyper/blob/master/src/server/mod.rs#L55.This seems weird to me. I would much rather Handler: Clone, and for Handler to simply be copied for each request and
handler.handle
called in its own task. That way, downstream users of this library have maximum control of what concurrency forms they want.If not, you will have to expose a stream of incoming requests to allow downstream users to decide on their own concurrency strategies.
The text was updated successfully, but these errors were encountered: