Repository: sugyan/atrium (language: rust)

Issue:
ReqwestClient shouldn't wrap reqwest::Client in Arc
`reqwest::Client` is already a thin wrapper over an `Arc`. `ReqwestClient` shouldn't add another one on top of it.


Discussion / hints:

Fix patch:
diff --git a/atrium-xrpc-client/src/isahc.rs b/atrium-xrpc-client/src/isahc.rs
index 06f5917e..6c0e446b 100644
--- a/atrium-xrpc-client/src/isahc.rs
+++ b/atrium-xrpc-client/src/isahc.rs
@@ -17,7 +17,7 @@ use std::sync::Arc;
 #[derive(Clone)]
 pub struct IsahcClient {
     base_uri: String,
-    client: Arc<Client>,
+    client: Client,
 }
 
 impl IsahcClient {
@@ -50,10 +50,9 @@ impl IsahcClientBuilder {
     pub fn build(self) -> IsahcClient {
         IsahcClient {
             base_uri: self.base_uri,
-            client: Arc::new(
-                self.client
-                    .unwrap_or(Client::new().expect("failed to create isahc client")),
-            ),
+            client: self
+                .client
+                .unwrap_or(Client::new().expect("failed to create isahc client")),
         }
     }
 }
diff --git a/atrium-xrpc-client/src/reqwest.rs b/atrium-xrpc-client/src/reqwest.rs
index 83039e91..22a97e90 100644
--- a/atrium-xrpc-client/src/reqwest.rs
+++ b/atrium-xrpc-client/src/reqwest.rs
@@ -3,7 +3,6 @@ use async_trait::async_trait;
 use atrium_xrpc::http::{Request, Response};
 use atrium_xrpc::{HttpClient, XrpcClient};
 use reqwest::Client;
-use std::sync::Arc;
 
 /// A [`reqwest`] based asynchronous client to make XRPC requests with.
 ///
@@ -17,7 +16,7 @@ use std::sync::Arc;
 #[derive(Clone)]
 pub struct ReqwestClient {
     base_uri: String,
-    client: Arc<Client>,
+    client: Client,
 }
 
 impl ReqwestClient {
@@ -50,7 +49,7 @@ impl ReqwestClientBuilder {
     pub fn build(self) -> ReqwestClient {
         ReqwestClient {
             base_uri: self.base_uri,
-            client: Arc::new(self.client.unwrap_or_default()),
+            client: self.client.unwrap_or_default(),
         }
     }
 }


Test patch: