mirror of
https://github.com/OMGeeky/tarpc.git
synced 2026-01-17 00:42:15 +01:00
Merge master into listener.
This commit is contained in:
@@ -23,7 +23,7 @@ function then returns the value produced by that other server.
|
||||
Add to your `Cargo.toml` dependencies:
|
||||
|
||||
```toml
|
||||
tarpc = "0.3.0"
|
||||
tarpc = "0.4.0"
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
## 1.3 (2016-02-20)
|
||||
## 0.4 (2016-04-02)
|
||||
|
||||
### Breaking Changes
|
||||
* Updated to the latest version of serde, 0.7.0. Because tarpc exposes serde in
|
||||
its API, this forces downstream code to update to the latest version of
|
||||
serde, as well.
|
||||
|
||||
## 0.3 (2016-02-20)
|
||||
|
||||
### Breaking Changes
|
||||
* The timeout arg to `serve` was replaced with a `Config` struct, which
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
# Pre-push hook for the tarpc repository. To use this hook, copy it to .git/hooks in your repository
|
||||
# root.
|
||||
#
|
||||
# This hook runs tests to make sure only working code is being pushed. If present, multirust is used
|
||||
# This hook runs tests to make sure only working code is being pushed. If present, rustup is used
|
||||
# to build and test the code on the appropriate toolchains. The working copy must not contain
|
||||
# uncommitted changes, since the script currently just runs cargo build/test in the working copy.
|
||||
#
|
||||
@@ -67,7 +67,7 @@ run_cargo() {
|
||||
fi
|
||||
if [ "$3" != "" ]; then
|
||||
printf "${PREFIX} $VERB $2 on $3 ... "
|
||||
multirust run $3 cargo $1 --manifest-path $2/Cargo.toml &>/dev/null
|
||||
rustup run $3 cargo $1 --manifest-path $2/Cargo.toml &>/dev/null
|
||||
else
|
||||
printf "${PREFIX} $VERB $2 ... "
|
||||
cargo $1 --manifest-path $2/Cargo.toml &>/dev/null
|
||||
@@ -83,7 +83,7 @@ run_cargo() {
|
||||
TOOLCHAIN_RESULT=0
|
||||
check_toolchain() {
|
||||
printf "${PREFIX} Checking for $1 toolchain ... "
|
||||
if [[ $(multirust list-toolchain) =~ $1 ]]; then
|
||||
if [[ $(rustup toolchain list) =~ $1 ]]; then
|
||||
printf "${SUCCESS}\n"
|
||||
else
|
||||
TOOLCHAIN_RESULT=1
|
||||
@@ -92,8 +92,8 @@ check_toolchain() {
|
||||
fi
|
||||
}
|
||||
|
||||
printf "${PREFIX} Checking for multirust ... "
|
||||
command -v multirust &>/dev/null
|
||||
printf "${PREFIX} Checking for rustup ... "
|
||||
command -v rustup &>/dev/null
|
||||
if [ "$?" == 0 ] && [ "${TARPC_USE_CURRENT_TOOLCHAIN}" == "" ]; then
|
||||
printf "${SUCCESS}\n"
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "tarpc"
|
||||
version = "0.3.0"
|
||||
version = "0.4.0"
|
||||
authors = ["Adam Wright <adam.austin.wright@gmail.com>", "Tim Kuehn <timothy.j.kuehn@gmail.com>"]
|
||||
license = "MIT"
|
||||
documentation = "https://google.github.io/tarpc"
|
||||
@@ -11,13 +11,13 @@ readme = "../README.md"
|
||||
description = "An RPC framework for Rust with a focus on ease of use."
|
||||
|
||||
[dependencies]
|
||||
bincode = "^0.4.0"
|
||||
log = "^0.3.5"
|
||||
scoped-pool = "^0.1.8"
|
||||
serde = "^0.6.15"
|
||||
unix_socket = "^0.5.0"
|
||||
bincode = "0.5"
|
||||
log = "0.3"
|
||||
scoped-pool = "0.1"
|
||||
serde = "0.7"
|
||||
unix_socket = "0.5"
|
||||
|
||||
[dev-dependencies]
|
||||
lazy_static = "^0.1.15"
|
||||
env_logger = "^0.3.2"
|
||||
tempdir = "^0.3.4"
|
||||
lazy_static = "0.1"
|
||||
env_logger = "0.3"
|
||||
tempdir = "0.3"
|
||||
|
||||
@@ -110,7 +110,7 @@ macro_rules! impl_serialize {
|
||||
match *self {
|
||||
$(
|
||||
$impler::$name(ref field) =>
|
||||
$crate::macros::serde::Serializer::visit_newtype_variant(
|
||||
$crate::macros::serde::Serializer::serialize_newtype_variant(
|
||||
serializer,
|
||||
stringify!($impler),
|
||||
$n,
|
||||
@@ -165,11 +165,12 @@ macro_rules! impl_deserialize {
|
||||
}
|
||||
)*
|
||||
return ::std::result::Result::Err(
|
||||
$crate::macros::serde::de::Error::syntax("expected a field")
|
||||
$crate::macros::serde::de::Error::custom(
|
||||
format!("No variants have a value of {}!", value))
|
||||
);
|
||||
}
|
||||
}
|
||||
deserializer.visit_struct_field(__FieldVisitor)
|
||||
deserializer.deserialize_struct_field(__FieldVisitor)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,7 +198,7 @@ macro_rules! impl_deserialize {
|
||||
stringify!($name)
|
||||
),*
|
||||
];
|
||||
deserializer.visit_enum(stringify!($impler), VARIANTS, __Visitor)
|
||||
deserializer.deserialize_enum(stringify!($impler), VARIANTS, __Visitor)
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
use bincode::{self, SizeLimit};
|
||||
use bincode::serde::{deserialize_from, serialize_into};
|
||||
use serde;
|
||||
use serde::de::value::Error::EndOfStream;
|
||||
use std::io::{self, Read, Write};
|
||||
use std::convert;
|
||||
use std::sync::Arc;
|
||||
@@ -40,10 +41,14 @@ impl convert::From<bincode::serde::SerializeError> for Error {
|
||||
impl convert::From<bincode::serde::DeserializeError> for Error {
|
||||
fn from(err: bincode::serde::DeserializeError) -> Error {
|
||||
match err {
|
||||
bincode::serde::DeserializeError::IoError(ref err)
|
||||
if err.kind() == io::ErrorKind::ConnectionReset => Error::ConnectionBroken,
|
||||
bincode::serde::DeserializeError::EndOfStreamError => Error::ConnectionBroken,
|
||||
bincode::serde::DeserializeError::IoError(err) => Error::Io(Arc::new(err)),
|
||||
bincode::serde::DeserializeError::Serde(EndOfStream) => Error::ConnectionBroken,
|
||||
bincode::serde::DeserializeError::IoError(err) => {
|
||||
match err.kind() {
|
||||
io::ErrorKind::ConnectionReset |
|
||||
io::ErrorKind::UnexpectedEof => Error::ConnectionBroken,
|
||||
_ => Error::Io(Arc::new(err)),
|
||||
}
|
||||
}
|
||||
err => panic!("Unexpected error during deserialization: {:?}", err),
|
||||
}
|
||||
}
|
||||
@@ -92,7 +97,6 @@ mod test {
|
||||
use std::sync::{Arc, Barrier, Mutex};
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
use transport::tcp::TcpTransport;
|
||||
|
||||
fn test_timeout() -> Option<Duration> {
|
||||
Some(Duration::from_secs(1))
|
||||
@@ -180,7 +184,7 @@ mod test {
|
||||
fn force_shutdown() {
|
||||
let _ = env_logger::init();
|
||||
let server = Arc::new(Server::new());
|
||||
let serve_handle = server.spawn_with_config(TcpTransport("localhost:0"),
|
||||
let serve_handle = server.spawn_with_config("localhost:0",
|
||||
Config { timeout: Some(Duration::new(0, 10)) })
|
||||
.unwrap();
|
||||
let client: Client<(), u64, _> = Client::new(serve_handle.dialer()).unwrap();
|
||||
@@ -193,7 +197,7 @@ mod test {
|
||||
fn client_failed_rpc() {
|
||||
let _ = env_logger::init();
|
||||
let server = Arc::new(Server::new());
|
||||
let serve_handle = server.spawn_with_config(TcpTransport("localhost:0"),
|
||||
let serve_handle = server.spawn_with_config("localhost:0",
|
||||
Config { timeout: test_timeout() })
|
||||
.unwrap();
|
||||
let client: Arc<Client<(), u64, _>> = Arc::new(Client::new(serve_handle.dialer()).unwrap());
|
||||
|
||||
@@ -19,11 +19,11 @@ impl<T: Serialize> Serialize for Packet<T> {
|
||||
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error>
|
||||
where S: Serializer
|
||||
{
|
||||
serializer.visit_struct(PACKET,
|
||||
MapVisitor {
|
||||
value: self,
|
||||
state: 0,
|
||||
})
|
||||
serializer.serialize_struct(PACKET,
|
||||
MapVisitor {
|
||||
value: self,
|
||||
state: 0,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,11 +40,11 @@ impl<'a, T: Serialize> ser::MapVisitor for MapVisitor<'a, T> {
|
||||
match self.state {
|
||||
0 => {
|
||||
self.state += 1;
|
||||
Ok(Some(try!(serializer.visit_struct_elt(RPC_ID, &self.value.rpc_id))))
|
||||
Ok(Some(try!(serializer.serialize_struct_elt(RPC_ID, &self.value.rpc_id))))
|
||||
}
|
||||
1 => {
|
||||
self.state += 1;
|
||||
Ok(Some(try!(serializer.visit_struct_elt(MESSAGE, &self.value.message))))
|
||||
Ok(Some(try!(serializer.serialize_struct_elt(MESSAGE, &self.value.message))))
|
||||
}
|
||||
_ => Ok(None),
|
||||
}
|
||||
@@ -62,7 +62,7 @@ impl<T: Deserialize> Deserialize for Packet<T> {
|
||||
where D: Deserializer
|
||||
{
|
||||
const FIELDS: &'static [&'static str] = &[RPC_ID, MESSAGE];
|
||||
deserializer.visit_struct(PACKET, FIELDS, Visitor(PhantomData))
|
||||
deserializer.deserialize_struct(PACKET, FIELDS, Visitor(PhantomData))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user