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 13334c9f3 refactor: Split service mysql to new crate  (#6960)
13334c9f3 is described below

commit 13334c9f362512c273825eef9aea853e30fac1b6
Author: fenfeng9 <[email protected]>
AuthorDate: Wed Dec 10 22:36:58 2025 +0800

    refactor: Split service mysql to new crate  (#6960)
    
    * refactor(core): make BytesRange::to_range_as_usize public
    
    * refactor(services/mysql): split service into standalone crate
---
 core/Cargo.lock                                    | 12 +++++++
 core/Cargo.toml                                    |  3 +-
 core/core/Cargo.toml                               |  1 -
 core/core/src/raw/http_util/bytes_range.rs         |  2 +-
 core/core/src/services/mod.rs                      |  5 ---
 core/services/mysql/Cargo.toml                     | 39 ++++++++++++++++++++++
 .../mysql => services/mysql/src}/backend.rs        |  6 ++--
 .../mysql => services/mysql/src}/config.rs         |  8 ++---
 .../services/mysql => services/mysql/src}/core.rs  |  2 +-
 .../mysql => services/mysql/src}/deleter.rs        |  6 ++--
 .../services/mysql => services/mysql/src}/docs.md  |  2 +-
 .../mysql/mod.rs => services/mysql/src/lib.rs}     |  2 +-
 .../mysql => services/mysql/src}/writer.rs         |  4 +--
 core/src/lib.rs                                    |  2 ++
 14 files changed, 71 insertions(+), 23 deletions(-)

