Update Cargo.toml to use crates.io releases of tokio deps.

This commit is contained in:
Tim Kuehn
2017-01-11 14:23:52 -08:00
parent 91e9ad3001
commit e4ef0881e6
14 changed files with 51 additions and 57 deletions

View File

@@ -13,8 +13,8 @@ description = "An RPC framework for Rust with a focus on ease of use."
[dependencies]
bincode = "0.6"
byteorder = "0.5"
bytes = { git = "https://github.com/carllerche/bytes" }
futures = { git = "https://github.com/alexcrichton/futures-rs" }
bytes = "0.3"
futures = "0.1"
lazy_static = "0.2"
log = "0.3"
scoped-pool = "1.0"
@@ -22,15 +22,11 @@ serde = "0.8"
serde_derive = "0.8"
tarpc-plugins = { path = "src/plugins" }
take = "0.1"
tokio-service = { git = "https://github.com/tokio-rs/tokio-service" }
tokio-proto = { git = "https://github.com/tokio-rs/tokio-proto" }
tokio-core = { git = "https://github.com/tokio-rs/tokio-core" }
tokio-service = "0.1"
tokio-proto = "0.1"
tokio-core = "0.1"
net2 = "0.2"
[replace]
"tokio-core:0.1.3" = { git = "https://github.com/tokio-rs/tokio-core" }
"futures:0.1.7" = { git = "https://github.com/alexcrichton/futures-rs" }
[dev-dependencies]
chrono = "0.2"
env_logger = "0.3"

View File

