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

Extend Server to use anything that produces a stream of (Io, SocketAddr) #1045

Closed
wants to merge 2 commits into from

Conversation

mattwoodyard
Copy link

I've done some refactoring on Server to make it easier to integrate with and ssl listener.

	* Add bind_existing method to allow the creation of a server that
	  uses an existing tcplistener instead of the one created by hyper
	* Generalize the Server struct so that it can be handed a stream of
          Io implementors.
@GitCop
Copy link

GitCop commented Feb 3, 2017

Thanks for contributing! Unfortunately, I'm here to tell you there were the following style issues with your Pull Request:

  • Commit: 6cdf656

  • Commits must be in the following format: %{type}(%{scope}): %{description}

  • Commit: 80ae945

  • Commits must be in the following format: %{type}(%{scope}): %{description}

Guidelines are available at https://github.com/hyperium/hyper/blob/master/CONTRIBUTING.md


This message was auto-generated by https://gitcop.com

@seanmonstar
Copy link
Member

Being generic over a stream of Ios was actually how the server used to work, and was changed to the current situation in #1013!

The idea is that Http implements ServerProto, and there is also the exposed bind_connection method, so really, any stream of connections can already be used.

Making use of TLS for the Server just involves using tokio_tls::proto::Server::new(http, listener), from here: https://github.com/tokio-rs/tokio-tls/blob/master/src/proto.rs

@alexcrichton may have more thoughts on the matter.

@mattwoodyard
Copy link
Author

I tried getting that working first (https://play.rust-lang.org/?gist=d8d0d1ed14574f4085b1d663c6354ef8&version=stable&backtrace=0), but it seemed to be missing some implementation (I think: #1036). I was going to add that, but then I noticed that tokio-proto didn't have graceful shutdown, which is something I wanted, so I did this.

Is there something I've missed?

@alexcrichton
Copy link
Contributor

@mattwoodyard sounds like you went down the same rabbit hole I did! @seanmonstar is spot on in that the server Hyper bundles isn't currently intended to be used with TLS (or other protocols for that matter). The idea is that protocols are built externally and then there's generic support for taking a protocol and spinning up a server with it.

Note, though, that support isn't quite here yet for all that. PRs like tokio-rs/tokio-proto#135 and issues like #1036 are key ingredients to getting that working. With #1036 Hyper's request/response should work "as-is" with tokio-proto's TcpServer and with tokio-rs/tokio-proto#135 then tokio-proto's TcpServer should reach feature parity with Hyper's current server in this repository.

@seanmonstar I'll leave it up to you whether you'd like to merge this for now. The intention at least is that this shouldn't be necessary (and in fact, the entire server shouldn't be necessary!), so you can at least rest easy that in the future you won't have to maintain this :)

@seanmonstar
Copy link
Member

Oh right, what I had suggested doesn't actually work yet without #1036. With #1036 fixed, would that solve your use case @mattwoodyard?

@mattwoodyard
Copy link
Author

For my immediate task, I'm just trying to get TLS to work. I'm not particularly attached to the approach in this PR. If #1036 can make the tokio_tls stuff work, thats fine. Longterm I'd like graceful shutdown with my TLS. If the plan is to generalize the hyper approach into tokio-proto, I can take a swing at that.

@alexcrichton
Copy link
Contributor

Yeah I believe that's the general long term plan at least, to have Hyper work well with the tokio-proto server builders to leverage all of the logic in there (which will expand over time)

@mattwoodyard
Copy link
Author

Closing in favor of #1047

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.

4 participants