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 731ada84f refactor: Split service github out of core (#7018)
731ada84f is described below

commit 731ada84f8771f13d617d34459529d6d0dcbacf0
Author: Jintao Zhang <[email protected]>
AuthorDate: Tue Dec 16 21:20:12 2025 +0800

    refactor: Split service github out of core (#7018)
    
    Signed-off-by: Jintao Zhang <[email protected]>
---
 core/Cargo.lock                                    | 16 ++++++++
 core/Cargo.toml                                    |  3 +-
 core/core/Cargo.toml                               |  1 -
 core/core/src/services/mod.rs                      |  5 ---
 core/services/github/Cargo.toml                    | 45 ++++++++++++++++++++++
 .../github => services/github/src}/backend.rs      |  4 +-
 .../github => services/github/src}/config.rs       | 32 +++++++--------
 .../github => services/github/src}/core.rs         |  4 +-
 .../github => services/github/src}/deleter.rs      |  4 +-
 .../github => services/github/src}/docs.md         |  5 +--
 .../github => services/github/src}/error.rs        |  4 +-
 .../github/mod.rs => services/github/src/lib.rs}   |  2 +-
 .../github => services/github/src}/lister.rs       |  6 +--
 .../services/github => services/github/src}/mod.rs |  0
 .../github => services/github/src}/writer.rs       |  4 +-
 core/src/lib.rs                                    |  2 +
 16 files changed, 94 insertions(+), 43 deletions(-)

diff --git a/core/Cargo.lock b/core/Cargo.lock
index cc0573fdc..0b7deee63 100644
--- a/core/Cargo.lock
+++ b/core/Cargo.lock
@@ -5564,6 +5564,7 @@ dependencies = [
  "opendal-service-ftp",
  "opendal-service-gcs",
  "opendal-service-ghac",
+ "opendal-service-github",
  "opendal-service-hdfs-native",
  "opendal-service-ipfs",
  "opendal-service-memcached",
@@ -6087,6 +6088,21 @@ dependencies = [
  "sha2",
 ]
 
+[[package]]
+name = "opendal-service-github"
+version = "0.55.0"
+dependencies = [
+ "base64 0.22.1",
+ "bytes",
+ "ctor",
+ "http 1.4.0",
+ "log",
+ "opendal-core",
+ "serde",
+ "serde_json",
+ "tokio",
+]
+
 [[package]]
 name = "opendal-service-hdfs-native"
 version = "0.55.0"
diff --git a/core/Cargo.toml b/core/Cargo.toml
index 39d007e58..db80c0f11 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -122,7 +122,7 @@ services-ftp = ["dep:opendal-service-ftp"]
 services-gcs = ["dep:opendal-service-gcs"]
 services-gdrive = ["opendal-core/services-gdrive"]
 services-ghac = ["dep:opendal-service-ghac"]
-services-github = ["opendal-core/services-github"]
+services-github = ["dep:opendal-service-github"]
 services-gridfs = ["opendal-core/services-gridfs"]
 services-hdfs = ["opendal-core/services-hdfs"]
 services-hdfs-native = ["dep:opendal-service-hdfs-native"]
@@ -216,6 +216,7 @@ opendal-service-fs = { path = "services/fs", version = 
"0.55.0", optional = true
 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 }
 opendal-service-ghac = { path = "services/ghac", version = "0.55.0", optional 
= true, default-features = false }
+opendal-service-github = { path = "services/github", 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-ipfs = { path = "services/ipfs", version = "0.55.0", optional 
= true, default-features = false }
 opendal-service-memcached = { path = "services/memcached", version = "0.55.0", 
optional = true, default-features = false }
diff --git a/core/core/Cargo.toml b/core/core/Cargo.toml
index 57f3082f2..04947df7a 100644
--- a/core/core/Cargo.toml
+++ b/core/core/Cargo.toml
@@ -65,7 +65,6 @@ services-dropbox = []
 services-etcd = ["dep:etcd-client", "dep:fastpool"]
 services-foundationdb = ["dep:foundationdb"]
 services-gdrive = ["internal-path-cache"]
-services-github = []
 services-gridfs = ["dep:mongodb", "dep:mongodb-internal-macros"]
 services-hdfs = ["dep:hdrs"]
 services-http = []
diff --git a/core/core/src/services/mod.rs b/core/core/src/services/mod.rs
index 5b3e62463..77d558df2 100644
--- a/core/core/src/services/mod.rs
+++ b/core/core/src/services/mod.rs
@@ -59,11 +59,6 @@ mod gdrive;
 #[cfg(feature = "services-gdrive")]
 pub use gdrive::*;
 
-#[cfg(feature = "services-github")]
-mod github;
-#[cfg(feature = "services-github")]
-pub use github::*;
-
 #[cfg(feature = "services-gridfs")]
 mod gridfs;
 #[cfg(feature = "services-gridfs")]
diff --git a/core/services/github/Cargo.toml b/core/services/github/Cargo.toml
new file mode 100644
index 000000000..fa158112e
--- /dev/null
+++ b/core/services/github/Cargo.toml
@@ -0,0 +1,45 @@
+# 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 GitHub service implementation"
+name = "opendal-service-github"
+
+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 }
+
+base64 = { workspace = true }
+bytes = { workspace = true }
+ctor = { workspace = true }
+http = { workspace = true }
+log = { workspace = true }
+serde = { workspace = true, features = ["derive"] }
+serde_json = { workspace = true }
+
+[dev-dependencies]
+tokio = { workspace = true, features = ["full"] }
diff --git a/core/core/src/services/github/backend.rs 
b/core/services/github/src/backend.rs
similarity index 99%
rename from core/core/src/services/github/backend.rs
rename to core/services/github/src/backend.rs
index b48373071..2fca63d4f 100644
--- a/core/core/src/services/github/backend.rs
+++ b/core/services/github/src/backend.rs
@@ -32,8 +32,8 @@ use super::error::parse_error;
 use super::lister::GithubLister;
 use super::writer::GithubWriter;
 use super::writer::GithubWriters;
-use crate::raw::*;
-use crate::*;
+use opendal_core::raw::*;
+use opendal_core::*;
 
 /// [github 
contents](https://docs.github.com/en/rest/repos/contents?apiVersion=2022-11-28#create-or-update-file-contents)
 services support.
 #[doc = include_str!("docs.md")]
diff --git a/core/core/src/services/github/config.rs 
b/core/services/github/src/config.rs
similarity index 81%
rename from core/core/src/services/github/config.rs
rename to core/services/github/src/config.rs
index 553fd92fb..62e0fb5b5 100644
--- a/core/core/src/services/github/config.rs
+++ b/core/services/github/src/config.rs
@@ -22,6 +22,7 @@ use serde::Serialize;
 
 use super::GITHUB_SCHEME;
 use super::backend::GithubBuilder;
+use opendal_core::{Configurator, Error, ErrorKind, OperatorUri, Result};
 
 /// Config for GitHub services support.
 #[derive(Default, Serialize, Deserialize, Clone, PartialEq, Eq)]
@@ -58,24 +59,18 @@ impl Debug for GithubConfig {
     }
 }
 
