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 ae8d9f700 refactor(services/gdrive): split gdrive into separate crate 
(#7039)
ae8d9f700 is described below

commit ae8d9f700a554c416c19c3e7d4bdfeb263a2519a
Author: Jintao Zhang <[email protected]>
AuthorDate: Fri Dec 19 10:31:52 2025 +0800

    refactor(services/gdrive): split gdrive into separate crate (#7039)
    
    * refactor(services/gdrive): split gdrive into separate crate
    
    This PR splits the gdrive service into its own crate 
`opendal-service-gdrive`.
    
    - Create new crate at `core/services/gdrive`
    - Update feature flag to use the new crate
    - Remove gdrive from `opendal-core`
    - Re-export from facade crate
    
    Closes #6896
    
    * refactor(services/gdrive): restore code comments
    
    Restore all code comments that were accidentally removed during the
    service split refactoring, as requested by reviewer.
    
    * fix(services/gdrive): fix doc test by using correct crate names
    
    Update the example code in docs.md to use opendal_core and
    opendal_service_gdrive instead of opendal, and add tokio as
    dev-dependency for doc tests.
---
 core/Cargo.lock                                    | 16 ++++++++
 core/Cargo.toml                                    |  3 +-
 core/core/Cargo.toml                               |  1 -
 core/core/src/services/mod.rs                      |  5 ---
 core/services/gdrive/Cargo.toml                    | 47 ++++++++++++++++++++++
 .../gdrive => services/gdrive/src}/backend.rs      |  4 +-
 .../gdrive => services/gdrive/src}/builder.rs      |  4 +-
 .../gdrive => services/gdrive/src}/config.rs       |  8 ++--
 .../gdrive => services/gdrive/src}/core.rs         |  4 +-
 .../gdrive => services/gdrive/src}/deleter.rs      |  4 +-
 .../gdrive => services/gdrive/src}/docs.md         |  6 ++-
 .../gdrive => services/gdrive/src}/error.rs        |  4 +-
 .../gdrive/mod.rs => services/gdrive/src/lib.rs}   |  2 +-
 .../gdrive => services/gdrive/src}/lister.rs       |  4 +-
 .../gdrive => services/gdrive/src}/writer.rs       |  4 +-
 core/src/lib.rs                                    |  2 +
 16 files changed, 90 insertions(+), 28 deletions(-)

