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 7ba24a6df refactor(services/sled): split service into its own crate 
(#6981)
7ba24a6df is described below

commit 7ba24a6df3a180ece5d36835025f0430d3ddc409
Author: x³u³ <[email protected]>
AuthorDate: Fri Dec 12 22:20:46 2025 +0800

    refactor(services/sled): split service into its own crate (#6981)
    
    Signed-off-by: xxxuuu <[email protected]>
---
 core/Cargo.lock                                    | 12 ++++++-
 core/Cargo.toml                                    |  3 +-
 core/core/Cargo.toml                               |  3 --
 core/core/src/services/mod.rs                      |  5 ---
 core/services/sled/Cargo.toml                      | 40 ++++++++++++++++++++++
 .../services/sled => services/sled/src}/backend.rs |  4 +--
 .../services/sled => services/sled/src}/config.rs  |  8 ++---
 .../services/sled => services/sled/src}/core.rs    |  2 +-
 .../services/sled => services/sled/src}/deleter.rs |  6 ++--
 .../services/sled => services/sled/src}/docs.md    |  2 +-
 .../sled/mod.rs => services/sled/src/lib.rs}       |  2 +-
 .../services/sled => services/sled/src}/lister.rs  |  6 ++--
 .../services/sled => services/sled/src}/writer.rs  |  4 +--
 core/src/lib.rs                                    |  2 ++
 14 files changed, 72 insertions(+), 27 deletions(-)

