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 2b43da285 refactor: Split upyun service to new crate (#7048)
2b43da285 is described below

commit 2b43da285fbbf91bd786ef6f1e4c4224ebcdb35b
Author: Qinxuan Chen <[email protected]>
AuthorDate: Wed Dec 17 19:34:23 2025 +0800

    refactor: Split upyun service to new crate (#7048)
---
 core/Cargo.lock                                    | 22 +++++++++-
 core/Cargo.toml                                    |  3 +-
 core/core/Cargo.toml                               |  4 --
 core/core/src/services/mod.rs                      |  5 ---
 core/services/upyun/Cargo.toml                     | 48 ++++++++++++++++++++++
 .../upyun => services/upyun/src}/backend.rs        |  4 +-
 .../upyun => services/upyun/src}/config.rs         | 16 ++++----
 .../services/upyun => services/upyun/src}/core.rs  |  4 +-
 .../upyun => services/upyun/src}/deleter.rs        |  4 +-
 .../services/upyun => services/upyun/src}/docs.md  |  4 +-
 .../services/upyun => services/upyun/src}/error.rs |  5 +--
 .../upyun/mod.rs => services/upyun/src/lib.rs}     | 11 +++--
 .../upyun => services/upyun/src}/lister.rs         | 11 ++---
 .../upyun => services/upyun/src}/writer.rs         |  4 +-
 core/src/lib.rs                                    |  2 +
 15 files changed, 103 insertions(+), 44 deletions(-)