diff --git a/core/Cargo.lock b/core/Cargo.lock
index ee6d74b96..a4817c0de 100644
--- a/core/Cargo.lock
+++ b/core/Cargo.lock
@@ -5573,6 +5573,7 @@ dependencies = [
  "opendal-service-fs",
  "opendal-service-ftp",
  "opendal-service-gcs",
+ "opendal-service-gdrive",
  "opendal-service-ghac",
  "opendal-service-github",
  "opendal-service-hdfs-native",
@@ -6211,6 +6212,21 @@ dependencies = [
  "tokio",
 ]
 
+[[package]]
+name = "opendal-service-gdrive"
+version = "0.55.0"
+dependencies = [
+ "bytes",
+ "ctor",
+ "http 1.4.0",
+ "log",
+ "mea",
+ "opendal-core",
+ "serde",
+ "serde_json",
+ "tokio",
+]
+
 [[package]]
 name = "opendal-service-ghac"
 version = "0.55.0"
diff --git a/core/Cargo.toml b/core/Cargo.toml
index 777c4b7bb..9c039dcda 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -130,7 +130,7 @@ services-foundationdb = ["dep:opendal-service-foundationdb"]
 services-fs = ["dep:opendal-service-fs"]
 services-ftp = ["dep:opendal-service-ftp"]
 services-gcs = ["dep:opendal-service-gcs"]
-services-gdrive = ["opendal-core/services-gdrive"]
+services-gdrive = ["dep:opendal-service-gdrive"]
 services-ghac = ["dep:opendal-service-ghac"]
 services-github = ["dep:opendal-service-github"]
 services-gridfs = ["opendal-core/services-gridfs"]
@@ -235,6 +235,7 @@ opendal-service-foundationdb = { path = 
"services/foundationdb", version = "0.55
 opendal-service-fs = { path = "services/fs", 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-gdrive = { path = "services/gdrive", version = "0.55.0", 
optional = true, default-features = false }
 opendal-service-ghac = { path = "services/ghac", version = "0.55.0", optional 
= true, default-features = false }
 opendal-service-github = { path = "services/github", 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 }
diff --git a/core/core/Cargo.toml b/core/core/Cargo.toml
index 953234f50..55ba6d924 100644
--- a/core/core/Cargo.toml
+++ b/core/core/Cargo.toml
@@ -57,7 +57,6 @@ executors-tokio = ["tokio/rt"]
 # Enable dtrace support.
 layers-dtrace = ["dep:probe"]
 
-services-gdrive = ["internal-path-cache"]
 services-gridfs = ["dep:mongodb", "dep:mongodb-internal-macros"]
 services-hdfs = ["dep:hdrs"]
 services-ipmfs = []
diff --git a/core/core/src/services/mod.rs b/core/core/src/services/mod.rs
index 24ad96791..7b96c8677 100644
--- a/core/core/src/services/mod.rs
+++ b/core/core/src/services/mod.rs
@@ -19,11 +19,6 @@
 //!
 //! More ongoing services support is tracked at 
[opendal#5](https://github.com/apache/opendal/issues/5). Please feel free to 
submit issues if there are services not covered.
 
-#[cfg(feature = "services-gdrive")]
-mod gdrive;
-#[cfg(feature = "services-gdrive")]
-pub use gdrive::*;
-
 #[cfg(feature = "services-gridfs")]
 mod gridfs;
 #[cfg(feature = "services-gridfs")]
diff --git a/core/services/gdrive/Cargo.toml b/core/services/gdrive/Cargo.toml
new file mode 100644
index 000000000..3cfc6a382
--- /dev/null
+++ b/core/services/gdrive/Cargo.toml
@@ -0,0 +1,47 @@
+# 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 gdrive service implementation"
+name = "opendal-service-gdrive"
+
+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, features = [
+  "internal-path-cache",
+] }
+
+bytes = { workspace = true }
+ctor = { workspace = true }
+http = { workspace = true }
+log = { workspace = true }
+mea = "0.5.1"
+serde = { workspace = true, features = ["derive"] }
+serde_json = { workspace = true }
+
+[dev-dependencies]
+tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
diff --git a/core/core/src/services/gdrive/backend.rs 
b/core/services/gdrive/src/backend.rs
similarity index 99%
rename from core/core/src/services/gdrive/backend.rs
rename to core/services/gdrive/src/backend.rs
index 185d22e23..6949e9673 100644
--- a/core/core/src/services/gdrive/backend.rs
+++ b/core/services/gdrive/src/backend.rs
@@ -28,8 +28,8 @@ use super::deleter::GdriveDeleter;
 use super::error::parse_error;
 use super::lister::GdriveLister;
 use super::writer::GdriveWriter;
-use crate::raw::*;
-use crate::*;
+use opendal_core::raw::*;
+use opendal_core::*;
 
 #[derive(Clone, Debug)]
 pub struct GdriveBackend {
diff --git a/core/core/src/services/gdrive/builder.rs 
b/core/services/gdrive/src/builder.rs
similarity index 99%
rename from core/core/src/services/gdrive/builder.rs
rename to core/services/gdrive/src/builder.rs
index 8947a454f..2f726c1e8 100644
--- a/core/core/src/services/gdrive/builder.rs
+++ b/core/services/gdrive/src/builder.rs
@@ -27,8 +27,8 @@ use super::config::GdriveConfig;
 use super::core::GdriveCore;
 use super::core::GdrivePathQuery;
 use super::core::GdriveSigner;
-use crate::raw::*;
-use crate::*;
+use opendal_core::raw::*;
+use opendal_core::*;
 
 /// [GoogleDrive](https://drive.google.com/) backend support.
 #[derive(Default)]
diff --git a/core/core/src/services/gdrive/config.rs 
b/core/services/gdrive/src/config.rs
similarity index 92%
rename from core/core/src/services/gdrive/config.rs
rename to core/services/gdrive/src/config.rs
index e06d6a100..8fa026430 100644
--- a/core/core/src/services/gdrive/config.rs
+++ b/core/services/gdrive/src/config.rs
@@ -47,10 +47,10 @@ impl Debug for GdriveConfig {
     }
 }
 
-impl crate::Configurator for GdriveConfig {
+impl opendal_core::Configurator for GdriveConfig {
     type Builder = GdriveBuilder;
 
-    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(root) = uri.root() {
@@ -70,8 +70,8 @@ impl crate::Configurator for GdriveConfig {
 #[cfg(test)]
 mod tests {
     use super::*;
-    use crate::Configurator;
-    use crate::types::OperatorUri;
+    use opendal_core::Configurator;
+    use opendal_core::OperatorUri;
 
     #[test]
     fn from_uri_sets_root() {
diff --git a/core/core/src/services/gdrive/core.rs 
b/core/services/gdrive/src/core.rs
similarity index 99%
rename from core/core/src/services/gdrive/core.rs
rename to core/services/gdrive/src/core.rs
index 779e24229..339a3d34b 100644
--- a/core/core/src/services/gdrive/core.rs
+++ b/core/services/gdrive/src/core.rs
@@ -29,8 +29,8 @@ use serde::Deserialize;
 use serde_json::json;
 
 use super::error::parse_error;
-use crate::raw::*;
-use crate::*;
+use opendal_core::raw::*;
+use opendal_core::*;
 
 pub struct GdriveCore {
     pub info: Arc<AccessorInfo>,
diff --git a/core/core/src/services/gdrive/deleter.rs 
b/core/services/gdrive/src/deleter.rs
similarity index 97%
rename from core/core/src/services/gdrive/deleter.rs
rename to core/services/gdrive/src/deleter.rs
index 253702502..e58538fd4 100644
--- a/core/core/src/services/gdrive/deleter.rs
+++ b/core/services/gdrive/src/deleter.rs
@@ -21,8 +21,8 @@ use http::StatusCode;
 
 use super::core::*;
 use super::error::parse_error;
-use crate::raw::*;
-use crate::*;
+use opendal_core::raw::*;
+use opendal_core::*;
 
 pub struct GdriveDeleter {
     core: Arc<GdriveCore>,
diff --git a/core/core/src/services/gdrive/docs.md 
b/core/services/gdrive/src/docs.md
similarity index 92%
rename from core/core/src/services/gdrive/docs.md
rename to core/services/gdrive/src/docs.md
index 692a09e5b..bdca4fe22 100644
--- a/core/core/src/services/gdrive/docs.md
+++ b/core/services/gdrive/src/docs.md
@@ -49,9 +49,9 @@ You can refer to [`GdriveBuilder`]'s docs for more information
 ### Via Builder
 
 ```rust,no_run
-use anyhow::Result;
-use opendal_core::services::Gdrive;
 use opendal_core::Operator;
+use opendal_core::Result;
+use opendal_service_gdrive::Gdrive;
 
 #[tokio::main]
 async fn main() -> Result<()> {
@@ -59,5 +59,7 @@ async fn main() -> Result<()> {
         .root("/test")
         .access_token("<token>");
 
+    let op: Operator = Operator::new(builder)?.finish();
     Ok(())
 }
+```
diff --git a/core/core/src/services/gdrive/error.rs 
b/core/services/gdrive/src/error.rs
similarity index 98%
rename from core/core/src/services/gdrive/error.rs
rename to core/services/gdrive/src/error.rs
index 199e82e26..647714781 100644
--- a/core/core/src/services/gdrive/error.rs
+++ b/core/services/gdrive/src/error.rs
@@ -19,8 +19,8 @@ use http::Response;
 use http::StatusCode;
 use serde::Deserialize;
 
-use crate::raw::*;
-use crate::*;
+use opendal_core::raw::*;
+use opendal_core::*;
 
 #[derive(Default, Debug, Deserialize)]
 struct GdriveError {
diff --git a/core/core/src/services/gdrive/mod.rs 
b/core/services/gdrive/src/lib.rs
similarity index 96%
rename from core/core/src/services/gdrive/mod.rs
rename to core/services/gdrive/src/lib.rs
index 25d6f1aed..051a80020 100644
--- a/core/core/src/services/gdrive/mod.rs
+++ b/core/services/gdrive/src/lib.rs
@@ -18,7 +18,7 @@
 /// Default scheme for gdrive service.
 pub const GDRIVE_SCHEME: &str = "gdrive";
 
-use crate::types::DEFAULT_OPERATOR_REGISTRY;
+use opendal_core::DEFAULT_OPERATOR_REGISTRY;
 
 mod backend;
 mod builder;
diff --git a/core/core/src/services/gdrive/lister.rs 
b/core/services/gdrive/src/lister.rs
similarity index 98%
rename from core/core/src/services/gdrive/lister.rs
rename to core/services/gdrive/src/lister.rs
index 7f6ff31dc..1ee111eca 100644
--- a/core/core/src/services/gdrive/lister.rs
+++ b/core/services/gdrive/src/lister.rs
@@ -22,8 +22,8 @@ use http::StatusCode;
 use super::core::GdriveCore;
 use super::core::GdriveFileList;
 use super::error::parse_error;
-use crate::raw::*;
-use crate::*;
+use opendal_core::raw::*;
+use opendal_core::*;
 
 pub struct GdriveLister {
     path: String,
diff --git a/core/core/src/services/gdrive/writer.rs 
b/core/services/gdrive/src/writer.rs
similarity index 98%
rename from core/core/src/services/gdrive/writer.rs
rename to core/services/gdrive/src/writer.rs
index 89b8024aa..6234316ee 100644
--- a/core/core/src/services/gdrive/writer.rs
+++ b/core/services/gdrive/src/writer.rs
@@ -23,8 +23,8 @@ use http::StatusCode;
 use super::core::GdriveCore;
 use super::core::GdriveFile;
 use super::error::parse_error;
-use crate::raw::*;
-use crate::*;
+use opendal_core::raw::*;
+use opendal_core::*;
 
 pub struct GdriveWriter {
     core: Arc<GdriveCore>,
diff --git a/core/src/lib.rs b/core/src/lib.rs
index 8f82069aa..43c121799 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -68,6 +68,8 @@ pub mod services {
     pub use opendal_service_ftp::*;
     #[cfg(feature = "services-gcs")]
     pub use opendal_service_gcs::*;
+    #[cfg(feature = "services-gdrive")]
+    pub use opendal_service_gdrive::*;
     #[cfg(feature = "services-ghac")]
     pub use opendal_service_ghac::*;
     #[cfg(feature = "services-github")]

Reply via email to