diff --git a/core/Cargo.lock b/core/Cargo.lock
index b29dab5b6..b8671c60a 100644
--- a/core/Cargo.lock
+++ b/core/Cargo.lock
@@ -5497,6 +5497,7 @@ dependencies = [
  "opendal-service-ghac",
  "opendal-service-hdfs-native",
  "opendal-service-moka",
+ "opendal-service-mysql",
  "opendal-service-s3",
  "opentelemetry",
  "opentelemetry-otlp",
@@ -5856,6 +5857,17 @@ dependencies = [
  "serde",
 ]
 
+[[package]]
+name = "opendal-service-mysql"
+version = "0.55.0"
+dependencies = [
+ "ctor",
+ "mea",
+ "opendal-core",
+ "serde",
+ "sqlx",
+]
+
 [[package]]
 name = "opendal-service-s3"
 version = "0.55.0"
diff --git a/core/Cargo.toml b/core/Cargo.toml
index da605cd87..cae8ccce8 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -139,7 +139,7 @@ services-mini-moka = ["opendal-core/services-mini-moka"]
 services-moka = ["dep:opendal-service-moka"]
 services-mongodb = ["opendal-core/services-mongodb"]
 services-monoiofs = ["opendal-core/services-monoiofs"]
-services-mysql = ["opendal-core/services-mysql"]
+services-mysql = ["dep:opendal-service-mysql"]
 services-obs = ["opendal-core/services-obs"]
 services-onedrive = ["opendal-core/services-onedrive"]
 services-opfs = ["opendal-core/services-opfs"]
@@ -203,6 +203,7 @@ opendal-service-azfile = { path = "services/azfile", 
version = "0.55.0", optiona
 opendal-service-ghac = { path = "services/ghac", 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 }
 opendal-service-moka = { path = "services/moka", 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-s3 = { path = "services/s3", version = "0.55.0", optional = 
true, default-features = false }
 
 [dev-dependencies]
diff --git a/core/core/Cargo.toml b/core/core/Cargo.toml
index fc6b50471..24dd72439 100644
--- a/core/core/Cargo.toml
+++ b/core/core/Cargo.toml
@@ -128,7 +128,6 @@ services-memory = []
 services-mini-moka = ["dep:mini-moka"]
 services-mongodb = ["dep:mongodb", "dep:mongodb-internal-macros"]
 services-monoiofs = ["dep:monoio", "dep:flume"]
-services-mysql = ["dep:sqlx", "sqlx?/mysql"]
 services-obs = [
   "dep:reqsign",
   "reqsign?/services-huaweicloud",
diff --git a/core/core/src/raw/http_util/bytes_range.rs 
b/core/core/src/raw/http_util/bytes_range.rs
index 23b4a3d9b..ca68e5e41 100644
--- a/core/core/src/raw/http_util/bytes_range.rs
+++ b/core/core/src/raw/http_util/bytes_range.rs
@@ -105,7 +105,7 @@ impl BytesRange {
     }
 
     /// Convert bytes range into rust range with usize.
-    pub(crate) fn to_range_as_usize(self) -> impl RangeBounds<usize> {
+    pub fn to_range_as_usize(self) -> impl RangeBounds<usize> {
         (
             Bound::Included(self.0 as usize),
             match self.1 {
diff --git a/core/core/src/services/mod.rs b/core/core/src/services/mod.rs
index 2033e882a..da251f280 100644
--- a/core/core/src/services/mod.rs
+++ b/core/core/src/services/mod.rs
@@ -169,11 +169,6 @@ mod monoiofs;
 #[cfg(feature = "services-monoiofs")]
 pub use monoiofs::*;
 
-#[cfg(feature = "services-mysql")]
-mod mysql;
-#[cfg(feature = "services-mysql")]
-pub use self::mysql::*;
-
 #[cfg(feature = "services-obs")]
 mod obs;
 #[cfg(feature = "services-obs")]
diff --git a/core/services/mysql/Cargo.toml b/core/services/mysql/Cargo.toml
new file mode 100644
index 000000000..99efc9871
--- /dev/null
+++ b/core/services/mysql/Cargo.toml
@@ -0,0 +1,39 @@
+# 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 MySQL service implementation"
+name = "opendal-service-mysql"
+
+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 }
+
+ctor = { workspace = true }
+mea = { version = "0.5.1" }
+serde = { workspace = true, features = ["derive"] }
+sqlx = { version = "0.8.0", features = ["runtime-tokio-rustls", "mysql"] }
diff --git a/core/core/src/services/mysql/backend.rs 
b/core/services/mysql/src/backend.rs
similarity index 98%
rename from core/core/src/services/mysql/backend.rs
rename to core/services/mysql/src/backend.rs
index cb6ee4678..a40b8d098 100644
--- a/core/core/src/services/mysql/backend.rs
+++ b/core/services/mysql/src/backend.rs
@@ -26,9 +26,9 @@ use super::config::MysqlConfig;
 use super::core::*;
 use super::deleter::MysqlDeleter;
 use super::writer::MysqlWriter;
-use crate::raw::oio;
-use crate::raw::*;
-use crate::*;
+use opendal_core::raw::oio;
+use opendal_core::raw::*;
+use opendal_core::*;
 
 #[doc = include_str!("docs.md")]
 #[derive(Debug, Default)]
diff --git a/core/core/src/services/mysql/config.rs 
b/core/services/mysql/src/config.rs
similarity index 95%
rename from core/core/src/services/mysql/config.rs
rename to core/services/mysql/src/config.rs
index 3614f0a78..20992261b 100644
--- a/core/core/src/services/mysql/config.rs
+++ b/core/services/mysql/src/config.rs
@@ -61,10 +61,10 @@ impl Debug for MysqlConfig {
     }
 }
 
-impl crate::Configurator for MysqlConfig {
+impl opendal_core::Configurator for MysqlConfig {
     type Builder = MysqlBuilder;
 
-    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() {
@@ -103,8 +103,8 @@ impl crate::Configurator for MysqlConfig {
 #[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_table_and_root() {
diff --git a/core/core/src/services/mysql/core.rs 
b/core/services/mysql/src/core.rs
similarity index 99%
rename from core/core/src/services/mysql/core.rs
rename to core/services/mysql/src/core.rs
index 3a346e9c5..3a366dced 100644
--- a/core/core/src/services/mysql/core.rs
+++ b/core/services/mysql/src/core.rs
@@ -19,7 +19,7 @@ use mea::once::OnceCell;
 use sqlx::MySqlPool;
 use sqlx::mysql::MySqlConnectOptions;
 
-use crate::*;
+use opendal_core::*;
 
 #[derive(Clone, Debug)]
 pub struct MysqlCore {
diff --git a/core/core/src/services/mysql/deleter.rs 
b/core/services/mysql/src/deleter.rs
similarity index 94%
rename from core/core/src/services/mysql/deleter.rs
rename to core/services/mysql/src/deleter.rs
index ca5c2f4fc..4ea1b7182 100644
--- a/core/core/src/services/mysql/deleter.rs
+++ b/core/services/mysql/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 MysqlDeleter {
     core: Arc<MysqlCore>,
diff --git a/core/core/src/services/mysql/docs.md 
b/core/services/mysql/src/docs.md
similarity index 96%
rename from core/core/src/services/mysql/docs.md
rename to core/services/mysql/src/docs.md
index 5acc25cb8..c7b6839b8 100644
--- a/core/core/src/services/mysql/docs.md
+++ b/core/services/mysql/src/docs.md
@@ -26,7 +26,7 @@ This service can be used to:
 
 ```rust,no_run
 use anyhow::Result;
-use opendal_core::services::Mysql;
+use opendal_service_mysql::Mysql;
 use opendal_core::Operator;
 
 #[tokio::main]
diff --git a/core/core/src/services/mysql/mod.rs 
b/core/services/mysql/src/lib.rs
similarity index 96%
rename from core/core/src/services/mysql/mod.rs
rename to core/services/mysql/src/lib.rs
index 3bd42214e..c16bcdc06 100644
--- a/core/core/src/services/mysql/mod.rs
+++ b/core/services/mysql/src/lib.rs
@@ -18,7 +18,7 @@
 /// Default scheme for mysql service.
 pub const MYSQL_SCHEME: &str = "mysql";
 
-use crate::types::DEFAULT_OPERATOR_REGISTRY;
+use opendal_core::DEFAULT_OPERATOR_REGISTRY;
 
 mod backend;
 mod config;
diff --git a/core/core/src/services/mysql/writer.rs 
b/core/services/mysql/src/writer.rs
similarity index 97%
rename from core/core/src/services/mysql/writer.rs
rename to core/services/mysql/src/writer.rs
index 3dc6d97b9..7473412f5 100644
--- a/core/core/src/services/mysql/writer.rs
+++ b/core/services/mysql/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 MysqlWriter {
     core: Arc<MysqlCore>,
diff --git a/core/src/lib.rs b/core/src/lib.rs
index 5a6625e97..594e9d079 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -41,6 +41,8 @@ pub mod services {
     pub use opendal_service_hdfs_native::*;
     #[cfg(feature = "services-moka")]
     pub use opendal_service_moka::*;
+    #[cfg(feature = "services-mysql")]
+    pub use opendal_service_mysql::*;
     #[cfg(feature = "services-s3")]
     pub use opendal_service_s3::*;
 }

Reply via email to