mirror of
https://github.com/OMGeeky/tarpc.git
synced 2026-02-23 15:49:54 +01:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
32e0b0d7f8 | ||
|
|
b87c52758e | ||
|
|
9235e12904 | ||
|
|
265fe56fa6 | ||
|
|
7b5b29a9c3 | ||
|
|
fe978f2c56 | ||
|
|
44f472c65c | ||
|
|
e8fcf0e4de | ||
|
|
2eb0b2cc83 | ||
|
|
a8766a9200 | ||
|
|
ef96c87226 | ||
|
|
3543b34f2b | ||
|
|
4c1d15f8ea | ||
|
|
ece1cc60b9 | ||
|
|
7d8a508379 |
@@ -68,7 +68,7 @@ items expanded by a `service!` invocation.
|
||||
|
||||
## Additional Features
|
||||
- Concurrent requests from a single client.
|
||||
- Any type that `impl`s `serde`'s Serialize` and `Deserialize` can be used in the rpc signatures.
|
||||
- Any type that `impl`s `serde`'s `Serialize` and `Deserialize` can be used in the rpc signatures.
|
||||
- Attributes can be specified on rpc methods. These will be included on both the `Service` trait
|
||||
methods as well as on the `Client`'s stub methods.
|
||||
- Just like regular fns, the return type can be left off when it's `-> ()`.
|
||||
|
||||
@@ -92,9 +92,8 @@ FMTRESULT=0
|
||||
for file in $(git diff --name-only --cached);
|
||||
do
|
||||
if [ ${file: -3} == ".rs" ]; then
|
||||
HASH=$(shasum $file)
|
||||
NEW_HASH=$(rustfmt --write-mode=display $file | shasum)
|
||||
if [ "${HASH}" != "${NEW_HASH}" ]; then
|
||||
diff=$(rustfmt --skip-children --write-mode=diff $file)
|
||||
if grep --quiet "^Diff at line" <<< "$diff"; then
|
||||
FMTRESULT=1
|
||||
fi
|
||||
fi
|
||||
@@ -105,6 +104,7 @@ if [ "${TARPC_SKIP_RUSTFMT}" == 1 ]; then
|
||||
elif [ ${FMTRESULT} != 0 ]; then
|
||||
FAILED=1
|
||||
printf "${FAILURE}\n"
|
||||
echo "$diff" | sed '/Using rustfmt.*$/d'
|
||||
else
|
||||
printf "${SUCCESS}\n"
|
||||
fi
|
||||
|
||||
@@ -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,11 +11,11 @@ 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.5"
|
||||
serde = "^0.6.14"
|
||||
bincode = "^0.5"
|
||||
log = "^0.3"
|
||||
scoped-pool = "^0.1"
|
||||
serde = "^0.7"
|
||||
|
||||
[dev-dependencies]
|
||||
lazy_static = "^0.1.15"
|
||||
env_logger = "^0.3.2"
|
||||
lazy_static = "^0.1"
|
||||
env_logger = "^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),
|
||||
}
|
||||
}
|
||||
@@ -180,9 +185,7 @@ mod test {
|
||||
let _ = env_logger::init();
|
||||
let server = Arc::new(Server::new());
|
||||
let serve_handle = server.spawn_with_config("localhost:0",
|
||||
Config {
|
||||
timeout: Some(Duration::new(0, 10))
|
||||
})
|
||||
Config { timeout: Some(Duration::new(0, 10)) })
|
||||
.unwrap();
|
||||
let addr = serve_handle.local_addr().clone();
|
||||
let client: Client<(), u64> = Client::new(addr).unwrap();
|
||||
@@ -196,9 +199,7 @@ mod test {
|
||||
let _ = env_logger::init();
|
||||
let server = Arc::new(Server::new());
|
||||
let serve_handle = server.spawn_with_config("localhost:0",
|
||||
Config {
|
||||
timeout: test_timeout(),
|
||||
})
|
||||
Config { timeout: test_timeout() })
|
||||
.unwrap();
|
||||
let addr = serve_handle.local_addr().clone();
|
||||
let client: Arc<Client<(), u64>> = Arc::new(Client::new(addr).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))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -214,7 +214,7 @@ pub trait Serve: Send + Sync + Sized {
|
||||
/// spawn
|
||||
fn spawn<A>(self, addr: A) -> io::Result<ServeHandle>
|
||||
where A: ToSocketAddrs,
|
||||
Self: 'static,
|
||||
Self: 'static
|
||||
{
|
||||
self.spawn_with_config(addr, Config::default())
|
||||
}
|
||||
@@ -222,7 +222,7 @@ pub trait Serve: Send + Sync + Sized {
|
||||
/// spawn
|
||||
fn spawn_with_config<A>(self, addr: A, config: Config) -> io::Result<ServeHandle>
|
||||
where A: ToSocketAddrs,
|
||||
Self: 'static,
|
||||
Self: 'static
|
||||
{
|
||||
let listener = try!(TcpListener::bind(&addr));
|
||||
let addr = try!(listener.local_addr());
|
||||
|
||||
Reference in New Issue
Block a user