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 a9625c815 refactor: Split service gcs out of core (#7002)
a9625c815 is described below
commit a9625c81582eac3aa4b21a9866f5f2b74bb0acb4
Author: Jintao Zhang <[email protected]>
AuthorDate: Sun Dec 14 19:06:41 2025 +0800
refactor: Split service gcs out of core (#7002)
Signed-off-by: Jintao Zhang <[email protected]>
---
core/Cargo.lock | 23 +++++++++
core/Cargo.toml | 3 +-
core/core/Cargo.toml | 5 --
core/core/src/services/mod.rs | 5 --
core/services/gcs/Cargo.toml | 58 ++++++++++++++++++++++
.../services/gcs => services/gcs/src}/backend.rs | 11 +++-
.../services/gcs => services/gcs/src}/config.rs | 8 +--
.../src/services/gcs => services/gcs/src}/core.rs | 4 +-
.../services/gcs => services/gcs/src}/deleter.rs | 6 +--
.../src/services/gcs => services/gcs/src}/docs.md | 0
.../src/services/gcs => services/gcs/src}/error.rs | 4 +-
.../gcs/mod.rs => services/gcs/src/lib.rs} | 12 +++--
.../services/gcs => services/gcs/src}/lister.rs | 5 +-
.../src/services/gcs => services/gcs/src}/uri.rs | 0
.../services/gcs => services/gcs/src}/writer.rs | 4 +-
core/src/lib.rs | 2 +
16 files changed, 116 insertions(+), 34 deletions(-)
diff --git a/core/Cargo.lock b/core/Cargo.lock
index e9d0f278b..ac3a7bbd8 100644
--- a/core/Cargo.lock
+++ b/core/Cargo.lock
@@ -5502,6 +5502,7 @@ dependencies = [
"opendal-service-azfile",
"opendal-service-cloudflare-kv",
"opendal-service-ftp",
+ "opendal-service-gcs",
"opendal-service-ghac",
"opendal-service-hdfs-native",
"opendal-service-ipfs",
@@ -5907,6 +5908,28 @@ dependencies = [
"tokio",
]
+[[package]]
+name = "opendal-service-gcs"
+version = "0.55.0"
+dependencies = [
+ "backon",
+ "base64 0.22.1",
+ "bytes",
+ "ctor",
+ "http 1.4.0",
+ "log",
+ "opendal-core",
+ "percent-encoding",
+ "pretty_assertions",
+ "quick-xml",
+ "reqsign",
+ "reqwest",
+ "serde",
+ "serde_json",
+ "tokio",
+ "tracing-subscriber",
+]
+
[[package]]
name = "opendal-service-ghac"
version = "0.55.0"
diff --git a/core/Cargo.toml b/core/Cargo.toml
index 819100b5d..17e1f361c 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -118,7 +118,7 @@ services-etcd = ["opendal-core/services-etcd"]
services-foundationdb = ["opendal-core/services-foundationdb"]
services-fs = ["opendal-core/services-fs"]
services-ftp = ["dep:opendal-service-ftp"]
-services-gcs = ["opendal-core/services-gcs"]
+services-gcs = ["dep:opendal-service-gcs"]
services-gdrive = ["opendal-core/services-gdrive"]
services-ghac = ["dep:opendal-service-ghac"]
services-github = ["opendal-core/services-github"]
@@ -209,6 +209,7 @@ opendal-service-cloudflare-kv = { path =
"services/cloudflare-kv", version = "0.
opendal-service-ghac = { path = "services/ghac", version = "0.55.0", optional
= true, default-features = false }
opendal-service-hdfs-native = { path = "services/hdfs-native", version =
"0.55.0", optional = true, default-features = false }
opendal-service-ftp = { path = "services/ftp", version = "0.55.0", optional =
true, default-features = false }
+opendal-service-gcs = { path = "services/gcs", version = "0.55.0", optional =
true, default-features = false }
opendal-service-ipfs = { path = "services/ipfs", version = "0.55.0", optional
= true, default-features = false }
opendal-service-moka = { path = "services/moka", version = "0.55.0", optional
= true, default-features = false }
opendal-service-mysql = { path = "services/mysql", version = "0.55.0",
optional = true, default-features = false }
diff --git a/core/core/Cargo.toml b/core/core/Cargo.toml
index 957ddf3d1..425c61513 100644
--- a/core/core/Cargo.toml
+++ b/core/core/Cargo.toml
@@ -91,11 +91,6 @@ services-dropbox = []
services-etcd = ["dep:etcd-client", "dep:fastpool"]
services-foundationdb = ["dep:foundationdb"]
services-fs = ["tokio/fs", "internal-tokio-rt"]
-services-gcs = [
- "dep:reqsign",
- "reqsign?/services-google",
- "reqsign?/reqwest_request",
-]
services-gdrive = ["internal-path-cache"]
services-github = []
services-gridfs = ["dep:mongodb", "dep:mongodb-internal-macros"]
diff --git a/core/core/src/services/mod.rs b/core/core/src/services/mod.rs
index 4cc96c928..79ca49398 100644
--- a/core/core/src/services/mod.rs
+++ b/core/core/src/services/mod.rs
@@ -79,11 +79,6 @@ mod fs;
#[cfg(feature = "services-fs")]
pub use fs::*;
-#[cfg(feature = "services-gcs")]
-mod gcs;
-#[cfg(feature = "services-gcs")]
-pub use gcs::*;
-
#[cfg(feature = "services-gdrive")]
mod gdrive;
#[cfg(feature = "services-gdrive")]
diff --git a/core/services/gcs/Cargo.toml b/core/services/gcs/Cargo.toml
new file mode 100644
index 000000000..8780772ec
--- /dev/null
+++ b/core/services/gcs/Cargo.toml
@@ -0,0 +1,58 @@
+# 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 Google Cloud Storage service implementation"
+name = "opendal-service-gcs"
+
+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]
+opendal-core = { path = "../../core", version = "0.55.0", default-features =
false }
+
+backon = "1.6"
+base64 = { workspace = true }
+bytes = { workspace = true }
+ctor = { workspace = true }
+http = { workspace = true }
+log = { workspace = true }
+percent-encoding = "2.3"
+quick-xml = { workspace = true, features = ["serialize"] }
+reqsign = { workspace = true, features = ["services-google",
"reqwest_request"] }
+reqwest = { version = "0.12.24", features = ["json", "stream"],
default-features = false }
+serde = { workspace = true, features = ["derive"] }
+serde_json = { workspace = true }
+tokio = { workspace = true, features = ["rt"] }
+
+[dev-dependencies]
+pretty_assertions = "1"
+serde_json = { workspace = true }
+tokio = { workspace = true, features = [
+ "macros",
+ "rt-multi-thread",
+ "io-util",
+] }
+tracing-subscriber = "0.3"
diff --git a/core/core/src/services/gcs/backend.rs
b/core/services/gcs/src/backend.rs
similarity index 98%
rename from core/core/src/services/gcs/backend.rs
rename to core/services/gcs/src/backend.rs
index 70c218f3e..3d5612e41 100644
--- a/core/core/src/services/gcs/backend.rs
+++ b/core/services/gcs/src/backend.rs
@@ -17,6 +17,7 @@
use std::fmt::Debug;
use std::sync::Arc;
+use std::sync::LazyLock;
use http::Response;
use http::StatusCode;
@@ -34,8 +35,10 @@ use super::error::parse_error;
use super::lister::GcsLister;
use super::writer::GcsWriter;
use super::writer::GcsWriters;
-use crate::raw::*;
-use crate::*;
+use opendal_core::raw::*;
+use opendal_core::*;
+
+static GLOBAL_REQWEST_CLIENT: LazyLock<reqwest::Client> =
LazyLock::new(reqwest::Client::new);
const DEFAULT_GCS_ENDPOINT: &str = "https://storage.googleapis.com";
const DEFAULT_GCS_SCOPE: &str =
"https://www.googleapis.com/auth/devstorage.read_write";
@@ -449,6 +452,10 @@ impl Access for GcsBackend {
ErrorKind::Unsupported,
"operation is not supported",
)),
+ _ => Err(Error::new(
+ ErrorKind::Unsupported,
+ "operation is not supported",
+ )),
};
let mut req = req?;
self.core.sign_query(&mut req, args.expire())?;
diff --git a/core/core/src/services/gcs/config.rs
b/core/services/gcs/src/config.rs
similarity index 97%
rename from core/core/src/services/gcs/config.rs
rename to core/services/gcs/src/config.rs
index 2e88c8cba..8246a06d3 100644
--- a/core/core/src/services/gcs/config.rs
+++ b/core/services/gcs/src/config.rs
@@ -84,10 +84,10 @@ impl Debug for GcsConfig {
}
}
-impl crate::Configurator for GcsConfig {
+impl opendal_core::Configurator for GcsConfig {
type Builder = GcsBuilder;
- fn from_uri(uri: &crate::types::OperatorUri) -> crate::Result<Self> {
+ fn from_uri(uri: &opendal_core::OperatorUri) -> opendal_core::Result<Self>
{
let mut map = uri.options().clone();
if let Some(name) = uri.name() {
@@ -112,8 +112,8 @@ impl crate::Configurator for GcsConfig {
#[cfg(test)]
mod tests {
use super::*;
- use crate::Configurator;
- use crate::types::OperatorUri;
+ use opendal_core::Configurator;
+ use opendal_core::types::OperatorUri;
#[test]
fn test_bucket_aliases() {
diff --git a/core/core/src/services/gcs/core.rs b/core/services/gcs/src/core.rs
similarity index 99%
rename from core/core/src/services/gcs/core.rs
rename to core/services/gcs/src/core.rs
index 35838a410..b8c091830 100644
--- a/core/core/src/services/gcs/core.rs
+++ b/core/services/gcs/src/core.rs
@@ -47,8 +47,8 @@ use serde::Deserialize;
use serde::Serialize;
use super::uri::percent_encode_path;
-use crate::raw::*;
-use crate::*;
+use opendal_core::raw::*;
+use opendal_core::*;
pub mod constants {
pub const X_GOOG_ACL: &str = "x-goog-acl";
diff --git a/core/core/src/services/gcs/deleter.rs
b/core/services/gcs/src/deleter.rs
similarity index 97%
rename from core/core/src/services/gcs/deleter.rs
rename to core/services/gcs/src/deleter.rs
index 803c86dc3..745b19f9c 100644
--- a/core/core/src/services/gcs/deleter.rs
+++ b/core/services/gcs/src/deleter.rs
@@ -21,9 +21,9 @@ use http::StatusCode;
use super::core::*;
use super::error::parse_error;
-use crate::raw::oio::BatchDeleteResult;
-use crate::raw::*;
-use crate::*;
+use opendal_core::raw::oio::BatchDeleteResult;
+use opendal_core::raw::*;
+use opendal_core::*;
pub struct GcsDeleter {
core: Arc<GcsCore>,
diff --git a/core/core/src/services/gcs/docs.md b/core/services/gcs/src/docs.md
similarity index 100%
rename from core/core/src/services/gcs/docs.md
rename to core/services/gcs/src/docs.md
diff --git a/core/core/src/services/gcs/error.rs
b/core/services/gcs/src/error.rs
similarity index 98%
rename from core/core/src/services/gcs/error.rs
rename to core/services/gcs/src/error.rs
index 187f0de5b..6e4c150eb 100644
--- a/core/core/src/services/gcs/error.rs
+++ b/core/services/gcs/src/error.rs
@@ -20,8 +20,8 @@ use http::StatusCode;
use serde::Deserialize;
use serde_json::de;
-use crate::raw::*;
-use crate::*;
+use opendal_core::raw::*;
+use opendal_core::*;
#[derive(Default, Debug, Deserialize)]
#[serde(default, rename_all = "camelCase")]
diff --git a/core/core/src/services/gcs/mod.rs b/core/services/gcs/src/lib.rs
similarity index 84%
rename from core/core/src/services/gcs/mod.rs
rename to core/services/gcs/src/lib.rs
index 437e9aa14..9d9b3e80d 100644
--- a/core/core/src/services/gcs/mod.rs
+++ b/core/services/gcs/src/lib.rs
@@ -15,10 +15,9 @@
// specific language governing permissions and limitations
// under the License.
-/// Default scheme for gcs service.
-pub const GCS_SCHEME: &str = "gcs";
-
-use crate::types::DEFAULT_OPERATOR_REGISTRY;
+#![cfg_attr(docsrs, feature(doc_cfg))]
+//! Google Cloud Storage service implementation for Apache OpenDAL.
+#![deny(missing_docs)]
mod backend;
mod config;
@@ -32,7 +31,10 @@ mod writer;
pub use backend::GcsBuilder as Gcs;
pub use config::GcsConfig;
+/// Default scheme for gcs service.
+pub const GCS_SCHEME: &str = "gcs";
+
#[ctor::ctor]
fn register_gcs_service() {
- DEFAULT_OPERATOR_REGISTRY.register::<Gcs>(GCS_SCHEME);
+ opendal_core::DEFAULT_OPERATOR_REGISTRY.register::<Gcs>(GCS_SCHEME);
}
diff --git a/core/core/src/services/gcs/lister.rs
b/core/services/gcs/src/lister.rs
similarity index 98%
rename from core/core/src/services/gcs/lister.rs
rename to core/services/gcs/src/lister.rs
index 2b2205960..8688ca2fc 100644
--- a/core/core/src/services/gcs/lister.rs
+++ b/core/services/gcs/src/lister.rs
@@ -18,12 +18,11 @@
use std::sync::Arc;
use bytes::Buf;
-use serde_json;
use super::core::*;
use super::error::parse_error;
-use crate::raw::*;
-use crate::*;
+use opendal_core::raw::*;
+use opendal_core::*;
/// GcsLister takes over task of listing objects and
/// helps walking directory
diff --git a/core/core/src/services/gcs/uri.rs b/core/services/gcs/src/uri.rs
similarity index 100%
rename from core/core/src/services/gcs/uri.rs
rename to core/services/gcs/src/uri.rs
diff --git a/core/core/src/services/gcs/writer.rs
b/core/services/gcs/src/writer.rs
similarity index 99%
rename from core/core/src/services/gcs/writer.rs
rename to core/services/gcs/src/writer.rs
index 377762fdb..938235355 100644
--- a/core/core/src/services/gcs/writer.rs
+++ b/core/services/gcs/src/writer.rs
@@ -24,8 +24,8 @@ use super::core::CompleteMultipartUploadRequestPart;
use super::core::GcsCore;
use super::core::InitiateMultipartUploadResult;
use super::error::parse_error;
-use crate::raw::*;
-use crate::*;
+use opendal_core::raw::*;
+use opendal_core::*;
pub type GcsWriters = oio::MultipartWriter<GcsWriter>;
diff --git a/core/src/lib.rs b/core/src/lib.rs
index 426675c9b..f1d666ead 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -39,6 +39,8 @@ pub mod services {
pub use opendal_service_cloudflare_kv::*;
#[cfg(feature = "services-ftp")]
pub use opendal_service_ftp::*;
+ #[cfg(feature = "services-gcs")]
+ pub use opendal_service_gcs::*;
#[cfg(feature = "services-ghac")]
pub use opendal_service_ghac::*;
#[cfg(feature = "services-hdfs-native")]