Browse Source

hyper: revert tokio upgrade (while bugs are addressed) (#3455)

Sean McArthur 7 years ago
parent
commit
ee9085c5b8
2 changed files with 28 additions and 6 deletions
  1. 5 2
      frameworks/Rust/hyper/Cargo.toml
  2. 23 4
      frameworks/Rust/hyper/src/main.rs

+ 5 - 2
frameworks/Rust/hyper/Cargo.toml

@@ -9,12 +9,15 @@ authors = [
 
 [dependencies]
 futures = "0.1"
-hyper = { version = "0.11.24", default-features = false }
+hyper = { version = "0.11.24" } #, default-features = false }
 num_cpus = "1.2"
 serde = "1.0"
 serde_json = "1.0"
 serde_derive = "1.0"
-tokio = "0.1"
+#tokio = "0.1"
+tokio-core = "=0.1.11"
+tokio-io = "=0.1.4"
+tokio-proto = "0.1"
 
 [profile.release]
 opt-level = 3

+ 23 - 4
frameworks/Rust/hyper/src/main.rs

@@ -4,20 +4,22 @@ extern crate num_cpus;
 #[macro_use]
 extern crate serde_derive;
 extern crate serde_json;
-extern crate tokio;
+//extern crate tokio;
+extern crate tokio_proto;
 
 use std::env;
 use std::net::SocketAddr;
 use std::process;
 
-use futures::{future, Future, Stream};
+use futures::{future}; //, Future, Stream};
 
 use hyper::Method::Get;
 use hyper::header::{ContentLength, ContentType, Server};
 use hyper::StatusCode::NotFound;
 use hyper::server::{Http, Service, Request, Response};
 
-use tokio::net::TcpListener;
+//use tokio::net::TcpListener;
+use tokio_proto::TcpServer;
 
 static HELLOWORLD: &'static [u8] = b"Hello, world!";
 
@@ -32,7 +34,7 @@ impl Service for TechEmpower {
     type Request = Request;
     type Response = Response;
     type Error = hyper::Error;
-    type Future = ::futures::Finished<Response, hyper::Error>;
+    type Future = future::FutureResult<Response, hyper::Error>;
 
     fn call(&self, req: Request) -> Self::Future {
         let response = match (req.method(), req.path()) {
@@ -80,6 +82,22 @@ fn configure() -> Http {
     http
 }
 
+fn main() {
+    // Check for some runtime configuration
+    let http = configure();
+
+    // Bind to 0.0.0.0:8080
+    let addr = SocketAddr::from(([0, 0, 0, 0], 8080));
+
+    let mut srv = TcpServer::new(http, addr);
+    srv.threads(num_cpus::get());
+
+    println!("Listening on http://{}", addr);
+    srv.serve(|| Ok(TechEmpower));
+}
+
+/* This is the future, but there's still a few blockers in new tokio,
+ * so disable this for now while we work them out.
 fn main() {
     // Check for some runtime configuration
     let http = configure();
@@ -105,3 +123,4 @@ fn main() {
     println!("Listening on http://{}", addr);
     tokio::run(server);
 }
+*/