-impl crate::Configurator for GithubConfig {
+impl Configurator for GithubConfig {
     type Builder = GithubBuilder;
 
-    fn from_uri(uri: &crate::types::OperatorUri) -> crate::Result<Self> {
+    fn from_uri(uri: &OperatorUri) -> Result<Self> {
         let owner = uri.name().ok_or_else(|| {
-            crate::Error::new(
-                crate::ErrorKind::ConfigInvalid,
-                "uri host must contain owner",
-            )
-            .with_context("service", GITHUB_SCHEME)
+            Error::new(ErrorKind::ConfigInvalid, "uri host must contain owner")
+                .with_context("service", GITHUB_SCHEME)
         })?;
 
         let raw_path = uri.root().ok_or_else(|| {
-            crate::Error::new(
-                crate::ErrorKind::ConfigInvalid,
-                "uri path must contain repository",
-            )
-            .with_context("service", GITHUB_SCHEME)
+            Error::new(ErrorKind::ConfigInvalid, "uri path must contain 
repository")
+                .with_context("service", GITHUB_SCHEME)
         })?;
 
         let (repo, remainder) = match raw_path.split_once('/') {
@@ -84,11 +79,10 @@ impl crate::Configurator for GithubConfig {
         };
 
         if repo.is_empty() {
-            return Err(crate::Error::new(
-                crate::ErrorKind::ConfigInvalid,
-                "repository name is required",
-            )
-            .with_context("service", GITHUB_SCHEME));
+            return Err(
+                Error::new(ErrorKind::ConfigInvalid, "repository name is 
required")
+                    .with_context("service", GITHUB_SCHEME),
+            );
         }
 
         let mut map = uri.options().clone();
@@ -112,8 +106,8 @@ impl crate::Configurator for GithubConfig {
 #[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_owner_repo_and_root() {
diff --git a/core/core/src/services/github/core.rs 
b/core/services/github/src/core.rs
similarity index 99%
rename from core/core/src/services/github/core.rs
rename to core/services/github/src/core.rs
index 55b1686ae..68d6c9ece 100644
--- a/core/core/src/services/github/core.rs
+++ b/core/services/github/src/core.rs
@@ -30,8 +30,8 @@ use serde::Deserialize;
 use serde::Serialize;
 
 use super::error::parse_error;
-use crate::raw::*;
-use crate::*;
+use opendal_core::raw::*;
+use opendal_core::*;
 
 /// Core of [github 
contents](https://docs.github.com/en/rest/repos/contents?apiVersion=2022-11-28#create-or-update-file-contents)
 services support.
 #[derive(Clone)]
diff --git a/core/core/src/services/github/deleter.rs 
b/core/services/github/src/deleter.rs
similarity index 96%
rename from core/core/src/services/github/deleter.rs
rename to core/services/github/src/deleter.rs
index 2e73750a8..e5c8a591b 100644
--- a/core/core/src/services/github/deleter.rs
+++ b/core/services/github/src/deleter.rs
@@ -18,8 +18,8 @@
 use std::sync::Arc;
 
 use super::core::*;
-use crate::raw::*;
-use crate::*;
+use opendal_core::raw::*;
+use opendal_core::*;
 
 pub struct GithubDeleter {
     core: Arc<GithubCore>,
diff --git a/core/core/src/services/github/docs.md 
b/core/services/github/src/docs.md
similarity index 90%
rename from core/core/src/services/github/docs.md
rename to core/services/github/src/docs.md
index d17af27fb..9f7b4306b 100644
--- a/core/core/src/services/github/docs.md
+++ b/core/services/github/src/docs.md
@@ -26,12 +26,11 @@ You can refer to [`GithubBuilder`]'s docs for more 
information
 ### Via Builder
 
 ```rust,no_run
-use anyhow::Result;
-use opendal_core::services::Github;
+use opendal_service_github::Github;
 use opendal_core::Operator;
 
 #[tokio::main]
-async fn main() -> Result<()> {
+async fn main() -> opendal_core::Result<()> {
     // create backend builder
     let mut builder = Github::default()
         // set the storage root for OpenDAL
diff --git a/core/core/src/services/github/error.rs 
b/core/services/github/src/error.rs
similarity index 98%
rename from core/core/src/services/github/error.rs
rename to core/services/github/src/error.rs
index cfc259c11..1b35858be 100644
--- a/core/core/src/services/github/error.rs
+++ b/core/services/github/src/error.rs
@@ -19,8 +19,8 @@ use bytes::Buf;
 use http::Response;
 use serde::Deserialize;
 
-use crate::raw::*;
-use crate::*;
+use opendal_core::raw::*;
+use opendal_core::*;
 
 #[derive(Default, Debug, Deserialize)]
 #[allow(dead_code)]
diff --git a/core/core/src/services/github/mod.rs 
b/core/services/github/src/lib.rs
similarity index 96%
copy from core/core/src/services/github/mod.rs
copy to core/services/github/src/lib.rs
index 9cb8c0abd..7297081cc 100644
--- a/core/core/src/services/github/mod.rs
+++ b/core/services/github/src/lib.rs
@@ -18,7 +18,7 @@
 /// Default scheme for github service.
 pub const GITHUB_SCHEME: &str = "github";
 
-use crate::types::DEFAULT_OPERATOR_REGISTRY;
+use opendal_core::DEFAULT_OPERATOR_REGISTRY;
 
 mod backend;
 mod config;
diff --git a/core/core/src/services/github/lister.rs 
b/core/services/github/src/lister.rs
similarity index 97%
rename from core/core/src/services/github/lister.rs
rename to core/services/github/src/lister.rs
index ac36bff67..327893060 100644
--- a/core/core/src/services/github/lister.rs
+++ b/core/services/github/src/lister.rs
@@ -18,9 +18,9 @@
 use std::sync::Arc;
 
 use super::core::GithubCore;
-use crate::raw::oio::Entry;
-use crate::raw::*;
-use crate::*;
+use opendal_core::raw::oio::Entry;
+use opendal_core::raw::*;
+use opendal_core::*;
 
 pub struct GithubLister {
     core: Arc<GithubCore>,
diff --git a/core/core/src/services/github/mod.rs 
b/core/services/github/src/mod.rs
similarity index 100%
rename from core/core/src/services/github/mod.rs
rename to core/services/github/src/mod.rs
diff --git a/core/core/src/services/github/writer.rs 
b/core/services/github/src/writer.rs
similarity index 97%
rename from core/core/src/services/github/writer.rs
rename to core/services/github/src/writer.rs
index c8ad090d7..7a7566d7f 100644
--- a/core/core/src/services/github/writer.rs
+++ b/core/services/github/src/writer.rs
@@ -22,8 +22,8 @@ use http::StatusCode;
 
 use super::core::GithubCore;
 use super::error::parse_error;
-use crate::raw::*;
-use crate::*;
+use opendal_core::raw::*;
+use opendal_core::*;
 
 pub type GithubWriters = oio::OneShotWriter<GithubWriter>;
 
diff --git a/core/src/lib.rs b/core/src/lib.rs
index 0393688d5..f18c5f8f5 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -56,6 +56,8 @@ pub mod services {
     pub use opendal_service_gcs::*;
     #[cfg(feature = "services-ghac")]
     pub use opendal_service_ghac::*;
+    #[cfg(feature = "services-github")]
+    pub use opendal_service_github::*;
     #[cfg(feature = "services-hdfs-native")]
     pub use opendal_service_hdfs_native::*;
     #[cfg(feature = "services-ipfs")]

Reply via email to