Make tokio1 serde1 default features

This commit is contained in:
Tim Kuehn
2019-08-08 22:06:09 -07:00
parent 41c1aafaf7
commit f8ba7d9f4e
5 changed files with 12 additions and 6 deletions

View File

@@ -17,7 +17,7 @@ json-transport = { package = "tarpc-json-transport", version = "0.1", path = "..
clap = "2.0" clap = "2.0"
futures-preview = { version = "0.3.0-alpha.17" } futures-preview = { version = "0.3.0-alpha.17" }
serde = { version = "1.0" } 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" tokio = "0.2.0-alpha.1"
env_logger = "0.6" env_logger = "0.6"

View File

@@ -89,12 +89,12 @@ if [ "$?" == 0 ]; then
exit 1 exit 1
fi fi
try_run "Building ... " cargo build --color=always try_run "Building ... " cargo build --no-default-features --color=always
try_run "Testing ... " cargo test --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 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}') for EXAMPLE in $(cargo run --example 2>&1 | grep ' ' | awk '{print $1}')
do do
try_run "Running example \"$EXAMPLE\" ... " cargo run --all-features --example $EXAMPLE try_run "Running example \"$EXAMPLE\" ... " cargo run --example $EXAMPLE
done done
fi fi

View File

@@ -8,7 +8,6 @@
use crate::context; use crate::context;
use futures::prelude::*; use futures::prelude::*;
use log::error;
use std::io; use std::io;
/// Provides a [`Client`] backed by a transport. /// Provides a [`Client`] backed by a transport.
@@ -143,6 +142,8 @@ where
/// Helper method to spawn the dispatch on the default executor. /// Helper method to spawn the dispatch on the default executor.
#[cfg(feature = "tokio1")] #[cfg(feature = "tokio1")]
pub fn spawn(self) -> io::Result<C> { pub fn spawn(self) -> io::Result<C> {
use log::error;
let dispatch = self let dispatch = self
.dispatch .dispatch
.unwrap_or_else(move |e| error!("Connection broken: {}", e)); .unwrap_or_else(move |e| error!("Connection broken: {}", e));

View File

@@ -20,7 +20,7 @@ use futures::{
task::{Context, Poll}, task::{Context, Poll},
}; };
use humantime::format_rfc3339; use humantime::format_rfc3339;
use log::{debug, info, trace}; use log::{debug, trace};
use pin_utils::{unsafe_pinned, unsafe_unpinned}; use pin_utils::{unsafe_pinned, unsafe_unpinned};
use std::{ use std::{
fmt, fmt,
@@ -663,6 +663,8 @@ where
/// request handler onto the default executor. /// request handler onto the default executor.
#[cfg(feature = "tokio1")] #[cfg(feature = "tokio1")]
pub fn execute(self) -> impl Future<Output = ()> { pub fn execute(self) -> impl Future<Output = ()> {
use log::info;
self.try_for_each(|request_handler| { self.try_for_each(|request_handler| {
async { async {
tokio::spawn(request_handler); tokio::spawn(request_handler);
@@ -701,6 +703,8 @@ where
type Output = (); type Output = ();
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> { 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)) { while let Some(channel) = ready!(self.as_mut().incoming().poll_next(cx)) {
tokio::spawn( tokio::spawn(
channel channel

View File

@@ -13,6 +13,7 @@ readme = "../README.md"
description = "An RPC framework for Rust with a focus on ease of use." description = "An RPC framework for Rust with a focus on ease of use."
[features] [features]
default = ["serde1", "tokio1"]
serde1 = ["rpc/serde1", "tarpc-plugins/serde1", "serde", "serde/derive"] serde1 = ["rpc/serde1", "tarpc-plugins/serde1", "serde", "serde/derive"]
tokio1 = ["rpc/tokio1"] tokio1 = ["rpc/tokio1"]