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

koushiro 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 784e21520 refactor(services/mongodb): split mongodb service into 
separate crate (#7079)
784e21520 is described below

commit 784e215207b7571c61e118226e2a29a3a5bf3fc0
Author: Piyush मिश्र <[email protected]>
AuthorDate: Sun Dec 21 14:10:30 2025 +0530

    refactor(services/mongodb): split mongodb service into separate crate 
(#7079)
---
 core/Cargo.lock                                    | 16 +++++++--
 core/Cargo.toml                                    |  3 +-
 core/core/Cargo.toml                               |  4 ---
 core/core/src/services/mod.rs                      |  5 ---
 core/services/mongodb/Cargo.toml                   | 42 ++++++++++++++++++++++
 .../mongodb => services/mongodb/src}/backend.rs    |  4 +--
 .../mongodb => services/mongodb/src}/config.rs     |  8 ++---
 .../mongodb => services/mongodb/src}/core.rs       |  2 +-
 .../mongodb => services/mongodb/src}/deleter.rs    |  6 ++--
 .../mongodb => services/mongodb/src}/docs.md       |  2 +-
 .../mongodb/mod.rs => services/mongodb/src/lib.rs} |  2 +-
 .../mongodb => services/mongodb/src}/writer.rs     |  4 +--
 core/src/lib.rs                                    |  2 ++
 13 files changed, 74 insertions(+), 26 deletions(-)

