You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by ko...@apache.org on 2025/12/17 05:39:28 UTC

(opendal) branch extract-upyun-service created (now e1d574d15)

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

koushiro pushed a change to branch extract-upyun-service
in repository https://gitbox.apache.org/repos/asf/opendal.git


      at e1d574d15 refactor: Split upyun service to new crate

This branch includes the following new commits:

     new e1d574d15 refactor: Split upyun service to new crate

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(opendal) 01/01: refactor: Split upyun service to new crate

Posted by ko...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

koushiro pushed a commit to branch extract-upyun-service
in repository https://gitbox.apache.org/repos/asf/opendal.git

commit e1d574d155ef5fea7693203c997fc21bcafd9904
Author: koushiro <ko...@gmail.com>
AuthorDate: Wed Dec 17 13:39:13 2025 +0800

    refactor: Split upyun service to new crate
---
 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                     | 52 ++++++++++++++++++++++
 .../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, 107 insertions(+), 44 deletions(-)

diff --git a/core/Cargo.lock b/core/Cargo.lock
index e03ff0760..cc668a691 100644
--- a/core/Cargo.lock
+++ b/core/Cargo.lock
@@ -5583,6 +5583,7 @@ dependencies = [
  "opendal-service-sled",
  "opendal-service-sqlite",
  "opendal-service-tikv",
+ "opendal-service-upyun",
  "opendal-service-vercel-blob",
  "opendal-testkit",
  "opentelemetry",
@@ -5645,7 +5646,6 @@ dependencies = [
  "getrandom 0.2.16",
  "hdfs-native",
  "hdrs",
- "hmac",
  "http 1.4.0",
  "http-body 1.0.1",
  "jiff",
@@ -5671,7 +5671,6 @@ dependencies = [
  "rocksdb",
  "serde",
  "serde_json",
- "sha1",
  "sha2",
  "size",
  "surrealdb",
@@ -6334,6 +6333,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 e6231e25f..d5597e05f 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -158,7 +158,7 @@ services-sqlite = ["dep:opendal-service-sqlite"]
 services-surrealdb = ["opendal-core/services-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"]
@@ -234,6 +234,7 @@ opendal-service-s3 = { path = "services/s3", version = "0.55.0", optional = true
 opendal-service-sled = { path = "services/sled", version = "0.55.0", optional = true, default-features = false }
 opendal-service-sqlite = { path = "services/sqlite", 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 edfaefc7d..22f46c486 100644
--- a/core/core/Cargo.toml
+++ b/core/core/Cargo.toml
@@ -82,7 +82,6 @@ services-seafile = []
 services-sftp = ["dep:openssh", "dep:openssh-sftp-client", "dep:fastpool"]
 services-surrealdb = ["dep:surrealdb"]
 services-swift = []
-services-upyun = ["dep:hmac", "dep:sha1"]
 services-vercel-artifacts = []
 services-webdav = []
 services-webhdfs = []
@@ -126,7 +125,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.
@@ -147,8 +145,6 @@ foundationdb = { version = "0.9.0", features = [
 ], 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 e1553e71d..7d3e17e46 100644
--- a/core/core/src/services/mod.rs
+++ b/core/core/src/services/mod.rs
@@ -139,11 +139,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..dfd283181
--- /dev/null
+++ b/core/services/upyun/Cargo.toml
@@ -0,0 +1,52 @@
+# 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",
+  "io-util",
+] }
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 055936fe5..2a41ca7df 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -94,6 +94,8 @@ pub mod services {
     pub use opendal_service_sqlite::*;
     #[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::*;
 }