Repository: elastic-rs/elastic (language: rust)

Issue:
AsyncClient is no longer Send or Sync
It appears the `pre_send` field on the AsyncSender stops the client from being `Send` and `Sync`. Is that intentional?

This came up because until now I was able to hold a `lazy_static` AsyncClient in my application, which no longer works. 


Discussion / hints:
Thanks for the report! This wasn't intentional, I'll fix that up and add some tests to ensure we don't accidentally regress the bounds.

Fix patch:
diff --git a/src/elastic/src/client/mod.rs b/src/elastic/src/client/mod.rs
index cc32e39cce..1af72d2435 100644
--- a/src/elastic/src/client/mod.rs
+++ b/src/elastic/src/client/mod.rs
@@ -708,5 +708,8 @@ mod tests {
     fn client_is_send_sync() {
         assert_send::<SyncClient>();
         assert_sync::<SyncClient>();
+
+        assert_send::<AsyncClient>();
+        assert_sync::<AsyncClient>();
     }
 }
diff --git a/src/elastic/src/client/sender/async.rs b/src/elastic/src/client/sender/async.rs
index e42be21e61..1fd90d83bb 100644
--- a/src/elastic/src/client/sender/async.rs
+++ b/src/elastic/src/client/sender/async.rs
@@ -95,7 +95,7 @@ pub struct AsyncSender {
         Arc<
             Fn(
                 &mut AsyncHttpRequest,
-            ) -> Box<Future<Item = (), Error = Box<StdError + Send + Sync>>>,
+            ) -> Box<Future<Item = (), Error = Box<StdError + Send + Sync>>> + Send + Sync,
         >,
     >,
 }
@@ -329,7 +329,7 @@ pub struct AsyncClientBuilder {
         Arc<
             Fn(
                 &mut AsyncHttpRequest,
-            ) -> Box<Future<Item = (), Error = Box<StdError + Send + Sync>>>,
+            ) -> Box<Future<Item = (), Error = Box<StdError + Send + Sync>>> + Send + Sync,
         >,
     >,
 }
@@ -524,7 +524,7 @@ impl AsyncClientBuilder {
         pre_send: impl Fn(
                 &mut AsyncHttpRequest,
             ) -> Box<Future<Item = (), Error = Box<StdError + Send + Sync>>>
-            + 'static,
+            + Send + Sync + 'static,
     ) -> Self {
         self.pre_send = Some(Arc::new(pre_send));
 


Test patch: