This is an automated email from the ASF dual-hosted git repository.

xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal.git


The following commit(s) were added to refs/heads/main by this push:
     new e7865fdff refactor: Migrate azfile services to context based http 
client (#5816)
e7865fdff is described below

commit e7865fdff6264f08e60a5747b95ce2b4f7cfadb9
Author: miro <[email protected]>
AuthorDate: Wed Mar 19 15:22:24 2025 +0800

    refactor: Migrate azfile services to context based http client (#5816)
---
 core/src/services/azfile/backend.rs | 22 ++++++++++++----------
 core/src/services/azfile/core.rs    |  5 ++---
 2 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/core/src/services/azfile/backend.rs 
b/core/src/services/azfile/backend.rs
index 9636d1ed6..84820fad5 100644
--- a/core/src/services/azfile/backend.rs
+++ b/core/src/services/azfile/backend.rs
@@ -41,6 +41,8 @@ const DEFAULT_AZFILE_ENDPOINT_SUFFIX: &str = 
"file.core.windows.net";
 
 impl Configurator for AzfileConfig {
     type Builder = AzfileBuilder;
+
+    #[allow(deprecated)]
     fn into_builder(self) -> Self::Builder {
         AzfileBuilder {
             config: self,
@@ -54,6 +56,8 @@ impl Configurator for AzfileConfig {
 #[derive(Default, Clone)]
 pub struct AzfileBuilder {
     config: AzfileConfig,
+
+    #[deprecated(since = "0.53.0", note = "Use `Operator::update_http_client` 
instead")]
     http_client: Option<HttpClient>,
 }
 
@@ -133,6 +137,8 @@ impl AzfileBuilder {
     ///
     /// This API is part of OpenDAL's Raw API. `HttpClient` could be changed
     /// during minor updates.
+    #[deprecated(since = "0.53.0", note = "Use `Operator::update_http_client` 
instead")]
+    #[allow(deprecated)]
     pub fn http_client(mut self, client: HttpClient) -> Self {
         self.http_client = Some(client);
         self
@@ -157,15 +163,6 @@ impl Builder for AzfileBuilder {
         }?;
         debug!("backend use endpoint {}", &endpoint);
 
-        let client = if let Some(client) = self.http_client {
-            client
-        } else {
-            HttpClient::new().map_err(|err| {
-                err.with_operation("Builder::build")
-                    .with_context("service", Scheme::Azfile)
-            })?
-        };
-
         let account_name_option = self
             .config
             .account_name
@@ -225,12 +222,17 @@ impl Builder for AzfileBuilder {
                             ..Default::default()
                         });
 
+                    // allow deprecated api here for compatibility
+                    #[allow(deprecated)]
+                    if let Some(client) = self.http_client {
+                        am.update_http_client(|_| client);
+                    }
+
                     am.into()
                 },
                 root,
                 endpoint,
                 loader: cred_loader,
-                client,
                 signer,
                 share_name: self.config.share_name.clone(),
             }),
diff --git a/core/src/services/azfile/core.rs b/core/src/services/azfile/core.rs
index b68f047cc..48f3640fa 100644
--- a/core/src/services/azfile/core.rs
+++ b/core/src/services/azfile/core.rs
@@ -49,7 +49,6 @@ pub struct AzfileCore {
     pub root: String,
     pub endpoint: String,
     pub share_name: String,
-    pub client: HttpClient,
     pub loader: AzureStorageLoader,
     pub signer: AzureStorageSigner,
 }
@@ -95,7 +94,7 @@ impl AzfileCore {
 
     #[inline]
     pub async fn send(&self, req: Request<Buffer>) -> Result<Response<Buffer>> 
{
-        self.client.send(req).await
+        self.info.http_client().send(req).await
     }
 
     pub async fn azfile_read(&self, path: &str, range: BytesRange) -> 
Result<Response<HttpBody>> {
@@ -116,7 +115,7 @@ impl AzfileCore {
 
         let mut req = 
req.body(Buffer::new()).map_err(new_request_build_error)?;
         self.sign(&mut req).await?;
-        self.client.fetch(req).await
+        self.info.http_client().fetch(req).await
     }
 
     pub async fn azfile_create_file(

Reply via email to