diff --git a/core/Cargo.lock b/core/Cargo.lock
index 664fec5e3..783d204c8 100644
--- a/core/Cargo.lock
+++ b/core/Cargo.lock
@@ -5589,6 +5589,7 @@ dependencies = [
  "opendal-service-memcached",
  "opendal-service-mini-moka",
  "opendal-service-moka",
+ "opendal-service-mongodb",
  "opendal-service-monoiofs",
  "opendal-service-mysql",
  "opendal-service-obs",
@@ -5673,8 +5674,6 @@ dependencies = [
  "md-5",
  "mea",
  "moka",
- "mongodb",
- "mongodb-internal-macros",
  "percent-encoding",
  "pretty_assertions",
  "probe",
@@ -6436,6 +6435,19 @@ dependencies = [
  "tokio",
 ]
 
+[[package]]
+name = "opendal-service-mongodb"
+version = "0.55.0"
+dependencies = [
+ "anyhow",
+ "ctor",
+ "mea",
+ "mongodb",
+ "opendal-core",
+ "serde",
+ "tokio",
+]
+
 [[package]]
 name = "opendal-service-monoiofs"
 version = "0.55.0"
diff --git a/core/Cargo.toml b/core/Cargo.toml
index 8ca76024b..7c417b3a2 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -148,7 +148,7 @@ services-memcached = ["dep:opendal-service-memcached"]
 services-memory = ["opendal-core/services-memory"]
 services-mini-moka = ["dep:opendal-service-mini-moka"]
 services-moka = ["dep:opendal-service-moka"]
-services-mongodb = ["opendal-core/services-mongodb"]
+services-mongodb = ["dep:opendal-service-mongodb"]
 services-monoiofs = ["dep:opendal-service-monoiofs"]
 services-mysql = ["dep:opendal-service-mysql"]
 services-obs = ["dep:opendal-service-obs"]
@@ -253,6 +253,7 @@ opendal-service-lakefs = { path = "services/lakefs", 
version = "0.55.0", optiona
 opendal-service-memcached = { path = "services/memcached", version = "0.55.0", 
optional = true, default-features = false }
 opendal-service-mini-moka = { path = "services/mini_moka", 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-mongodb = { path = "services/mongodb", version = "0.55.0", 
optional = true, default-features = false }
 opendal-service-monoiofs = { path = "services/monoiofs", version = "0.55.0", 
optional = true, default-features = false }
 opendal-service-mysql = { path = "services/mysql", version = "0.55.0", 
optional = true, default-features = false }
 opendal-service-obs = { path = "services/obs", version = "0.55.0", optional = 
true, default-features = false }
diff --git a/core/core/Cargo.toml b/core/core/Cargo.toml
index 3d58a953c..eca27cad3 100644
--- a/core/core/Cargo.toml
+++ b/core/core/Cargo.toml
@@ -58,7 +58,6 @@ executors-tokio = ["tokio/rt"]
 layers-dtrace = ["dep:probe"]
 
 services-memory = []
-services-mongodb = ["dep:mongodb", "dep:mongodb-internal-macros"]
 services-redis = ["dep:redis", "dep:fastpool", "redis?/tokio-rustls-comp"]
 services-redis-native-tls = ["services-redis", "redis?/tokio-native-tls-comp"]
 services-rocksdb = ["dep:rocksdb", "internal-tokio-rt"]
@@ -103,9 +102,6 @@ reqsign = { workspace = true, features = 
["reqwest_request"], optional = true }
 
 # for services-moka
 moka = { version = "0.12", optional = true, features = ["future", "sync"] }
-# for services-mongodb
-mongodb = { version = "3.3.0", optional = true }
-mongodb-internal-macros = { version = "3.2.4", optional = true }
 # for services-redis
 redis = { version = "1.0", features = [
   "cluster-async",
diff --git a/core/core/src/services/mod.rs b/core/core/src/services/mod.rs
index 864a88bfb..7bb1ab8c7 100644
--- a/core/core/src/services/mod.rs
+++ b/core/core/src/services/mod.rs
@@ -24,11 +24,6 @@ mod memory;
 #[cfg(feature = "services-memory")]
 pub use self::memory::*;
 
-#[cfg(feature = "services-mongodb")]
-mod mongodb;
-#[cfg(feature = "services-mongodb")]
-pub use self::mongodb::*;
-
 #[cfg(feature = "services-redis")]
 mod redis;
 #[cfg(feature = "services-redis")]
diff --git a/core/services/mongodb/Cargo.toml b/core/services/mongodb/Cargo.toml
new file mode 100644
index 000000000..5c114c83b
--- /dev/null
+++ b/core/services/mongodb/Cargo.toml
@@ -0,0 +1,42 @@
+# 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 Mongodb service implementation"
+name = "opendal-service-mongodb"
+
+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]
+ctor = { workspace = true }
+mea = "0.5.1"
+mongodb = { version = "3.3.0" }
+opendal-core = { path = "../../core", version = "0.55.0", default-features = 
false }
+serde = { workspace = true, features = ["derive"] }
+
+[dev-dependencies]
+anyhow = { version = "1.0.100", features = ["std"] }
+tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
diff --git a/core/core/src/services/mongodb/backend.rs 
b/core/services/mongodb/src/backend.rs
similarity index 99%
rename from core/core/src/services/mongodb/backend.rs
rename to core/services/mongodb/src/backend.rs
index 17513fd9f..676ac36d1 100644
--- a/core/core/src/services/mongodb/backend.rs
+++ b/core/services/mongodb/src/backend.rs
@@ -24,8 +24,8 @@ use super::config::MongodbConfig;
 use super::core::*;
 use super::deleter::MongodbDeleter;
 use super::writer::MongodbWriter;
-use crate::raw::*;
-use crate::*;
+use opendal_core::raw::*;
+use opendal_core::*;
 
 #[doc = include_str!("docs.md")]
 #[derive(Debug, Default)]
diff --git a/core/core/src/services/mongodb/config.rs 
b/core/services/mongodb/src/config.rs
similarity index 95%
rename from core/core/src/services/mongodb/config.rs
rename to core/services/mongodb/src/config.rs
index 817835e34..f6dd8940c 100644
--- a/core/core/src/services/mongodb/config.rs
+++ b/core/services/mongodb/src/config.rs
@@ -53,10 +53,10 @@ impl Debug for MongodbConfig {
     }
 }
 
-impl crate::Configurator for MongodbConfig {
+impl opendal_core::Configurator for MongodbConfig {
     type Builder = MongodbBuilder;
 
-    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(authority) = uri.authority() {
@@ -98,8 +98,8 @@ impl crate::Configurator for MongodbConfig {
 #[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_connection_string_database_collection_and_root() {
diff --git a/core/core/src/services/mongodb/core.rs 
b/core/services/mongodb/src/core.rs
similarity index 99%
rename from core/core/src/services/mongodb/core.rs
rename to core/services/mongodb/src/core.rs
index 9e8a6ee82..99c9d4a13 100644
--- a/core/core/src/services/mongodb/core.rs
+++ b/core/services/mongodb/src/core.rs
@@ -23,7 +23,7 @@ use mongodb::bson::Document;
 use mongodb::bson::doc;
 use mongodb::options::ClientOptions;
 
-use crate::*;
+use opendal_core::*;
 
 #[derive(Clone)]
 pub struct MongodbCore {
diff --git a/core/core/src/services/mongodb/deleter.rs 
b/core/services/mongodb/src/deleter.rs
similarity index 94%
rename from core/core/src/services/mongodb/deleter.rs
rename to core/services/mongodb/src/deleter.rs
index 2c147453b..8f02b9243 100644
--- a/core/core/src/services/mongodb/deleter.rs
+++ b/core/services/mongodb/src/deleter.rs
@@ -18,9 +18,9 @@
 use std::sync::Arc;
 
 use super::core::*;
-use crate::raw::oio;
-use crate::raw::*;
-use crate::*;
+use opendal_core::raw::oio;
+use opendal_core::raw::*;
+use opendal_core::*;
 
 pub struct MongodbDeleter {
     core: Arc<MongodbCore>,
diff --git a/core/core/src/services/mongodb/docs.md 
b/core/services/mongodb/src/docs.md
similarity index 96%
rename from core/core/src/services/mongodb/docs.md
rename to core/services/mongodb/src/docs.md
index a39eb7bf1..691a774e5 100644
--- a/core/core/src/services/mongodb/docs.md
+++ b/core/services/mongodb/src/docs.md
@@ -27,7 +27,7 @@ This service can be used to:
 
 ```rust,no_run
 use anyhow::Result;
-use opendal_core::services::Mongodb;
+use opendal_service_mongodb::Mongodb;
 use opendal_core::Operator;
 
 #[tokio::main]
diff --git a/core/core/src/services/mongodb/mod.rs 
b/core/services/mongodb/src/lib.rs
similarity index 96%
rename from core/core/src/services/mongodb/mod.rs
rename to core/services/mongodb/src/lib.rs
index e2fc75c48..c9611b1df 100644
--- a/core/core/src/services/mongodb/mod.rs
+++ b/core/services/mongodb/src/lib.rs
@@ -18,7 +18,7 @@
 /// Default scheme for mongodb service.
 pub const MONGODB_SCHEME: &str = "mongodb";
 
-use crate::types::DEFAULT_OPERATOR_REGISTRY;
+use opendal_core::DEFAULT_OPERATOR_REGISTRY;
 
 mod backend;
 mod config;
diff --git a/core/core/src/services/mongodb/writer.rs 
b/core/services/mongodb/src/writer.rs
similarity index 97%
rename from core/core/src/services/mongodb/writer.rs
rename to core/services/mongodb/src/writer.rs
index f9c34ba9c..fab103997 100644
--- a/core/core/src/services/mongodb/writer.rs
+++ b/core/services/mongodb/src/writer.rs
@@ -18,8 +18,8 @@
 use std::sync::Arc;
 
 use super::core::*;
-use crate::raw::oio;
-use crate::*;
+use opendal_core::raw::oio;
+use opendal_core::*;
 
 pub struct MongodbWriter {
     core: Arc<MongodbCore>,
diff --git a/core/src/lib.rs b/core/src/lib.rs
index a3319f8c8..827145389 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -98,6 +98,8 @@ pub mod services {
     pub use opendal_service_mini_moka::*;
     #[cfg(feature = "services-moka")]
     pub use opendal_service_moka::*;
+    #[cfg(feature = "services-mongodb")]
+    pub use opendal_service_mongodb::*;
     #[cfg(feature = "services-monoiofs")]
     pub use opendal_service_monoiofs::*;
     #[cfg(feature = "services-mysql")]

Reply via email to