diff --git a/core/Cargo.lock b/core/Cargo.lock
index 858a2d813..556ba6afe 100644
--- a/core/Cargo.lock
+++ b/core/Cargo.lock
@@ -5509,6 +5509,7 @@ dependencies = [
  "opendal-service-obs",
  "opendal-service-postgresql",
  "opendal-service-s3",
+ "opendal-service-sled",
  "opendal-service-vercel-blob",
  "opentelemetry",
  "opentelemetry-otlp",
@@ -5607,7 +5608,6 @@ dependencies = [
  "sha1",
  "sha2",
  "size",
- "sled",
  "sqlx",
  "surrealdb",
  "tikv-client",
@@ -6008,6 +6008,16 @@ dependencies = [
  "tracing-subscriber",
 ]
 
+[[package]]
+name = "opendal-service-sled"
+version = "0.55.0"
+dependencies = [
+ "ctor",
+ "opendal-core",
+ "serde",
+ "sled",
+]
+
 [[package]]
 name = "opendal-service-vercel-blob"
 version = "0.55.0"
diff --git a/core/Cargo.toml b/core/Cargo.toml
index 761a445f6..f74d35fd8 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -152,7 +152,7 @@ services-rocksdb = ["opendal-core/services-rocksdb"]
 services-s3 = ["dep:opendal-service-s3"]
 services-seafile = ["opendal-core/services-seafile"]
 services-sftp = ["opendal-core/services-sftp"]
-services-sled = ["opendal-core/services-sled"]
+services-sled = ["dep:opendal-service-sled"]
 services-sqlite = ["opendal-core/services-sqlite"]
 services-surrealdb = ["opendal-core/services-surrealdb"]
 services-swift = ["opendal-core/services-swift"]
@@ -213,6 +213,7 @@ opendal-service-moka = { path = "services/moka", version = 
"0.55.0", optional =
 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 }
 opendal-service-postgresql = { path = "services/postgresql", 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-s3 = { path = "services/s3", version = "0.55.0", optional = 
true, default-features = false }
 opendal-service-vercel-blob = { path = "services/vercel-blob", version = 
"0.55.0", optional = true, default-features = false }
 
diff --git a/core/core/Cargo.toml b/core/core/Cargo.toml
index 3c703649e..78ec36787 100644
--- a/core/core/Cargo.toml
+++ b/core/core/Cargo.toml
@@ -131,7 +131,6 @@ services-redis-native-tls = ["services-redis", 
"redis?/tokio-native-tls-comp"]
 services-rocksdb = ["dep:rocksdb", "internal-tokio-rt"]
 services-seafile = []
 services-sftp = ["dep:openssh", "dep:openssh-sftp-client", "dep:fastpool"]
-services-sled = ["dep:sled", "internal-tokio-rt"]
 services-sqlite = ["dep:sqlx", "sqlx?/sqlite", "dep:ouroboros"]
 services-surrealdb = ["dep:surrealdb"]
 services-swift = []
@@ -239,8 +238,6 @@ redis = { version = "1.0", features = [
 ], optional = true }
 # for services-rocksdb
 rocksdb = { version = "0.21.0", default-features = false, optional = true }
-# for services-sled
-sled = { version = "0.34.7", optional = true }
 # for services-tikv
 tikv-client = { version = "0.3.0", optional = true, default-features = false }
 # for services-hdfs-native
diff --git a/core/core/src/services/mod.rs b/core/core/src/services/mod.rs
index 20fafb163..f8dfc907e 100644
--- a/core/core/src/services/mod.rs
+++ b/core/core/src/services/mod.rs
@@ -204,11 +204,6 @@ mod sftp;
 #[cfg(feature = "services-sftp")]
 pub use sftp::*;
 
-#[cfg(feature = "services-sled")]
-mod sled;
-#[cfg(feature = "services-sled")]
-pub use self::sled::*;
-
 #[cfg(feature = "services-sqlite")]
 mod sqlite;
 #[cfg(feature = "services-sqlite")]
diff --git a/core/services/sled/Cargo.toml b/core/services/sled/Cargo.toml
new file mode 100644
index 000000000..e6cf682c9
--- /dev/null
+++ b/core/services/sled/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 sled service implementation"
+name = "opendal-service-sled"
+
+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 }
+serde = { workspace = true, features = ["derive"] }
+sled = "0.34.7"
diff --git a/core/core/src/services/sled/backend.rs 
b/core/services/sled/src/backend.rs
similarity index 99%
rename from core/core/src/services/sled/backend.rs
rename to core/services/sled/src/backend.rs
index d1c8edc2d..9f0cec989 100644
--- a/core/core/src/services/sled/backend.rs
+++ b/core/services/sled/src/backend.rs
@@ -23,8 +23,8 @@ use super::core::*;
 use super::deleter::SledDeleter;
 use super::lister::SledLister;
 use super::writer::SledWriter;
-use crate::raw::*;
-use crate::*;
+use opendal_core::raw::*;
+use opendal_core::*;
 
 // 
https://github.com/spacejam/sled/blob/69294e59c718289ab3cb6bd03ac3b9e1e072a1e7/src/db.rs#L5
 const DEFAULT_TREE_ID: &str = r#"__sled__default"#;
diff --git a/core/core/src/services/sled/config.rs 
b/core/services/sled/src/config.rs
similarity index 92%
rename from core/core/src/services/sled/config.rs
rename to core/services/sled/src/config.rs
index aca7d966a..d84396de2 100644
--- a/core/core/src/services/sled/config.rs
+++ b/core/services/sled/src/config.rs
@@ -44,10 +44,10 @@ impl Debug for SledConfig {
     }
 }
 
-impl crate::Configurator for SledConfig {
+impl opendal_core::Configurator for SledConfig {
     type Builder = SledBuilder;
 
-    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() {
@@ -68,8 +68,8 @@ impl crate::Configurator for SledConfig {
 #[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_tree_and_root() {
diff --git a/core/core/src/services/sled/core.rs 
b/core/services/sled/src/core.rs
similarity index 99%
rename from core/core/src/services/sled/core.rs
rename to core/services/sled/src/core.rs
index d7732953b..d00b8d82f 100644
--- a/core/core/src/services/sled/core.rs
+++ b/core/services/sled/src/core.rs
@@ -17,7 +17,7 @@
 
 use std::fmt::Debug;
 
-use crate::*;
+use opendal_core::*;
 
 #[derive(Clone)]
 pub struct SledCore {
diff --git a/core/core/src/services/sled/deleter.rs 
b/core/services/sled/src/deleter.rs
similarity index 94%
rename from core/core/src/services/sled/deleter.rs
rename to core/services/sled/src/deleter.rs
index 15e15f63c..d7540cb4f 100644
--- a/core/core/src/services/sled/deleter.rs
+++ b/core/services/sled/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 SledDeleter {
     core: Arc<SledCore>,
diff --git a/core/core/src/services/sled/docs.md 
b/core/services/sled/src/docs.md
similarity index 94%
rename from core/core/src/services/sled/docs.md
rename to core/services/sled/src/docs.md
index ee0fb674c..62e3d4e5b 100644
--- a/core/core/src/services/sled/docs.md
+++ b/core/services/sled/src/docs.md
@@ -24,7 +24,7 @@ You can refer to [`SledBuilder`]'s docs for more information
 
 ```rust,no_run
 use anyhow::Result;
-use opendal_core::services::Sled;
+use opendal_service_sled::Sled;
 use opendal_core::Operator;
 
 #[tokio::main]
diff --git a/core/core/src/services/sled/mod.rs b/core/services/sled/src/lib.rs
similarity index 96%
rename from core/core/src/services/sled/mod.rs
rename to core/services/sled/src/lib.rs
index 915fa9de3..91196be64 100644
--- a/core/core/src/services/sled/mod.rs
+++ b/core/services/sled/src/lib.rs
@@ -18,7 +18,7 @@
 /// Default scheme for sled service.
 pub const SLED_SCHEME: &str = "sled";
 
-use crate::types::DEFAULT_OPERATOR_REGISTRY;
+use opendal_core::DEFAULT_OPERATOR_REGISTRY;
 
 mod backend;
 mod config;
diff --git a/core/core/src/services/sled/lister.rs 
b/core/services/sled/src/lister.rs
similarity index 95%
rename from core/core/src/services/sled/lister.rs
rename to core/services/sled/src/lister.rs
index 4529dabe8..04c648cce 100644
--- a/core/core/src/services/sled/lister.rs
+++ b/core/services/sled/src/lister.rs
@@ -19,9 +19,9 @@ use std::sync::Arc;
 use std::vec::IntoIter;
 
 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 SledLister {
     root: String,
diff --git a/core/core/src/services/sled/writer.rs 
b/core/services/sled/src/writer.rs
similarity index 97%
rename from core/core/src/services/sled/writer.rs
rename to core/services/sled/src/writer.rs
index a1178fa87..abd7eaed0 100644
--- a/core/core/src/services/sled/writer.rs
+++ b/core/services/sled/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 SledWriter {
     core: Arc<SledCore>,
diff --git a/core/src/lib.rs b/core/src/lib.rs
index f553e9e2b..9138ae3e5 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -53,6 +53,8 @@ pub mod services {
     pub use opendal_service_postgresql::*;
     #[cfg(feature = "services-s3")]
     pub use opendal_service_s3::*;
+    #[cfg(feature = "services-sled")]
+    pub use opendal_service_sled::*;
     #[cfg(feature = "services-vercel-blob")]
     pub use opendal_service_vercel_blob::*;
 }

Reply via email to