feat(rt): make tokio runtime optional

A Cargo feature `runtime` is added, which is enabled by default, that
includes the following:

- The `client::HttpConnector`, which uses `tokio::net::TcpStream`.
- The `server::AddrStream`, which uses `tokio::net::TcpListener`.
- The `hyper::rt` module, which includes useful utilities to work with
  the runtime without needing to import `futures` or `tokio` explicity.

Disabling the feature removes many of these niceties, but allows people
to use hyper in environments that have an alternative runtime, without
needing to download an unused one.
This commit is contained in:
Sean McArthur
2018-04-23 16:56:26 -07:00
committed by GitHub
parent 62a5c1188a
commit d127201ef2
21 changed files with 541 additions and 410 deletions

View File

@@ -2,7 +2,6 @@
extern crate futures;
extern crate hyper;
extern crate pretty_env_logger;
extern crate tokio;
use futures::{future, Future};
use futures::sync::oneshot;
@@ -29,7 +28,7 @@ fn main() {
println!("Listening on http://{}", addr);
tokio::run(server);
hyper::rt::run(server);
}
type ResponseFuture = Box<Future<Item=Response<Body>, Error=io::Error> + Send>;