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 af58f7dca refactor: Split dashmap service to new crate (#7022)
af58f7dca is described below

commit af58f7dca0ede0d5121ebdc39eb598237f10402f
Author: Qinxuan Chen <[email protected]>
AuthorDate: Tue Dec 16 15:52:07 2025 +0800

    refactor: Split dashmap service to new crate (#7022)
    
    * refactor: Split dashmap service to new crate
    
    * fix docs tests
---
 core/Cargo.lock                                    | 14 +++++++-
 core/Cargo.toml                                    |  3 +-
 core/core/Cargo.toml                               |  3 --
 core/core/src/services/mod.rs                      |  5 ---
 core/services/dashmap/Cargo.toml                   | 41 ++++++++++++++++++++++
 .../dashmap => services/dashmap/src}/backend.rs    |  4 +--
 .../dashmap => services/dashmap/src}/config.rs     | 16 +++++----
 .../dashmap => services/dashmap/src}/core.rs       |  3 +-
 .../dashmap => services/dashmap/src}/deleter.rs    |  5 +--
 .../dashmap => services/dashmap/src}/docs.md       |  4 +--
 .../dashmap/mod.rs => services/dashmap/src/lib.rs} | 11 +++---
 .../dashmap => services/dashmap/src}/lister.rs     | 13 +++----
 .../dashmap => services/dashmap/src}/writer.rs     |  8 ++---
 core/src/lib.rs                                    |  2 ++
 14 files changed, 93 insertions(+), 39 deletions(-)

