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

Remove dependency on deprecated tokio_core #16

Merged
merged 1 commit into from
Sep 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ readme = "README.md"
futures = "0.1"
hex = "0.2"
hyper = "0.12"
tokio-core = "0.1"
tokio = "0.1"
tokio-io = "0.1"
tokio-uds = "0.2"
1 change: 0 additions & 1 deletion examples/client.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
extern crate futures;
extern crate hyper;
extern crate hyperlocal;
extern crate tokio_core;

use std::io::{self, Write};

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
extern crate futures;
extern crate hex;
extern crate hyper;
extern crate tokio_core;
extern crate tokio;
extern crate tokio_io;
extern crate tokio_uds;

Expand Down
18 changes: 10 additions & 8 deletions src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use hyper::body::Payload;
use hyper::server::conn::Http as HyperHttp;
use hyper::service::{NewService, Service};
use hyper::Body;
use tokio_core::reactor::Core;
use tokio::runtime::Runtime;
use tokio_uds::UnixListener;

/// An instance of a server created through `Http::bind`.
Expand All @@ -26,7 +26,7 @@ where
S: NewService<ReqBody = Body> + Send + 'static,
{
new_service: S,
core: Core,
runtime: Runtime,
listener: UnixListener,
}

Expand All @@ -35,6 +35,8 @@ where
S: NewService<ReqBody = Body, ResBody = Body, Error = io::Error> + Send + Sync + 'static,
S::InitError: fmt::Display,
<S::Service as Service>::Future: Send,
<S as NewService>::Service: Send,
<S as NewService>::Future: Send,
{
/// Return the of the underlying socket address this server is listening on
pub fn local_addr(&self) -> io::Result<SocketAddr> {
Expand All @@ -45,7 +47,7 @@ where
pub fn run(self) -> io::Result<()> {
let Server {
new_service,
mut core,
runtime,
listener,
} = self;

Expand All @@ -57,8 +59,7 @@ where
io::ErrorKind::Other,
format!("failed to create service: {}", e),
)
})
.and_then(|service| {
}).and_then(|service| {
HyperHttp::new()
.serve_connection(sock, service)
.map_err(|e| {
Expand All @@ -70,7 +71,8 @@ where
})
});

core.run(server)
// ::hyper::rt::run(server)
runtime.block_on_all(server)
}
}

Expand Down Expand Up @@ -110,11 +112,11 @@ impl Http {
<S::Service as Service>::Future: Send + 'static,
B: Payload,
{
let core = Core::new()?;
let runtime = Runtime::new()?;
let listener = UnixListener::bind(path.as_ref())?;

Ok(Server {
core,
runtime,
listener,
new_service,
})
Expand Down