@@ -50,7 +50,7 @@ impl Server {
impl FutureService for Server {
type ReadFut = CpuFuture<Vec<u8>, Never>;
fn read(&mut self, size: u32) -> Self::ReadFut {
fn read(&self, size: u32) -> Self::ReadFut {
let request_number = self.request_count.fetch_add(1, Ordering::SeqCst);
debug!("Server received read({}) no. {}", size, request_number);
self.pool
@@ -88,13 +88,13 @@ struct Stats {
max: Option<Duration>,
}
fn run_once(mut clients: Vec<FutureClient>, concurrency: u32) -> impl Future<Item=(), Error=()> + 'static {
fn run_once(clients: Vec<FutureClient>, concurrency: u32) -> impl Future<Item=(), Error=()> + 'static {
let start = Instant::now();
let num_clients = clients.len();
futures::stream::futures_unordered((0..concurrency as usize)
.map(|iteration| (iteration + 1, iteration % num_clients))
.map(|(iteration, client_idx)| {
let mut client = &mut clients[client_idx];
let client = &clients[client_idx];
let start = Instant::now();
debug!("Client {} reading (iteration {})...", client_idx, iteration);
client.read(CHUNK_SIZE)

View File

@@ -49,7 +49,7 @@ struct Subscriber {
impl subscriber::FutureService for Subscriber {
type ReceiveFut = futures::Finished<(), Never>;
fn receive(&mut self, message: String) -> Self::ReceiveFut {
fn receive(&self, message: String) -> Self::ReceiveFut {
println!("{} received message: {}", self.id, message);
futures::finished(())
}
@@ -80,7 +80,7 @@ impl Publisher {
impl publisher::FutureService for Publisher {
type BroadcastFut = BoxFuture<(), Never>;
fn broadcast(&mut self, message: String) -> Self::BroadcastFut {
fn broadcast(&self, message: String) -> Self::BroadcastFut {
futures::collect(self.clients
.lock()
.unwrap()
@@ -94,7 +94,7 @@ impl publisher::FutureService for Publisher {
type SubscribeFut = BoxFuture<(), Message>;
fn subscribe(&mut self, id: u32, address: SocketAddr) -> Self::SubscribeFut {
fn subscribe(&self, id: u32, address: SocketAddr) -> Self::SubscribeFut {
let clients = self.clients.clone();
subscriber::FutureClient::connect(&address)
.map(move |subscriber| {
@@ -108,7 +108,7 @@ impl publisher::FutureService for Publisher {
type UnsubscribeFut = BoxFuture<(), Never>;
fn unsubscribe(&mut self, id: u32) -> Self::UnsubscribeFut {
fn unsubscribe(&self, id: u32) -> Self::UnsubscribeFut {
println!("Unsubscribing {}", id);
self.clients.lock().unwrap().remove(&id).unwrap();
futures::finished(()).boxed()
@@ -122,7 +122,7 @@ fn main() {
.wait()
.unwrap();
let mut publisher_client = publisher::SyncClient::connect(publisher_addr).unwrap();
let publisher_client = publisher::SyncClient::connect(publisher_addr).unwrap();
let subscriber1 = Subscriber::new(0);
publisher_client.subscribe(0, subscriber1).unwrap();

View File

@@ -39,7 +39,7 @@ impl Error for NoNameGiven {
struct HelloServer;
impl SyncService for HelloServer {
fn hello(&mut self, name: String) -> Result<String, NoNameGiven> {
fn hello(&self, name: String) -> Result<String, NoNameGiven> {
if name == "" {
Err(NoNameGiven)
} else {

View File

@@ -46,7 +46,7 @@ impl Service for HelloServer {
type Error = io::Error;
type Future = Box<Future<Item = tarpc::Response<String, Never>, Error = io::Error>>;
fn call(&mut self, request: Self::Request) -> Self::Future {
fn call(&self, request: Self::Request) -> Self::Future {
Ok(Ok(format!("Hello, {}!", request.unwrap()))).into_future().boxed()
}
}
@@ -60,7 +60,7 @@ impl FutureClient {
tarpc::Client::connect_remotely(addr, &tarpc::future::REMOTE).map(FutureClient)
}
pub fn hello(&mut self, name: String)
pub fn hello(&self, name: String)
-> impl Future<Item = String, Error = tarpc::Error<Never>> + 'static
{
self.0.call(name).then(|msg| msg.unwrap())
@@ -73,7 +73,7 @@ fn main() {
let addr = HelloServer::listen("localhost:10000".first_socket_addr()).wait().unwrap();
let f = FutureClient::connect(&addr)
.map_err(tarpc::Error::from)
.and_then(|mut client| {
.and_then(|client| {
let resp1 = client.hello("Mom".to_string());
info!("Sent first request.");

View File

@@ -26,7 +26,7 @@ struct HelloServer;
impl FutureService for HelloServer {
type HelloFut = futures::Finished<String, Never>;
fn hello(&mut self, name: String) -> Self::HelloFut {
fn hello(&self, name: String) -> Self::HelloFut {
futures::finished(format!("Hello, {}!", name))
}
}
@@ -38,7 +38,7 @@ fn main() {
core.run(
FutureClient::connect(&addr)
.map_err(tarpc::Error::from)
.and_then(|mut client| client.hello("Mom".to_string()))
.and_then(|client| client.hello("Mom".to_string()))
.map(|resp| println!("{}", resp))
).unwrap();
}

View File

@@ -22,7 +22,7 @@ service! {
struct HelloServer;
impl SyncService for HelloServer {
fn hello(&mut self, name: String) -> Result<String, Never> {
fn hello(&self, name: String) -> Result<String, Never> {
Ok(format!("Hello, {}!", name))
}
}
@@ -30,6 +30,6 @@ impl SyncService for HelloServer {
fn main() {
let addr = "localhost:10000";
HelloServer.listen(addr).unwrap();
let mut client = SyncClient::connect(addr).unwrap();
let client = SyncClient::connect(addr).unwrap();
println!("{}", client.hello("Mom".to_string()).unwrap());
}

View File

@@ -41,7 +41,7 @@ struct AddServer;
impl AddFutureService for AddServer {
type AddFut = futures::Finished<i32, Never>;
fn add(&mut self, x: i32, y: i32) -> Self::AddFut {
fn add(&self, x: i32, y: i32) -> Self::AddFut {
futures::finished(x + y)
}
}
@@ -62,7 +62,7 @@ impl DoubleServer {
impl DoubleFutureService for DoubleServer {
type DoubleFut = BoxFuture<i32, Message>;
fn double(&mut self, x: i32) -> Self::DoubleFut {
fn double(&self, x: i32) -> Self::DoubleFut {
self.client
.lock()
.unwrap()

View File

@@ -44,7 +44,7 @@ struct Server;
impl FutureService for Server {
type ReadFut = futures::Finished<Arc<Vec<u8>>, Never>;
fn read(&mut self) -> Self::ReadFut {
fn read(&self) -> Self::ReadFut {
futures::finished(BUF.clone())
}
}

View File

@@ -31,7 +31,7 @@ struct Bar;
impl bar::FutureService for Bar {
type BarFut = futures::Finished<i32, Never>;
fn bar(&mut self, i: i32) -> Self::BarFut {
fn bar(&self, i: i32) -> Self::BarFut {
futures::finished(i)
}
}
@@ -47,7 +47,7 @@ struct Baz;
impl baz::FutureService for Baz {
type BazFut = futures::Finished<String, Never>;
fn baz(&mut self, s: String) -> Self::BazFut {
fn baz(&self, s: String) -> Self::BazFut {
futures::finished(format!("Hello, {}!", s))
}
}
@@ -61,8 +61,8 @@ fn main() {
let bar_addr = Bar.listen("localhost:0".first_socket_addr()).wait().unwrap();
let baz_addr = Baz.listen("localhost:0".first_socket_addr()).wait().unwrap();
let mut bar_client = bar::SyncClient::connect(&bar_addr).unwrap();
let mut baz_client = baz::SyncClient::connect(&baz_addr).unwrap();
let bar_client = bar::SyncClient::connect(&bar_addr).unwrap();
let baz_client = baz::SyncClient::connect(&baz_addr).unwrap();
info!("Result: {:?}", bar_client.bar(17));

View File

@@ -55,7 +55,7 @@ impl<Req, Resp, E> Service for Client<Req, Resp, E>
type Error = io::Error;
type Future = ResponseFuture<Req, Resp, E>;
fn call(&mut self, request: Self::Request) -> Self::Future {
fn call(&self, request: Self::Request) -> Self::Future {
self.inner.call(request).map(Self::map_err)
}
}

View File

@@ -45,7 +45,7 @@
//! struct HelloServer;
//!
//! impl SyncService for HelloServer {
//! fn hello(&mut self, name: String) -> Result<String, Never> {
//! fn hello(&self, name: String) -> Result<String, Never> {
//! Ok(format!("Hello, {}!", name))
//! }
//! }
@@ -53,7 +53,7 @@
//! fn main() {
//! let addr = "localhost:10000";
//! let _server = HelloServer.listen(addr);
//! let mut client = SyncClient::connect(addr).unwrap();
//! let client = SyncClient::connect(addr).unwrap();
//! println!("{}", client.hello("Mom".to_string()).unwrap());
//! }
//! ```

View File

@@ -386,7 +386,7 @@ macro_rules! service {
}
$(#[$attr])*
fn $fn_name(&mut self, $($arg:$in_),*) -> ty_snake_to_camel!(Self::$fn_name);
fn $fn_name(&self, $($arg:$in_),*) -> ty_snake_to_camel!(Self::$fn_name);
)*
}
@@ -476,7 +476,7 @@ macro_rules! service {
type Error = ::std::io::Error;
type Future = __tarpc_service_FutureReply<__tarpc_service_S>;
fn call(&mut self, __tarpc_service_request: Self::Request) -> Self::Future {
fn call(&self, __tarpc_service_request: Self::Request) -> Self::Future {
let __tarpc_service_request = match __tarpc_service_request {
Ok(__tarpc_service_request) => __tarpc_service_request,
Err(__tarpc_service_deserialize_err) => {
@@ -509,7 +509,7 @@ macro_rules! service {
}
return __tarpc_service_FutureReply::$fn_name(
$crate::futures::Future::then(
FutureService::$fn_name(&mut self.0, $($arg),*),
FutureService::$fn_name(&self.0, $($arg),*),
__tarpc_service_wrap));
}
)*
@@ -529,7 +529,7 @@ macro_rules! service {
{
$(
$(#[$attr])*
fn $fn_name(&mut self, $($arg:$in_),*) -> ::std::result::Result<$out, $error>;
fn $fn_name(&self, $($arg:$in_),*) -> ::std::result::Result<$out, $error>;
)*
}
@@ -578,7 +578,7 @@ macro_rules! service {
$crate::futures::Done<$out, $error>>,
fn($crate::futures::Canceled) -> $error>>;
}
fn $fn_name(&mut self, $($arg:$in_),*) -> ty_snake_to_camel!(Self::$fn_name) {
fn $fn_name(&self, $($arg:$in_),*) -> ty_snake_to_camel!(Self::$fn_name) {
fn unimplemented(_: $crate::futures::Canceled) -> $error {
// TODO(tikue): what do do if SyncService panics?
unimplemented!()
@@ -611,7 +611,7 @@ macro_rules! service {
#[allow(unused)]
#[derive(Clone, Debug)]
/// The client stub that makes RPC calls to the server. Exposes a blocking interface.
pub struct SyncClient(::std::sync::Arc<::std::sync::Mutex<FutureClient>>);
pub struct SyncClient(FutureClient);
impl $crate::sync::Connect for SyncClient {
fn connect<A>(addr: A) -> ::std::result::Result<Self, ::std::io::Error>
@@ -620,7 +620,7 @@ macro_rules! service {
let addr = $crate::util::FirstSocketAddr::try_first_socket_addr(&addr)?;
let client = <FutureClient as $crate::future::Connect>::connect(&addr);
let client = $crate::futures::Future::wait(client)?;
let client = SyncClient(::std::sync::Arc::new(::std::sync::Mutex::new(client)));
let client = SyncClient(client);
::std::result::Result::Ok(client)
}
}
@@ -632,7 +632,7 @@ macro_rules! service {
pub fn $fn_name(&self, $($arg: $in_),*)
-> ::std::result::Result<$out, $crate::Error<$error>>
{
let rpc = self.0.lock().unwrap().$fn_name($($arg),*);
let rpc = (self.0).$fn_name($($arg),*);
$crate::futures::Future::wait(rpc)
}
)*
@@ -719,13 +719,13 @@ macro_rules! service {
$(
#[allow(unused)]
$(#[$attr])*
pub fn $fn_name(&mut self, $($arg: $in_),*)
pub fn $fn_name(&self, $($arg: $in_),*)
-> impl $crate::futures::Future<Item=$out, Error=$crate::Error<$error>>
+ 'static
{
let __tarpc_service_req = __tarpc_service_Request::$fn_name(($($arg,)*));
let __tarpc_service_fut =
$crate::tokio_service::Service::call(&mut self.0, __tarpc_service_req);
$crate::tokio_service::Service::call(&self.0, __tarpc_service_req);
$crate::futures::Future::then(__tarpc_service_fut,
move |__tarpc_service_msg| {
match __tarpc_service_msg? {
@@ -822,10 +822,10 @@ mod functional_test {
struct Server;
impl SyncService for Server {
fn add(&mut self, x: i32, y: i32) -> Result<i32, Never> {
fn add(&self, x: i32, y: i32) -> Result<i32, Never> {
Ok(x + y)
}
fn hey(&mut self, name: String) -> Result<String, Never> {
fn hey(&self, name: String) -> Result<String, Never> {
Ok(format!("Hey, {}.", name))
}
}
@@ -865,13 +865,13 @@ mod functional_test {
impl FutureService for Server {
type AddFut = Finished<i32, Never>;
fn add(&mut self, x: i32, y: i32) -> Self::AddFut {
fn add(&self, x: i32, y: i32) -> Self::AddFut {
finished(x + y)
}
type HeyFut = Finished<String, Never>;
fn hey(&mut self, name: String) -> Self::HeyFut {
fn hey(&self, name: String) -> Self::HeyFut {
finished(format!("Hey, {}.", name))
}
}
@@ -880,7 +880,7 @@ mod functional_test {
fn simple() {
let _ = env_logger::init();
let addr = Server.listen("localhost:0".first_socket_addr()).wait().unwrap();
let mut client = FutureClient::connect(&addr).wait().unwrap();
let client = FutureClient::connect(&addr).wait().unwrap();
assert_eq!(3, client.add(1, 2).wait().unwrap());
assert_eq!("Hey, Tim.", client.hey("Tim".to_string()).wait().unwrap());
}
@@ -889,7 +889,7 @@ mod functional_test {
fn concurrent() {
let _ = env_logger::init();
let addr = Server.listen("localhost:0".first_socket_addr()).wait().unwrap();
let mut client = FutureClient::connect(&addr).wait().unwrap();
let client = FutureClient::connect(&addr).wait().unwrap();
let req1 = client.add(1, 2);
let req2 = client.add(3, 4);
let req3 = client.hey("Tim".to_string());
@@ -902,7 +902,7 @@ mod functional_test {
fn other_service() {
let _ = env_logger::init();
let addr = Server.listen("localhost:0".first_socket_addr()).wait().unwrap();
let mut client =
let client =
super::other_service::FutureClient::connect(&addr).wait().unwrap();
match client.foo().wait().err().unwrap() {
::Error::ServerDeserialize(_) => {} // good
@@ -923,7 +923,7 @@ mod functional_test {
impl error_service::FutureService for ErrorServer {
type BarFut = ::futures::Failed<u32, ::util::Message>;
fn bar(&mut self) -> Self::BarFut {
fn bar(&self) -> Self::BarFut {
info!("Called bar");
failed("lol jk".into())
}
@@ -938,7 +938,7 @@ mod functional_test {
let _ = env_logger::init();
let addr = ErrorServer.listen("localhost:0".first_socket_addr()).wait().unwrap();
let mut client = FutureClient::connect(&addr).wait().unwrap();
let client = FutureClient::connect(&addr).wait().unwrap();
client.bar()
.then(move |result| {
match result.err().unwrap() {
@@ -952,7 +952,7 @@ mod functional_test {
.wait()
.unwrap();
let mut client = SyncClient::connect(&addr).unwrap();
let client = SyncClient::connect(&addr).unwrap();
match client.bar().err().unwrap() {
::Error::App(e) => {
assert_eq!(e.description(), "lol jk");

View File

@@ -121,7 +121,6 @@ impl<T, Encode, Decode> ServerProto<T> for Proto<Encode, Decode>
{
type Response = Encode;
type Request = Result<Decode, bincode::DeserializeError>;
type Error = io::Error;
type Transport = Framed<T, Codec<Encode, Decode>>;
type BindTransport = Result<Self::Transport, io::Error>;
@@ -137,7 +136,6 @@ impl<T, Encode, Decode> ClientProto<T> for Proto<Encode, Decode>
{
type Response = Result<Decode, bincode::DeserializeError>;
type Request = Encode;
type Error = io::Error;
type Transport = Framed<T, Codec<Encode, Decode>>;
type BindTransport = Result<Self::Transport, io::Error>;