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

Concurrency Strategy is Unclear #4

Closed
reem opened this issue Sep 6, 2014 · 2 comments · Fixed by #13
Closed

Concurrency Strategy is Unclear #4

reem opened this issue Sep 6, 2014 · 2 comments · Fixed by #13

Comments

@reem
Copy link
Contributor

reem commented Sep 6, 2014

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.

@seanmonstar
Copy link
Member

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
Sent: ‎Saturday‎, ‎September‎ ‎06‎, ‎2014 ‎11‎:‎58‎ ‎AM
To: seanmonstar/hyper

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.


Reply to this email directly or view it on GitHub.

@reem
Copy link
Contributor Author

reem commented Sep 7, 2014

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.

reem added a commit to reem/hyper that referenced this issue Sep 7, 2014
…) 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
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 a pull request may close this issue.

2 participants