v0.7 looks like a good step forward. However, from my point-of-view, the release note misses off one significant change: etcd::Client is no longer Send (or Sync). This means that it is difficult to use in a multithreaded application, even when wrapped in an Mutex.
It appears that making hyper not suitable for multithreading might be deliberate. However, I don't think that needs to be a true of etcd::Client objects. It might even just be a matter of switching from using std::rc::{Rc,Weak}
to std::sync::{Arc,Weak}
.
Was it a conscious decision not to support multithreading? (If so, why? Performance?) Might you consider doing so?
error[E0277]: the trait bound `std::rc::Weak<std::cell::RefCell<tokio_core::reactor::Inner>>: std::marker::Send` is not satisfied in `std::result::Result<etcd::Client<hyper::client::connect::HttpConnector>, etcd::Error>`
--> src/bin.rs:12:5
|
12 | test_send_trait(arc_etcd);
| ^^^^^^^^^^^^^^^ `std::rc::Weak<std::cell::RefCell<tokio_core::reactor::Inner>>` cannot be sent between threads safely
|
= help: within `std::result::Result<etcd::Client<hyper::client::connect::HttpConnector>, etcd::Error>`, the trait `std::marker::Send` is not implemented for `std::rc::Weak<std::cell::RefCell<tokio_core::reactor::Inner>>`
= note: required because it appears within the type `tokio_core::reactor::Handle`
= note: required because it appears within the type `hyper::client::Client<hyper::client::connect::HttpConnector>`
= note: required because it appears within the type `etcd::http::HttpClient<hyper::client::connect::HttpConnector>`
= note: required because it appears within the type `etcd::Client<hyper::client::connect::HttpConnector>`
= note: required because it appears within the type `std::result::Result<etcd::Client<hyper::client::connect::HttpConnector>, etcd::Error>`
= note: required because of the requirements on the impl of `std::marker::Send` for `std::sync::Mutex<std::result::Result<etcd::Client<hyper::client::connect::HttpConnector>, etcd::Error>>`
= note: required because of the requirements on the impl of `std::marker::Send` for `std::sync::Arc<std::sync::Mutex<std::result::Result<etcd::Client<hyper::client::connect::HttpConnector>, etcd::Error>>>`
= note: required by `test_send_trait`
error[E0277]: the trait bound `std::rc::Rc<std::cell::RefCell<hyper::client::pool::PoolInner<tokio_proto::util::client_proxy::ClientProxy<tokio_proto::streaming::message::Message<hyper::http::MessageHead<hyper::http::RequestLine>, hyper::http::body::Body>, tokio_proto::streaming::message::Message<hyper::http::MessageHead<hyper::http::RawStatus>, tokio_proto::streaming::body::Body<hyper::http::chunk::Chunk, hyper::error::Error>>, hyper::error::Error>>>>: std::marker::Send` is not satisfied in `std::result::Result<etcd::Client<hyper::client::connect::HttpConnector>, etcd::Error>`
--> src/bin.rs:12:5
|
12 | test_send_trait(arc_etcd);
| ^^^^^^^^^^^^^^^ `std::rc::Rc<std::cell::RefCell<hyper::client::pool::PoolInner<tokio_proto::util::client_proxy::ClientProxy<tokio_proto::streaming::message::Message<hyper::http::MessageHead<hyper::http::RequestLine>, hyper::http::body::Body>, tokio_proto::streaming::message::Message<hyper::http::MessageHead<hyper::http::RawStatus>, tokio_proto::streaming::body::Body<hyper::http::chunk::Chunk, hyper::error::Error>>, hyper::error::Error>>>>` cannot be sent between threads safely
|
= help: within `std::result::Result<etcd::Client<hyper::client::connect::HttpConnector>, etcd::Error>`, the trait `std::marker::Send` is not implemented for `std::rc::Rc<std::cell::RefCell<hyper::client::pool::PoolInner<tokio_proto::util::client_proxy::ClientProxy<tokio_proto::streaming::message::Message<hyper::http::MessageHead<hyper::http::RequestLine>, hyper::http::body::Body>, tokio_proto::streaming::message::Message<hyper::http::MessageHead<hyper::http::RawStatus>, tokio_proto::streaming::body::Body<hyper::http::chunk::Chunk, hyper::error::Error>>, hyper::error::Error>>>>`
= note: required because it appears within the type `hyper::client::pool::Pool<tokio_proto::util::client_proxy::ClientProxy<tokio_proto::streaming::message::Message<hyper::http::MessageHead<hyper::http::RequestLine>, hyper::http::body::Body>, tokio_proto::streaming::message::Message<hyper::http::MessageHead<hyper::http::RawStatus>, tokio_proto::streaming::body::Body<hyper::http::chunk::Chunk, hyper::error::Error>>, hyper::error::Error>>`
= note: required because it appears within the type `hyper::client::Client<hyper::client::connect::HttpConnector>`
= note: required because it appears within the type `etcd::http::HttpClient<hyper::client::connect::HttpConnector>`
= note: required because it appears within the type `etcd::Client<hyper::client::connect::HttpConnector>`
= note: required because it appears within the type `std::result::Result<etcd::Client<hyper::client::connect::HttpConnector>, etcd::Error>`
= note: required because of the requirements on the impl of `std::marker::Send` for `std::sync::Mutex<std::result::Result<etcd::Client<hyper::client::connect::HttpConnector>, etcd::Error>>`
= note: required because of the requirements on the impl of `std::marker::Send` for `std::sync::Arc<std::sync::Mutex<std::result::Result<etcd::Client<hyper::client::connect::HttpConnector>, etcd::Error>>>`
= note: required by `test_send_trait`