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 1947198ff refactor: Migrate aliyun_drive services to context based 
http client (#5815)
1947198ff is described below

commit 1947198ff29c15fc7f9ce43689948da6d891b518
Author: miro <[email protected]>
AuthorDate: Wed Mar 19 15:21:52 2025 +0800

    refactor: Migrate aliyun_drive services to context based http client (#5815)
---
 core/src/services/aliyun_drive/backend.rs | 24 +++++++++++++-----------
 core/src/services/aliyun_drive/core.rs    |  3 +--
 2 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/core/src/services/aliyun_drive/backend.rs 
b/core/src/services/aliyun_drive/backend.rs
index 50f0eaa7e..c6abed478 100644
--- a/core/src/services/aliyun_drive/backend.rs
+++ b/core/src/services/aliyun_drive/backend.rs
@@ -40,6 +40,8 @@ use crate::*;
 
 impl Configurator for AliyunDriveConfig {
     type Builder = AliyunDriveBuilder;
+
+    #[allow(deprecated)]
     fn into_builder(self) -> Self::Builder {
         AliyunDriveBuilder {
             config: self,
@@ -53,6 +55,7 @@ impl Configurator for AliyunDriveConfig {
 pub struct AliyunDriveBuilder {
     config: AliyunDriveConfig,
 
+    #[deprecated(since = "0.53.0", note = "Use `Operator::update_http_client` 
instead")]
     http_client: Option<HttpClient>,
 }
 
@@ -120,6 +123,8 @@ impl AliyunDriveBuilder {
     ///
     /// 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
@@ -136,15 +141,6 @@ impl Builder for AliyunDriveBuilder {
         let root = 
normalize_root(&self.config.root.clone().unwrap_or_default());
         debug!("backend use root {}", &root);
 
-        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::AliyunDrive)
-            })?
-        };
-
         let sign = match self.config.access_token.clone() {
             Some(access_token) if !access_token.is_empty() => {
                 AliyunDriveSign::Access(access_token)
@@ -212,6 +208,13 @@ impl Builder for AliyunDriveBuilder {
                             list_has_content_type: true,
                             ..Default::default()
                         });
+
+                    // allow deprecated api here for compatibility
+                    #[allow(deprecated)]
+                    if let Some(client) = self.http_client {
+                        am.update_http_client(|_| client);
+                    }
+
                     am.into()
                 },
                 endpoint: "https://openapi.alipan.com".to_string(),
@@ -221,7 +224,6 @@ impl Builder for AliyunDriveBuilder {
                     drive_id: None,
                     sign,
                 })),
-                client,
                 dir_lock: Arc::new(Mutex::new(())),
             }),
         })
@@ -373,7 +375,7 @@ impl Access for AliyunDriveBackend {
             .body(Buffer::new())
             .map_err(new_request_build_error)?;
 
-        let resp = self.core.client.fetch(req).await?;
+        let resp = self.core.info.http_client().fetch(req).await?;
         let status = resp.status();
         match status {
             StatusCode::OK | StatusCode::PARTIAL_CONTENT => {
diff --git a/core/src/services/aliyun_drive/core.rs 
b/core/src/services/aliyun_drive/core.rs
index 7a934c1fb..197aac65e 100644
--- a/core/src/services/aliyun_drive/core.rs
+++ b/core/src/services/aliyun_drive/core.rs
@@ -67,7 +67,6 @@ pub struct AliyunDriveCore {
     pub drive_type: DriveType,
 
     pub signer: Arc<Mutex<AliyunDriveSigner>>,
-    pub client: HttpClient,
     pub dir_lock: Arc<Mutex<()>>,
 }
 
@@ -101,7 +100,7 @@ impl AliyunDriveCore {
                     .expect("access token must be valid header value"),
             );
         }
-        let res = self.client.send(req).await?;
+        let res = self.info.http_client().send(req).await?;
         if !res.status().is_success() {
             return Err(parse_error(res));
         }

Reply via email to