Use hyper-provided runtime instead of tokio-core

This commit is contained in:
Tangent 128 2018-09-18 02:29:01 -04:00
parent 14d468cc7d
commit 08e8b1311f
4 changed files with 9 additions and 43 deletions

26
Cargo.lock generated
View File

@ -343,11 +343,6 @@ dependencies = [
"redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "scoped-tls"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "scopeguard"
version = "0.3.3"
@ -412,24 +407,6 @@ dependencies = [
"tokio-udp 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "tokio-core"
version = "0.1.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.21 (registry+https://github.com/rust-lang/crates.io-index)",
"iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"mio 0.6.14 (registry+https://github.com/rust-lang/crates.io-index)",
"scoped-tls 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-executor 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-io 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-reactor 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-timer 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "tokio-executor"
version = "0.1.2"
@ -550,7 +527,6 @@ dependencies = [
"hyper 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)",
"odds 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-core 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-io 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
@ -634,7 +610,6 @@ dependencies = [
"checksum rawslice 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "22b23b9f57ea250c6db4b21e2897b43ff08209217ca8260469fae6c0f9ad7e25"
"checksum redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)" = "0d92eecebad22b767915e4d529f89f28ee96dbbf5a4810d2b844373f136417fd"
"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76"
"checksum scoped-tls 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8674d439c964889e2476f474a3bf198cc9e199e77499960893bac5de7e9218a4"
"checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27"
"checksum slab 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fdeff4cd9ecff59ec7e3744cbca73dfe5ac35c2aedb2cfba8a1c715a18912e9d"
"checksum string 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00caf261d6f90f588f8450b8e1230fa0d5be49ee6140fdfbcb55335aff350970"
@ -643,7 +618,6 @@ dependencies = [
"checksum textwrap 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c0b59b6b4b44d867f1370ef1bd91bfb262bf07bf0ae65c202ea2fbc16153b693"
"checksum time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "a15375f1df02096fb3317256ce2cee6a1f42fc84ea5ad5fc8c421cfe40c73098"
"checksum tokio 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "be15ef40f675c9fe66e354d74c73f3ed012ca1aa14d65846a33ee48f1ae8d922"
"checksum tokio-core 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "aeeffbbb94209023feaef3c196a41cbcdafa06b4a6f893f68779bb5e53796f71"
"checksum tokio-executor 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8cac2a7883ff3567e9d66bb09100d09b33d90311feca0206c7ca034bc0c55113"
"checksum tokio-io 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "6af9eb326f64b2d6b68438e1953341e00ab3cf54de7e35d92bfc73af8555313a"
"checksum tokio-reactor 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b3cedc8e5af5131dc3423ffa4f877cce78ad25259a9a62de0613735a13ebc64b"

View File

@ -11,5 +11,4 @@ http = "0.1"
hyper = "0.12"
odds = { version = "0.3.1", features = ["std-vec"] }
tokio = "0.1.5"
tokio-core = "0.1.17"
tokio-io = "0.1.6"

View File

@ -8,9 +8,6 @@ use hyper::{
client::HttpConnector,
Request
};
use tokio_core::reactor::{
Handle
};
use super::{
stdin_stream,
@ -39,7 +36,7 @@ pub fn options() -> App<'static, 'static> {
type BoxedChunkStream = Box<Stream<Item = Chunk, Error = WebmetroError> + Send>;
pub fn run(_handle: Handle, args: &ArgMatches) -> Box<Future<Item=(), Error=WebmetroError>> {
pub fn run(args: &ArgMatches) -> Box<Future<Item=(), Error=WebmetroError> + Send> {
let mut chunk_stream: BoxedChunkStream = Box::new(
stdin_stream()
.parse_ebml()

View File

@ -3,7 +3,6 @@ extern crate futures;
extern crate http;
extern crate hyper;
extern crate tokio;
extern crate tokio_core;
extern crate tokio_io;
extern crate webmetro;
@ -11,7 +10,7 @@ mod commands;
use clap::{App, AppSettings};
use futures::prelude::*;
use tokio_core::reactor::Core;
use hyper::rt;
use webmetro::error::WebmetroError;
use commands::{
@ -36,13 +35,10 @@ fn options() -> App<'static, 'static> {
fn main() {
let args = options().get_matches();
let core = Core::new().unwrap();
let handle = core.handle();
tokio_run(core, match args.subcommand() {
tokio_run(match args.subcommand() {
("filter", Some(sub_args)) => box_up(filter::run(sub_args)),
("relay", Some(sub_args)) => box_up(relay::run(sub_args)),
("send", Some(sub_args)) => box_up(send::run(handle, sub_args)),
("send", Some(sub_args)) => box_up(send::run(sub_args)),
("dump", Some(sub_args)) => box_up(dump::run(sub_args)),
_ => box_up(futures::lazy(|| {
options().print_help().unwrap();
@ -52,15 +48,15 @@ fn main() {
});
}
fn tokio_run(mut core: Core, task: Box<Future<Item=(), Error=WebmetroError>>) {
core.run(task.into_future()).unwrap_or_else(|err| {
fn tokio_run(task: Box<Future<Item=(), Error=WebmetroError> + Send>) {
rt::run(task.into_future().map_err(|err| {
eprintln!("Error: {}", err);
::std::process::exit(1);
});
}));
}
fn box_up<F: IntoFuture<Item=(), Error=WebmetroError>>(task: F) -> Box<Future<Item=(), Error=WebmetroError>>
where F::Future: 'static
fn box_up<F: IntoFuture<Item=(), Error=WebmetroError>>(task: F) -> Box<Future<Item=(), Error=WebmetroError> + Send>
where F::Future: Send + 'static
{
Box::new(task.into_future())
}