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 46def5be4 refactor: Split redb service to new crate (#7028)
46def5be4 is described below

commit 46def5be4191a92b0b0d953bde79fa0c618a0c09
Author: WaterWhisperer <[email protected]>
AuthorDate: Tue Dec 16 23:49:59 2025 +0800

    refactor: Split redb service to new crate (#7028)
---
 core/Cargo.lock                                    | 12 ++++++-
 core/Cargo.toml                                    |  3 +-
 core/core/Cargo.toml                               |  3 --
 core/core/src/services/mod.rs                      |  5 ---
 core/services/redb/Cargo.toml                      | 40 ++++++++++++++++++++++
 .../services/redb => services/redb/src}/backend.rs |  4 +--
 .../services/redb => services/redb/src}/config.rs  |  8 ++---
 .../services/redb => services/redb/src}/core.rs    |  2 +-
 .../services/redb => services/redb/src}/deleter.rs |  6 ++--
 .../services/redb => services/redb/src}/docs.md    |  0
 .../redb/mod.rs => services/redb/src/lib.rs}       | 12 ++++---
 .../services/redb => services/redb/src}/writer.rs  |  4 +--
 core/src/lib.rs                                    |  2 ++
 13 files changed, 74 insertions(+), 27 deletions(-)

diff --git a/core/Cargo.lock b/core/Cargo.lock
index d3fbaff03..efdc312cd 100644
--- a/core/Cargo.lock
+++ b/core/Cargo.lock
@@ -5576,6 +5576,7 @@ dependencies = [
  "opendal-service-oss",
  "opendal-service-persy",
  "opendal-service-postgresql",
+ "opendal-service-redb",
  "opendal-service-s3",
  "opendal-service-sled",
  "opendal-service-sqlite",
@@ -5664,7 +5665,6 @@ dependencies = [
  "prost 0.13.5",
  "quick-xml",
  "rand 0.8.5",
- "redb",
  "redis",
  "reqsign",
  "reqwest",
@@ -6246,6 +6246,16 @@ dependencies = [
  "sqlx",
 ]
 
+[[package]]
+name = "opendal-service-redb"
+version = "0.55.0"
+dependencies = [
+ "ctor",
+ "opendal-core",
+ "redb",
+ "serde",
+]
+
 [[package]]
 name = "opendal-service-s3"
 version = "0.55.0"
diff --git a/core/Cargo.toml b/core/Cargo.toml
index 513e3c314..998807645 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -146,7 +146,7 @@ services-oss = ["dep:opendal-service-oss"]
 services-pcloud = ["opendal-core/services-pcloud"]
 services-persy = ["dep:opendal-service-persy"]
 services-postgresql = ["dep:opendal-service-postgresql"]
-services-redb = ["opendal-core/services-redb"]
+services-redb = ["dep:opendal-service-redb"]
 services-redis = ["opendal-core/services-redis"]
 services-redis-native-tls = ["opendal-core/services-redis-native-tls"]
 services-rocksdb = ["opendal-core/services-rocksdb"]
@@ -228,6 +228,7 @@ opendal-service-obs = { path = "services/obs", version = 
"0.55.0", optional = tr
 opendal-service-oss = { path = "services/oss", version = "0.55.0", optional = 
true, default-features = false }
 opendal-service-persy = { path = "services/persy", version = "0.55.0", 
optional = true, default-features = false }
 opendal-service-postgresql = { path = "services/postgresql", version = 
"0.55.0", optional = true, default-features = false }
+opendal-service-redb = { path = "services/redb", version = "0.55.0", optional 
= true, default-features = false }
 opendal-service-s3 = { path = "services/s3", version = "0.55.0", optional = 
true, default-features = false }
 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 }
diff --git a/core/core/Cargo.toml b/core/core/Cargo.toml
index 7b60fdd80..b053bb60b 100644
--- a/core/core/Cargo.toml
+++ b/core/core/Cargo.toml
@@ -83,7 +83,6 @@ services-opfs = [
 ]
 
 services-pcloud = []
-services-redb = ["dep:redb", "internal-tokio-rt"]
 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"]
@@ -169,8 +168,6 @@ openssh-sftp-client = { version = "0.15.3", optional = 
true, features = [
   "openssh",
   "tracing",
 ] }
-# for services-redb
-redb = { version = "2", 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 f4af2e062..86c211bf2 100644
--- a/core/core/src/services/mod.rs
+++ b/core/core/src/services/mod.rs
@@ -114,11 +114,6 @@ mod pcloud;
 #[cfg(feature = "services-pcloud")]
 pub use pcloud::*;
 
-#[cfg(feature = "services-redb")]
-mod redb;
-#[cfg(feature = "services-redb")]
-pub use self::redb::*;
-
 #[cfg(feature = "services-redis")]
 mod redis;
 #[cfg(feature = "services-redis")]
diff --git a/core/services/redb/Cargo.toml b/core/services/redb/Cargo.toml
new file mode 100644
index 000000000..aead366dc
--- /dev/null
+++ b/core/services/redb/Cargo.toml
@@ -0,0 +1,40 @@
+# 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 Redb service implementation"
+name = "opendal-service-redb"
+
+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-tokio-rt",
+] }
+
+ctor = { workspace = true }
+redb = { version = "2" }
+serde = { workspace = true, features = ["derive"] }
diff --git a/core/core/src/services/redb/backend.rs 
b/core/services/redb/src/backend.rs
similarity index 99%
rename from core/core/src/services/redb/backend.rs
rename to core/services/redb/src/backend.rs
index 8b4794316..48ad108df 100644
--- a/core/core/src/services/redb/backend.rs
+++ b/core/services/redb/src/backend.rs
@@ -23,8 +23,8 @@ use super::config::RedbConfig;
 use super::core::*;
 use super::deleter::RedbDeleter;
 use super::writer::RedbWriter;
-use crate::raw::*;
-use crate::*;
+use opendal_core::raw::*;
+use opendal_core::*;
 
 /// Redb service support.
 #[doc = include_str!("docs.md")]
diff --git a/core/core/src/services/redb/config.rs 
b/core/services/redb/src/config.rs
similarity index 91%
rename from core/core/src/services/redb/config.rs
rename to core/services/redb/src/config.rs
index 8082a6231..390ac6a1a 100644
--- a/core/core/src/services/redb/config.rs
+++ b/core/services/redb/src/config.rs
@@ -33,10 +33,10 @@ pub struct RedbConfig {
     pub root: Option<String>,
 }
 
-impl crate::Configurator for RedbConfig {
+impl opendal_core::Configurator for RedbConfig {
     type Builder = RedbBuilder;
 
-    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(path) = uri.root() {
@@ -60,8 +60,8 @@ impl crate::Configurator for RedbConfig {
 #[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_datadir_table_and_root() {
diff --git a/core/core/src/services/redb/core.rs 
b/core/services/redb/src/core.rs
similarity index 99%
rename from core/core/src/services/redb/core.rs
rename to core/services/redb/src/core.rs
index 73c161f37..9e90eac4f 100644
--- a/core/core/src/services/redb/core.rs
+++ b/core/services/redb/src/core.rs
@@ -18,7 +18,7 @@
 use std::fmt::Debug;
 use std::sync::Arc;
 
-use crate::*;
+use opendal_core::*;
 
 #[derive(Clone)]
 pub struct RedbCore {
diff --git a/core/core/src/services/redb/deleter.rs 
b/core/services/redb/src/deleter.rs
similarity index 94%
rename from core/core/src/services/redb/deleter.rs
rename to core/services/redb/src/deleter.rs
index 9ab1ef1f1..eb5697a44 100644
--- a/core/core/src/services/redb/deleter.rs
+++ b/core/services/redb/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 RedbDeleter {
     core: Arc<RedbCore>,
diff --git a/core/core/src/services/redb/docs.md 
b/core/services/redb/src/docs.md
similarity index 100%
rename from core/core/src/services/redb/docs.md
rename to core/services/redb/src/docs.md
diff --git a/core/core/src/services/redb/mod.rs b/core/services/redb/src/lib.rs
similarity index 84%
rename from core/core/src/services/redb/mod.rs
rename to core/services/redb/src/lib.rs
index 3d653a1e6..2b7ffb075 100644
--- a/core/core/src/services/redb/mod.rs
+++ b/core/services/redb/src/lib.rs
@@ -15,10 +15,9 @@
 // specific language governing permissions and limitations
 // under the License.
 
-/// Default scheme for redb service.
-pub const REDB_SCHEME: &str = "redb";
-
-use crate::types::DEFAULT_OPERATOR_REGISTRY;
+#![cfg_attr(docsrs, feature(doc_cfg))]
+//! Redb service implementation for Apache OpenDAL.
+#![deny(missing_docs)]
 
 mod backend;
 mod config;
@@ -29,7 +28,10 @@ mod writer;
 pub use backend::RedbBuilder as Redb;
 pub use config::RedbConfig;
 
+/// Default scheme for redb service.
+pub const REDB_SCHEME: &str = "redb";
+
 #[ctor::ctor]
 fn register_redb_service() {
-    DEFAULT_OPERATOR_REGISTRY.register::<Redb>(REDB_SCHEME);
+    opendal_core::DEFAULT_OPERATOR_REGISTRY.register::<Redb>(REDB_SCHEME);
 }
diff --git a/core/core/src/services/redb/writer.rs 
b/core/services/redb/src/writer.rs
similarity index 97%
rename from core/core/src/services/redb/writer.rs
rename to core/services/redb/src/writer.rs
index 8e27a9f8d..ff292a5f4 100644
--- a/core/core/src/services/redb/writer.rs
+++ b/core/services/redb/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 RedbWriter {
     core: Arc<RedbCore>,
diff --git a/core/src/lib.rs b/core/src/lib.rs
index ea7f862f4..659b58c28 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -80,6 +80,8 @@ pub mod services {
     pub use opendal_service_persy::*;
     #[cfg(feature = "services-postgresql")]
     pub use opendal_service_postgresql::*;
+    #[cfg(feature = "services-redb")]
+    pub use opendal_service_redb::*;
     #[cfg(feature = "services-s3")]
     pub use opendal_service_s3::*;
     #[cfg(feature = "services-sled")]

Reply via email to