diff --git a/core/Cargo.lock b/core/Cargo.lock
index 2dcfe098b..de0a2fc3c 100644
--- a/core/Cargo.lock
+++ b/core/Cargo.lock
@@ -5558,6 +5558,7 @@ dependencies = [
  "opendal-service-azfile",
  "opendal-service-b2",
  "opendal-service-cloudflare-kv",
+ "opendal-service-dashmap",
  "opendal-service-fs",
  "opendal-service-ftp",
  "opendal-service-gcs",
@@ -5627,7 +5628,6 @@ dependencies = [
  "compio",
  "criterion",
  "ctor",
- "dashmap 6.1.0",
  "divan",
  "dotenvy",
  "etcd-client",
@@ -5983,6 +5983,18 @@ dependencies = [
  "serde_json",
 ]
 
+[[package]]
+name = "opendal-service-dashmap"
+version = "0.55.0"
+dependencies = [
+ "ctor",
+ "dashmap 6.1.0",
+ "log",
+ "opendal-core",
+ "serde",
+ "tokio",
+]
+
 [[package]]
 name = "opendal-service-fs"
 version = "0.55.0"
diff --git a/core/Cargo.toml b/core/Cargo.toml
index 05a44d9eb..7480c14e1 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -111,7 +111,7 @@ services-cloudflare-kv = 
["dep:opendal-service-cloudflare-kv"]
 services-compfs = ["opendal-core/services-compfs"]
 services-cos = ["opendal-core/services-cos"]
 services-d1 = ["opendal-core/services-d1"]
-services-dashmap = ["opendal-core/services-dashmap"]
+services-dashmap = ["dep:opendal-service-dashmap"]
 services-dbfs = ["opendal-core/services-dbfs"]
 services-dropbox = ["opendal-core/services-dropbox"]
 services-etcd = ["opendal-core/services-etcd"]
@@ -209,6 +209,7 @@ opendal-service-azdls = { path = "services/azdls", version 
= "0.55.0", optional
 opendal-service-azfile = { path = "services/azfile", version = "0.55.0", 
optional = true, default-features = false }
 opendal-service-b2 = { path = "services/b2", version = "0.55.0", optional = 
true, default-features = false }
 opendal-service-cloudflare-kv = { path = "services/cloudflare-kv", version = 
"0.55.0", optional = true, default-features = false }
+opendal-service-dashmap = { path = "services/dashmap", version = "0.55.0", 
optional = true, default-features = false }
 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 }
diff --git a/core/core/Cargo.toml b/core/core/Cargo.toml
index c732d3c20..bd652333f 100644
--- a/core/core/Cargo.toml
+++ b/core/core/Cargo.toml
@@ -80,7 +80,6 @@ services-cos = [
   "reqsign?/reqwest_request",
 ]
 services-d1 = []
-services-dashmap = ["dep:dashmap"]
 services-dbfs = []
 services-dropbox = []
 services-etcd = ["dep:etcd-client", "dep:fastpool"]
@@ -176,8 +175,6 @@ cacache = { version = "13.0", default-features = false, 
features = [
   "tokio-runtime",
   "mmap",
 ], optional = true }
-# for services-dashmap
-dashmap = { version = "6", optional = true }
 # for services-etcd
 etcd-client = { version = "0.17", optional = true, features = ["tls"] }
 # for services-foundationdb
diff --git a/core/core/src/services/mod.rs b/core/core/src/services/mod.rs
index 96b3ddc52..c8994c24e 100644
--- a/core/core/src/services/mod.rs
+++ b/core/core/src/services/mod.rs
@@ -39,11 +39,6 @@ mod d1;
 #[cfg(feature = "services-d1")]
 pub use self::d1::*;
 
-#[cfg(feature = "services-dashmap")]
-mod dashmap;
-#[cfg(feature = "services-dashmap")]
-pub use self::dashmap::*;
-
 #[cfg(feature = "services-dbfs")]
 mod dbfs;
 #[cfg(feature = "services-dbfs")]
diff --git a/core/services/dashmap/Cargo.toml b/core/services/dashmap/Cargo.toml
new file mode 100644
index 000000000..750437969
--- /dev/null
+++ b/core/services/dashmap/Cargo.toml
@@ -0,0 +1,41 @@
+# 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 Dashmap service implementation"
+name = "opendal-service-dashmap"
+
+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 }
+dashmap = "6"
+log = { workspace = true }
+opendal-core = { path = "../../core", version = "0.55.0", default-features = 
false }
+serde = { workspace = true, features = ["derive"] }
+
+[dev-dependencies]
+tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
diff --git a/core/core/src/services/dashmap/backend.rs 
b/core/services/dashmap/src/backend.rs
similarity index 99%
rename from core/core/src/services/dashmap/backend.rs
rename to core/services/dashmap/src/backend.rs
index 638631f0e..365e7e828 100644
--- a/core/core/src/services/dashmap/backend.rs
+++ b/core/services/dashmap/src/backend.rs
@@ -19,6 +19,8 @@ use std::sync::Arc;
 
 use dashmap::DashMap;
 use log::debug;
+use opendal_core::raw::*;
+use opendal_core::*;
 
 use super::DASHMAP_SCHEME;
 use super::config::DashmapConfig;
@@ -26,8 +28,6 @@ use super::core::DashmapCore;
 use super::deleter::DashmapDeleter;
 use super::lister::DashmapLister;
 use super::writer::DashmapWriter;
-use crate::raw::*;
-use crate::*;
 
 /// [dashmap](https://github.com/xacrimon/dashmap) backend support.
 #[doc = include_str!("docs.md")]
diff --git a/core/core/src/services/dashmap/config.rs 
b/core/services/dashmap/src/config.rs
similarity index 84%
rename from core/core/src/services/dashmap/config.rs
rename to core/services/dashmap/src/config.rs
index d3754ca39..8a49b46f0 100644
--- a/core/core/src/services/dashmap/config.rs
+++ b/core/services/dashmap/src/config.rs
@@ -15,6 +15,9 @@
 // specific language governing permissions and limitations
 // under the License.
 
+use opendal_core::Configurator;
+use opendal_core::OperatorUri;
+use opendal_core::Result;
 use serde::Deserialize;
 use serde::Serialize;
 
@@ -29,9 +32,9 @@ pub struct DashmapConfig {
     pub root: Option<String>,
 }
 
-impl crate::Configurator for DashmapConfig {
+impl Configurator for DashmapConfig {
     type Builder = DashmapBuilder;
-    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(root) = uri.root() {
@@ -51,14 +54,13 @@ impl crate::Configurator for DashmapConfig {
 #[cfg(test)]
 mod tests {
     use super::*;
-    use crate::Configurator;
-    use crate::types::OperatorUri;
 
     #[test]
-    fn from_uri_sets_root() {
-        let uri = OperatorUri::new("dashmap:///cache", Vec::<(String, 
String)>::new()).unwrap();
+    fn from_uri_sets_root() -> Result<()> {
+        let uri = OperatorUri::new("dashmap:///cache", Vec::<(String, 
String)>::new())?;
 
-        let cfg = DashmapConfig::from_uri(&uri).unwrap();
+        let cfg = DashmapConfig::from_uri(&uri)?;
         assert_eq!(cfg.root.as_deref(), Some("cache"));
+        Ok(())
     }
 }
diff --git a/core/core/src/services/dashmap/core.rs 
b/core/services/dashmap/src/core.rs
similarity index 98%
rename from core/core/src/services/dashmap/core.rs
rename to core/services/dashmap/src/core.rs
index 173de8bd3..8d7bc8337 100644
--- a/core/core/src/services/dashmap/core.rs
+++ b/core/services/dashmap/src/core.rs
@@ -18,8 +18,7 @@
 use std::fmt::Debug;
 
 use dashmap::DashMap;
-
-use crate::*;
+use opendal_core::*;
 
 /// Value stored in dashmap cache containing both metadata and content
 #[derive(Clone)]
diff --git a/core/core/src/services/dashmap/deleter.rs 
b/core/services/dashmap/src/deleter.rs
similarity index 95%
rename from core/core/src/services/dashmap/deleter.rs
rename to core/services/dashmap/src/deleter.rs
index 0f4e10e50..49450afbb 100644
--- a/core/core/src/services/dashmap/deleter.rs
+++ b/core/services/dashmap/src/deleter.rs
@@ -17,9 +17,10 @@
 
 use std::sync::Arc;
 
+use opendal_core::raw::*;
+use opendal_core::*;
+
 use super::core::DashmapCore;
-use crate::raw::{OpDelete, build_abs_path, oio};
-use crate::*;
 
 pub struct DashmapDeleter {
     core: Arc<DashmapCore>,
diff --git a/core/core/src/services/dashmap/docs.md 
b/core/services/dashmap/src/docs.md
similarity index 89%
rename from core/core/src/services/dashmap/docs.md
rename to core/services/dashmap/src/docs.md
index 8c44279fd..ce4b4886f 100644
--- a/core/core/src/services/dashmap/docs.md
+++ b/core/services/dashmap/src/docs.md
@@ -23,9 +23,9 @@ You can refer to [`DashmapBuilder`]'s docs for more 
information
 ### Via Builder
 
 ```rust,no_run
-use anyhow::Result;
-use opendal_core::services::Dashmap;
 use opendal_core::Operator;
+use opendal_core::Result;
+use opendal_service_dashmap::Dashmap;
 
 #[tokio::main]
 async fn main() -> Result<()> {
diff --git a/core/core/src/services/dashmap/mod.rs 
b/core/services/dashmap/src/lib.rs
similarity index 84%
rename from core/core/src/services/dashmap/mod.rs
rename to core/services/dashmap/src/lib.rs
index eff210847..c3f609b30 100644
--- a/core/core/src/services/dashmap/mod.rs
+++ b/core/services/dashmap/src/lib.rs
@@ -15,10 +15,10 @@
 // specific language governing permissions and limitations
 // under the License.
 
-/// Default scheme for dashmap service.
-pub const DASHMAP_SCHEME: &str = "dashmap";
+//! Dashmap service implementation for Apache OpenDAL.
 
-use crate::types::DEFAULT_OPERATOR_REGISTRY;
+#![cfg_attr(docsrs, feature(doc_cfg))]
+#![deny(missing_docs)]
 
 mod backend;
 mod config;
@@ -30,7 +30,10 @@ mod writer;
 pub use backend::DashmapBuilder as Dashmap;
 pub use config::DashmapConfig;
 
+/// Default scheme for dashmap service.
+pub const DASHMAP_SCHEME: &str = "dashmap";
+
 #[ctor::ctor]
 fn register_dashmap_service() {
-    DEFAULT_OPERATOR_REGISTRY.register::<Dashmap>(DASHMAP_SCHEME);
+    
opendal_core::DEFAULT_OPERATOR_REGISTRY.register::<Dashmap>(DASHMAP_SCHEME);
 }
diff --git a/core/core/src/services/dashmap/lister.rs 
b/core/services/dashmap/src/lister.rs
similarity index 89%
rename from core/core/src/services/dashmap/lister.rs
rename to core/services/dashmap/src/lister.rs
index e276ac3d1..d74cc5891 100644
--- a/core/core/src/services/dashmap/lister.rs
+++ b/core/services/dashmap/src/lister.rs
@@ -15,13 +15,14 @@
 // specific language governing permissions and limitations
 // under the License.
 
-use super::core::DashmapCore;
-use crate::raw::oio::Entry;
-use crate::raw::{build_abs_path, build_rel_path, oio};
-use crate::*;
 use std::sync::Arc;
 use std::vec::IntoIter;
 
+use opendal_core::raw::*;
+use opendal_core::*;
+
+use super::core::DashmapCore;
+
 pub struct DashmapLister {
     root: String,
     path: String,
@@ -42,7 +43,7 @@ impl DashmapLister {
 }
 
 impl oio::List for DashmapLister {
-    async fn next(&mut self) -> Result<Option<Entry>> {
+    async fn next(&mut self) -> Result<Option<oio::Entry>> {
         for key in self.iter.by_ref() {
             if key.starts_with(&self.path) {
                 let path = build_rel_path(&self.root, &key);
@@ -53,7 +54,7 @@ impl oio::List for DashmapLister {
                 } else {
                     EntryMode::FILE
                 };
-                let entry = Entry::new(&path, Metadata::new(mode));
+                let entry = oio::Entry::new(&path, Metadata::new(mode));
                 return Ok(Some(entry));
             }
         }
diff --git a/core/core/src/services/dashmap/writer.rs 
b/core/services/dashmap/src/writer.rs
similarity index 96%
rename from core/core/src/services/dashmap/writer.rs
rename to core/services/dashmap/src/writer.rs
index bb8409ba3..36517238a 100644
--- a/core/core/src/services/dashmap/writer.rs
+++ b/core/services/dashmap/src/writer.rs
@@ -17,10 +17,10 @@
 
 use std::sync::Arc;
 
-use super::core::DashmapCore;
-use super::core::DashmapValue;
-use crate::raw::*;
-use crate::*;
+use opendal_core::raw::*;
+use opendal_core::*;
+
+use super::core::*;
 
 pub struct DashmapWriter {
     core: Arc<DashmapCore>,
diff --git a/core/src/lib.rs b/core/src/lib.rs
index 59f2196e3..666d2c8ff 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -41,6 +41,8 @@ pub mod services {
     pub use opendal_service_b2::*;
     #[cfg(feature = "services-cloudflare-kv")]
     pub use opendal_service_cloudflare_kv::*;
+    #[cfg(feature = "services-dashmap")]
+    pub use opendal_service_dashmap::*;
     #[cfg(feature = "services-fs")]
     pub use opendal_service_fs::*;
     #[cfg(feature = "services-ftp")]

Reply via email to