From f8ba7d9f4ea7eb8f6248fc7b6db42ca3c73f6fe4 Mon Sep 17 00:00:00 2001 From: Tim Kuehn Date: Thu, 8 Aug 2019 22:06:09 -0700 Subject: [PATCH] Make tokio1 serde1 default features --- example-service/Cargo.toml | 2 +- hooks/pre-push | 6 +++--- rpc/src/client/mod.rs | 3 ++- rpc/src/server/mod.rs | 6 +++++- tarpc/Cargo.toml | 1 + 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/example-service/Cargo.toml b/example-service/Cargo.toml index e287e92..194c1c2 100644 --- a/example-service/Cargo.toml +++ b/example-service/Cargo.toml @@ -17,7 +17,7 @@ json-transport = { package = "tarpc-json-transport", version = "0.1", path = ".. clap = "2.0" futures-preview = { version = "0.3.0-alpha.17" } serde = { version = "1.0" } -tarpc = { version = "0.18", path = "../tarpc", features = ["serde1", "tokio1"] } +tarpc = { version = "0.18", path = "../tarpc" } tokio = "0.2.0-alpha.1" env_logger = "0.6" diff --git a/hooks/pre-push b/hooks/pre-push index 2f1bce1..5740172 100755 --- a/hooks/pre-push +++ b/hooks/pre-push @@ -89,12 +89,12 @@ if [ "$?" == 0 ]; then exit 1 fi - try_run "Building ... " cargo build --color=always - try_run "Testing ... " cargo test --color=always + try_run "Building ... " cargo build --no-default-features --color=always + try_run "Testing ... " cargo test --no-default-features --color=always try_run "Testing with all features enabled ... " cargo test --all-features --color=always for EXAMPLE in $(cargo run --example 2>&1 | grep ' ' | awk '{print $1}') do - try_run "Running example \"$EXAMPLE\" ... " cargo run --all-features --example $EXAMPLE + try_run "Running example \"$EXAMPLE\" ... " cargo run --example $EXAMPLE done fi diff --git a/rpc/src/client/mod.rs b/rpc/src/client/mod.rs index 0ad466a..ee56368 100644 --- a/rpc/src/client/mod.rs +++ b/rpc/src/client/mod.rs @@ -8,7 +8,6 @@ use crate::context; use futures::prelude::*; -use log::error; use std::io; /// Provides a [`Client`] backed by a transport. @@ -143,6 +142,8 @@ where /// Helper method to spawn the dispatch on the default executor. #[cfg(feature = "tokio1")] pub fn spawn(self) -> io::Result { + use log::error; + let dispatch = self .dispatch .unwrap_or_else(move |e| error!("Connection broken: {}", e)); diff --git a/rpc/src/server/mod.rs b/rpc/src/server/mod.rs index 6558c6c..7b24de8 100644 --- a/rpc/src/server/mod.rs +++ b/rpc/src/server/mod.rs @@ -20,7 +20,7 @@ use futures::{ task::{Context, Poll}, }; use humantime::format_rfc3339; -use log::{debug, info, trace}; +use log::{debug, trace}; use pin_utils::{unsafe_pinned, unsafe_unpinned}; use std::{ fmt, @@ -663,6 +663,8 @@ where /// request handler onto the default executor. #[cfg(feature = "tokio1")] pub fn execute(self) -> impl Future { + use log::info; + self.try_for_each(|request_handler| { async { tokio::spawn(request_handler); @@ -701,6 +703,8 @@ where type Output = (); fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> { + use log::info; + while let Some(channel) = ready!(self.as_mut().incoming().poll_next(cx)) { tokio::spawn( channel diff --git a/tarpc/Cargo.toml b/tarpc/Cargo.toml index 032b6ba..860a682 100644 --- a/tarpc/Cargo.toml +++ b/tarpc/Cargo.toml @@ -13,6 +13,7 @@ readme = "../README.md" description = "An RPC framework for Rust with a focus on ease of use." [features] +default = ["serde1", "tokio1"] serde1 = ["rpc/serde1", "tarpc-plugins/serde1", "serde", "serde/derive"] tokio1 = ["rpc/tokio1"]