diff --git a/core/Cargo.lock b/core/Cargo.lock
index 72c8802cb..d0ba13b6a 100644
--- a/core/Cargo.lock
+++ b/core/Cargo.lock
@@ -5592,6 +5592,7 @@ dependencies = [
  "opendal-service-sqlite",
  "opendal-service-surrealdb",
  "opendal-service-tikv",
+ "opendal-service-upyun",
  "opendal-service-vercel-blob",
  "opendal-testkit",
  "opentelemetry",
@@ -5651,7 +5652,6 @@ dependencies = [
  "getrandom 0.2.16",
  "hdfs-native",
  "hdrs",
- "hmac",
  "http 1.4.0",
  "http-body 1.0.1",
  "jiff",
@@ -5677,7 +5677,6 @@ dependencies = [
  "rocksdb",
  "serde",
  "serde_json",
- "sha1",
  "sha2",
  "size",
  "tokio",
@@ -6462,6 +6461,25 @@ dependencies = [
  "tikv-client",
 ]
 
+[[package]]
+name = "opendal-service-upyun"
+version = "0.55.0"
+dependencies = [
+ "base64 0.22.1",
+ "bytes",
+ "ctor",
+ "hmac",
+ "http 1.4.0",
+ "log",
+ "md-5",
+ "opendal-core",
+ "quick-xml",
+ "serde",
+ "serde_json",
+ "sha1",
+ "tokio",
+]
+
 [[package]]
 name = "opendal-service-vercel-blob"
 version = "0.55.0"
diff --git a/core/Cargo.toml b/core/Cargo.toml
index 9bed2f362..faaf0527c 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -158,7 +158,7 @@ services-sqlite = ["dep:opendal-service-sqlite"]
 services-surrealdb = ["dep:opendal-service-surrealdb"]
 services-swift = ["opendal-core/services-swift"]
 services-tikv = ["dep:opendal-service-tikv"]
-services-upyun = ["opendal-core/services-upyun"]
+services-upyun = ["dep:opendal-service-upyun"]
 services-vercel-artifacts = ["opendal-core/services-vercel-artifacts"]
 services-vercel-blob = ["dep:opendal-service-vercel-blob"]
 services-webdav = ["opendal-core/services-webdav"]
@@ -243,6 +243,7 @@ opendal-service-sled = { path = "services/sled", version = 
"0.55.0", optional =
 opendal-service-sqlite = { path = "services/sqlite", version = "0.55.0", 
optional = true, default-features = false }
 opendal-service-surrealdb = { path = "services/surrealdb", version = "0.55.0", 
optional = true, default-features = false }
 opendal-service-tikv = { path = "services/tikv", version = "0.55.0", optional 
= true, default-features = false }
+opendal-service-upyun = { path = "services/upyun", version = "0.55.0", 
optional = true, default-features = false }
 opendal-service-vercel-blob = { path = "services/vercel-blob", version = 
"0.55.0", optional = true, default-features = false }
 opendal-testkit = { path = "testkit", version = "0.55.0", optional = true }
 
diff --git a/core/core/Cargo.toml b/core/core/Cargo.toml
index 0fb075d3e..93fdf5686 100644
--- a/core/core/Cargo.toml
+++ b/core/core/Cargo.toml
@@ -73,7 +73,6 @@ services-rocksdb = ["dep:rocksdb", "internal-tokio-rt"]
 services-seafile = []
 services-sftp = ["dep:openssh", "dep:openssh-sftp-client", "dep:fastpool"]
 services-swift = []
-services-upyun = ["dep:hmac", "dep:sha1"]
 services-vercel-artifacts = []
 services-webdav = []
 services-webhdfs = []
@@ -117,7 +116,6 @@ uuid = { workspace = true, features = ["serde", "v4"] }
 # general dependencies.
 fastpool = { version = "1.0.2", optional = true }
 prost = { version = "0.13", optional = true }
-sha1 = { version = "0.10.6", optional = true }
 sha2 = { workspace = true, optional = true }
 
 # For http based services.
@@ -125,8 +123,6 @@ reqsign = { workspace = true, default-features = false, 
optional = true }
 
 # for services-hdfs
 hdrs = { version = "0.3.2", optional = true, features = ["async_file"] }
-# for services-upyun
-hmac = { version = "0.12.1", optional = true }
 # for services-moka
 moka = { version = "0.12", optional = true, features = ["future", "sync"] }
 # for services-mongodb
diff --git a/core/core/src/services/mod.rs b/core/core/src/services/mod.rs
index c2269d0a8..3df095ffb 100644
--- a/core/core/src/services/mod.rs
+++ b/core/core/src/services/mod.rs
@@ -94,11 +94,6 @@ mod swift;
 #[cfg(feature = "services-swift")]
 pub use self::swift::*;
 
-#[cfg(feature = "services-upyun")]
-mod upyun;
-#[cfg(feature = "services-upyun")]
-pub use upyun::*;
-
 #[cfg(feature = "services-vercel-artifacts")]
 mod vercel_artifacts;
 #[cfg(feature = "services-vercel-artifacts")]
diff --git a/core/services/upyun/Cargo.toml b/core/services/upyun/Cargo.toml
new file mode 100644
index 000000000..1f64da4df
--- /dev/null
+++ b/core/services/upyun/Cargo.toml
@@ -0,0 +1,48 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+[package]
+description = "Apache OpenDAL Upyun service implementation"
+name = "opendal-service-upyun"
+
+authors = { workspace = true }
+edition = { workspace = true }
+homepage = { workspace = true }
+license = { workspace = true }
+repository = { workspace = true }
+rust-version = { workspace = true }
+version = { workspace = true }
+
+[package.metadata.docs.rs]
+all-features = true
+
+[dependencies]
+base64 = { workspace = true }
+bytes = { workspace = true }
+ctor = { workspace = true }
+hmac = "0.12.1"
+http = { workspace = true }
+log = { workspace = true }
+md-5 = "0.10"
+opendal-core = { path = "../../core", version = "0.55.0", default-features = 
false }
+quick-xml = { workspace = true, features = ["serialize", "overlapped-lists"] }
+serde = { workspace = true, features = ["derive"] }
+serde_json = { workspace = true }
+sha1 = "0.10.6"
+
+[dev-dependencies]
+tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
diff --git a/core/core/src/services/upyun/backend.rs 
b/core/services/upyun/src/backend.rs
similarity index 99%
rename from core/core/src/services/upyun/backend.rs
rename to core/services/upyun/src/backend.rs
index 565315292..7918d6350 100644
--- a/core/core/src/services/upyun/backend.rs
+++ b/core/services/upyun/src/backend.rs
@@ -21,6 +21,8 @@ use std::sync::Arc;
 use http::Response;
 use http::StatusCode;
 use log::debug;
+use opendal_core::raw::*;
+use opendal_core::*;
 
 use super::UPYUN_SCHEME;
 use super::config::UpyunConfig;
@@ -30,8 +32,6 @@ use super::error::parse_error;
 use super::lister::UpyunLister;
 use super::writer::UpyunWriter;
 use super::writer::UpyunWriters;
-use crate::raw::*;
-use crate::*;
 
 /// [upyun](https://www.upyun.com/products/file-storage) services support.
 #[doc = include_str!("docs.md")]
diff --git a/core/core/src/services/upyun/config.rs 
b/core/services/upyun/src/config.rs
similarity index 88%
rename from core/core/src/services/upyun/config.rs
rename to core/services/upyun/src/config.rs
index 2501330ef..6b4f2a5e5 100644
--- a/core/core/src/services/upyun/config.rs
+++ b/core/services/upyun/src/config.rs
@@ -17,6 +17,7 @@
 
 use std::fmt::Debug;
 
+use opendal_core::*;
 use serde::Deserialize;
 use serde::Serialize;
 
@@ -49,10 +50,10 @@ impl Debug for UpyunConfig {
     }
 }
 
-impl crate::Configurator for UpyunConfig {
+impl Configurator for UpyunConfig {
     type Builder = UpyunBuilder;
 
-    fn from_uri(uri: &crate::types::OperatorUri) -> crate::Result<Self> {
+    fn from_uri(uri: &OperatorUri) -> Result<Self> {
         let mut map = uri.options().clone();
 
         if let Some(name) = uri.name() {
@@ -74,18 +75,17 @@ impl crate::Configurator for UpyunConfig {
 #[cfg(test)]
 mod tests {
     use super::*;
-    use crate::Configurator;
-    use crate::types::OperatorUri;
 
     #[test]
-    fn from_uri_extracts_bucket_and_root() {
+    fn from_uri_extracts_bucket_and_root() -> Result<()> {
         let uri = OperatorUri::new(
             "upyun://example-bucket/path/to/root",
             Vec::<(String, String)>::new(),
-        )
-        .unwrap();
-        let cfg = UpyunConfig::from_uri(&uri).unwrap();
+        )?;
+
+        let cfg = UpyunConfig::from_uri(&uri)?;
         assert_eq!(cfg.bucket, "example-bucket");
         assert_eq!(cfg.root.as_deref(), Some("path/to/root"));
+        Ok(())
     }
 }
diff --git a/core/core/src/services/upyun/core.rs 
b/core/services/upyun/src/core.rs
similarity index 99%
rename from core/core/src/services/upyun/core.rs
rename to core/services/upyun/src/core.rs
index 99d9210a1..c264198c8 100644
--- a/core/core/src/services/upyun/core.rs
+++ b/core/services/upyun/src/core.rs
@@ -26,12 +26,12 @@ use http::Request;
 use http::Response;
 use http::header;
 use md5::Digest;
+use opendal_core::raw::*;
+use opendal_core::*;
 use serde::Deserialize;
 use sha1::Sha1;
 
 use self::constants::*;
-use crate::raw::*;
-use crate::*;
 
 pub(super) mod constants {
     pub const X_UPYUN_FILE_TYPE: &str = "x-upyun-file-type";
diff --git a/core/core/src/services/upyun/deleter.rs 
b/core/services/upyun/src/deleter.rs
similarity index 96%
rename from core/core/src/services/upyun/deleter.rs
rename to core/services/upyun/src/deleter.rs
index a45927b63..68cd8e056 100644
--- a/core/core/src/services/upyun/deleter.rs
+++ b/core/services/upyun/src/deleter.rs
@@ -18,11 +18,11 @@
 use std::sync::Arc;
 
 use http::StatusCode;
+use opendal_core::raw::*;
+use opendal_core::*;
 
 use super::core::*;
 use super::error::parse_error;
-use crate::raw::*;
-use crate::*;
 
 pub struct UpyunDeleter {
     core: Arc<UpyunCore>,
diff --git a/core/core/src/services/upyun/docs.md 
b/core/services/upyun/src/docs.md
similarity index 93%
rename from core/core/src/services/upyun/docs.md
rename to core/services/upyun/src/docs.md
index 4e74ba6b3..f60437597 100644
--- a/core/core/src/services/upyun/docs.md
+++ b/core/services/upyun/src/docs.md
@@ -26,9 +26,9 @@ You can refer to [`UpyunBuilder`]'s docs for more information
 ### Via Builder
 
 ```rust,no_run
-use anyhow::Result;
-use opendal_core::services::Upyun;
 use opendal_core::Operator;
+use opendal_core::Result;
+use opendal_service_upyun::Upyun;
 
 #[tokio::main]
 async fn main() -> Result<()> {
diff --git a/core/core/src/services/upyun/error.rs 
b/core/services/upyun/src/error.rs
similarity index 98%
rename from core/core/src/services/upyun/error.rs
rename to core/services/upyun/src/error.rs
index 3a8567cd7..7efdb7e26 100644
--- a/core/core/src/services/upyun/error.rs
+++ b/core/services/upyun/src/error.rs
@@ -17,12 +17,11 @@
 
 use bytes::Buf;
 use http::Response;
+use opendal_core::raw::*;
+use opendal_core::*;
 use quick_xml::de;
 use serde::Deserialize;
 
-use crate::raw::*;
-use crate::*;
-
 /// UpyunError is the error returned by upyun service.
 #[derive(Default, Debug, Deserialize)]
 #[serde(default, rename_all = "PascalCase")]
diff --git a/core/core/src/services/upyun/mod.rs 
b/core/services/upyun/src/lib.rs
similarity index 84%
rename from core/core/src/services/upyun/mod.rs
rename to core/services/upyun/src/lib.rs
index 960f2d241..10359b9fd 100644
--- a/core/core/src/services/upyun/mod.rs
+++ b/core/services/upyun/src/lib.rs
@@ -15,10 +15,10 @@
 // specific language governing permissions and limitations
 // under the License.
 
-/// Default scheme for upyun service.
-pub const UPYUN_SCHEME: &str = "upyun";
+//! Upyun service implementation for Apache OpenDAL.
 
-use crate::types::DEFAULT_OPERATOR_REGISTRY;
+#![cfg_attr(docsrs, feature(doc_cfg))]
+#![deny(missing_docs)]
 
 mod backend;
 mod config;
@@ -31,7 +31,10 @@ mod writer;
 pub use backend::UpyunBuilder as Upyun;
 pub use config::UpyunConfig;
 
+/// Default scheme for upyun service.
+pub const UPYUN_SCHEME: &str = "upyun";
+
 #[ctor::ctor]
 fn register_upyun_service() {
-    DEFAULT_OPERATOR_REGISTRY.register::<Upyun>(UPYUN_SCHEME);
+    opendal_core::DEFAULT_OPERATOR_REGISTRY.register::<Upyun>(UPYUN_SCHEME);
 }
diff --git a/core/core/src/services/upyun/lister.rs 
b/core/services/upyun/src/lister.rs
similarity index 93%
rename from core/core/src/services/upyun/lister.rs
rename to core/services/upyun/src/lister.rs
index a9367def1..7e1d884d6 100644
--- a/core/core/src/services/upyun/lister.rs
+++ b/core/services/upyun/src/lister.rs
@@ -18,15 +18,12 @@
 use std::sync::Arc;
 
 use bytes::Buf;
+use opendal_core::raw::*;
+use opendal_core::*;
 
 use super::core::ListObjectsResponse;
 use super::core::UpyunCore;
 use super::error::parse_error;
-use crate::EntryMode;
-use crate::Metadata;
-use crate::Result;
-use crate::raw::oio::Entry;
-use crate::raw::*;
 
 pub struct UpyunLister {
     core: Arc<UpyunCore>,
@@ -84,13 +81,13 @@ impl oio::PageList for UpyunLister {
 
             let entry = if file.type_field == "folder" {
                 let path = format!("{path}/");
-                Entry::new(&path, Metadata::new(EntryMode::DIR))
+                oio::Entry::new(&path, Metadata::new(EntryMode::DIR))
             } else {
                 let m = Metadata::new(EntryMode::FILE)
                     .with_content_length(file.length)
                     .with_content_type(file.type_field)
                     
.with_last_modified(Timestamp::from_second(file.last_modified)?);
-                Entry::new(&path, m)
+                oio::Entry::new(&path, m)
             };
 
             ctx.entries.push_back(entry);
diff --git a/core/core/src/services/upyun/writer.rs 
b/core/services/upyun/src/writer.rs
similarity index 98%
rename from core/core/src/services/upyun/writer.rs
rename to core/services/upyun/src/writer.rs
index bc93b99b3..82a36bb20 100644
--- a/core/core/src/services/upyun/writer.rs
+++ b/core/services/upyun/src/writer.rs
@@ -18,12 +18,12 @@
 use std::sync::Arc;
 
 use http::StatusCode;
+use opendal_core::raw::*;
+use opendal_core::*;
 
 use super::core::UpyunCore;
 use super::core::constants::X_UPYUN_MULTI_UUID;
 use super::error::parse_error;
-use crate::raw::*;
-use crate::*;
 
 pub type UpyunWriters = oio::MultipartWriter<UpyunWriter>;
 
diff --git a/core/src/lib.rs b/core/src/lib.rs
index 6f0381af1..2b2bce19d 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -112,6 +112,8 @@ pub mod services {
     pub use opendal_service_surrealdb::*;
     #[cfg(feature = "services-tikv")]
     pub use opendal_service_tikv::*;
+    #[cfg(feature = "services-upyun")]
+    pub use opendal_service_upyun::*;
     #[cfg(feature = "services-vercel-blob")]
     pub use opendal_service_vercel_blob::*;
 }

Reply via email to