This is an automated email from the ASF dual-hosted git repository.
koushiro 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 a6fa856c8 refactor(services/http): Move services http out as a crate
(#6870)
a6fa856c8 is described below
commit a6fa856c851e540ec88eda7133d4fc171e3901c5
Author: ChenChen Lai <[email protected]>
AuthorDate: Thu Dec 18 14:33:29 2025 +0800
refactor(services/http): Move services http out as a crate (#6870)
* refactor(services/http): Move services http out as a crate
* fix cargo fmt
* fix binding_go error
* modify unrelated code
* format
* Fix
---------
Co-authored-by: Xuanwo <[email protected]>
---
core/Cargo.lock | 14 ++++++++
core/Cargo.toml | 3 +-
core/core/Cargo.toml | 1 -
core/core/src/services/mod.rs | 5 ---
core/services/http/Cargo.toml | 39 ++++++++++++++++++++++
.../services/http => services/http/src}/backend.rs | 4 +--
.../services/http => services/http/src}/config.rs | 8 ++---
.../services/http => services/http/src}/core.rs | 4 +--
.../services/http => services/http/src}/docs.md | 2 +-
.../services/http => services/http/src}/error.rs | 4 +--
.../http/mod.rs => services/http/src/lib.rs} | 12 ++++---
core/src/lib.rs | 2 ++
12 files changed, 75 insertions(+), 23 deletions(-)
diff --git a/core/Cargo.lock b/core/Cargo.lock
index abfca2fa6..d99e5de7d 100644
--- a/core/Cargo.lock
+++ b/core/Cargo.lock
@@ -5573,6 +5573,7 @@ dependencies = [
"opendal-service-ghac",
"opendal-service-github",
"opendal-service-hdfs-native",
+ "opendal-service-http",
"opendal-service-huggingface",
"opendal-service-ipfs",
"opendal-service-koofr",
@@ -6215,6 +6216,19 @@ dependencies = [
"serde",
]
+[[package]]
+name = "opendal-service-http"
+version = "0.55.0"
+dependencies = [
+ "anyhow",
+ "ctor",
+ "http 1.4.0",
+ "log",
+ "opendal-core",
+ "serde",
+ "tokio",
+]
+
[[package]]
name = "opendal-service-huggingface"
version = "0.55.0"
diff --git a/core/Cargo.toml b/core/Cargo.toml
index 9b38beeb2..a2657824b 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -126,7 +126,7 @@ 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"]
-services-http = ["opendal-core/services-http"]
+services-http = ["dep:opendal-service-http"]
services-huggingface = ["dep:opendal-service-huggingface"]
services-ipfs = ["dep:opendal-service-ipfs"]
services-ipmfs = ["opendal-core/services-ipmfs"]
@@ -225,6 +225,7 @@ opendal-service-gcs = { path = "services/gcs", version =
"0.55.0", optional = tr
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-http = { path = "services/http", version = "0.55.0", optional
= true, default-features = false }
opendal-service-huggingface = { path = "services/huggingface", 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-koofr = { path = "services/koofr", version = "0.55.0",
optional = true, default-features = false }
diff --git a/core/core/Cargo.toml b/core/core/Cargo.toml
index baa713915..3e9751e42 100644
--- a/core/core/Cargo.toml
+++ b/core/core/Cargo.toml
@@ -60,7 +60,6 @@ layers-dtrace = ["dep:probe"]
services-gdrive = ["internal-path-cache"]
services-gridfs = ["dep:mongodb", "dep:mongodb-internal-macros"]
services-hdfs = ["dep:hdrs"]
-services-http = []
services-ipmfs = []
services-lakefs = []
services-memory = []
diff --git a/core/core/src/services/mod.rs b/core/core/src/services/mod.rs
index 67b839774..ed83487a3 100644
--- a/core/core/src/services/mod.rs
+++ b/core/core/src/services/mod.rs
@@ -34,11 +34,6 @@ mod hdfs;
#[cfg(feature = "services-hdfs")]
pub use self::hdfs::*;
-#[cfg(feature = "services-http")]
-mod http;
-#[cfg(feature = "services-http")]
-pub use self::http::*;
-
#[cfg(feature = "services-ipmfs")]
mod ipmfs;
#[cfg(feature = "services-ipmfs")]
diff --git a/core/services/http/Cargo.toml b/core/services/http/Cargo.toml
new file mode 100644
index 000000000..f993b7c7b
--- /dev/null
+++ b/core/services/http/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 HTTP service implementation"
+edition = "2024"
+license = "Apache-2.0"
+name = "opendal-service-http"
+repository = "https://github.com/apache/opendal"
+version = "0.55.0"
+
+[package.metadata.docs.rs]
+all-features = true
+
+[dependencies]
+ctor = "0.6"
+http = "1.1"
+log = "0.4"
+opendal-core = { path = "../../core", version = "0.55.0", default-features =
false }
+serde = { version = "1", features = ["derive"] }
+
+[dev-dependencies]
+anyhow = { version = "1.0.100", features = ["std"] }
+opendal-core = { path = "../../core", version = "0.55.0", default-features =
false }
+tokio = { version = "1.48", features = ["macros", "rt-multi-thread"] }
diff --git a/core/core/src/services/http/backend.rs
b/core/services/http/src/backend.rs
similarity index 99%
rename from core/core/src/services/http/backend.rs
rename to core/services/http/src/backend.rs
index 5d490cd22..9d99cf089 100644
--- a/core/core/src/services/http/backend.rs
+++ b/core/services/http/src/backend.rs
@@ -26,8 +26,8 @@ use super::HTTP_SCHEME;
use super::config::HttpConfig;
use super::core::HttpCore;
use super::error::parse_error;
-use crate::raw::*;
-use crate::*;
+use opendal_core::raw::*;
+use opendal_core::*;
/// HTTP Read-only service support like [Nginx](https://www.nginx.com/) and
[Caddy](https://caddyserver.com/).
#[doc = include_str!("docs.md")]
diff --git a/core/core/src/services/http/config.rs
b/core/services/http/src/config.rs
similarity index 94%
rename from core/core/src/services/http/config.rs
rename to core/services/http/src/config.rs
index f0a050482..4e5578920 100644
--- a/core/core/src/services/http/config.rs
+++ b/core/services/http/src/config.rs
@@ -48,10 +48,10 @@ impl Debug for HttpConfig {
}
}
-impl crate::Configurator for HttpConfig {
+impl opendal_core::Configurator for HttpConfig {
type Builder = HttpBuilder;
- 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() {
map.insert(
@@ -75,8 +75,8 @@ impl crate::Configurator for HttpConfig {
#[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_endpoint_and_root() {
diff --git a/core/core/src/services/http/core.rs
b/core/services/http/src/core.rs
similarity index 98%
rename from core/core/src/services/http/core.rs
rename to core/services/http/src/core.rs
index a2f02004a..69c2aa3c5 100644
--- a/core/core/src/services/http/core.rs
+++ b/core/services/http/src/core.rs
@@ -24,8 +24,8 @@ use http::header;
use http::header::IF_MATCH;
use http::header::IF_NONE_MATCH;
-use crate::raw::*;
-use crate::*;
+use opendal_core::raw::*;
+use opendal_core::*;
pub struct HttpCore {
pub info: Arc<AccessorInfo>,
diff --git a/core/core/src/services/http/docs.md
b/core/services/http/src/docs.md
similarity index 95%
rename from core/core/src/services/http/docs.md
rename to core/services/http/src/docs.md
index 20c3cb8a0..d11ff8ea0 100644
--- a/core/core/src/services/http/docs.md
+++ b/core/services/http/src/docs.md
@@ -30,7 +30,7 @@ You can refer to [`HttpBuilder`]'s docs for more information
```rust,no_run
use anyhow::Result;
-use opendal_core::services::Http;
+use opendal_service_http::Http;
use opendal_core::Operator;
#[tokio::main]
diff --git a/core/core/src/services/http/error.rs
b/core/services/http/src/error.rs
similarity index 97%
rename from core/core/src/services/http/error.rs
rename to core/services/http/src/error.rs
index 091500892..f1473891b 100644
--- a/core/core/src/services/http/error.rs
+++ b/core/services/http/src/error.rs
@@ -18,8 +18,8 @@
use http::Response;
use http::StatusCode;
-use crate::raw::*;
-use crate::*;
+use opendal_core::raw::*;
+use opendal_core::*;
/// Parse error response into Error.
pub(super) fn parse_error(resp: Response<Buffer>) -> Error {
diff --git a/core/core/src/services/http/mod.rs b/core/services/http/src/lib.rs
similarity index 84%
rename from core/core/src/services/http/mod.rs
rename to core/services/http/src/lib.rs
index 5b3975d7b..f13cc8652 100644
--- a/core/core/src/services/http/mod.rs
+++ b/core/services/http/src/lib.rs
@@ -15,10 +15,9 @@
// specific language governing permissions and limitations
// under the License.
-/// Default scheme for http service.
-pub const HTTP_SCHEME: &str = "http";
-
-use crate::types::DEFAULT_OPERATOR_REGISTRY;
+#![cfg_attr(docsrs, feature(doc_cfg))]
+//! HTTP service implementation for Apache OpenDAL.
+#![deny(missing_docs)]
mod backend;
mod config;
@@ -28,7 +27,10 @@ mod error;
pub use backend::HttpBuilder as Http;
pub use config::HttpConfig;
+/// Default scheme for http service.
+pub const HTTP_SCHEME: &str = "http";
+
#[ctor::ctor]
fn register_http_service() {
- DEFAULT_OPERATOR_REGISTRY.register::<Http>(HTTP_SCHEME);
+ opendal_core::DEFAULT_OPERATOR_REGISTRY.register::<Http>(HTTP_SCHEME);
}
diff --git a/core/src/lib.rs b/core/src/lib.rs
index bafdec79e..e36baa274 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -74,6 +74,8 @@ pub mod services {
pub use opendal_service_github::*;
#[cfg(feature = "services-hdfs-native")]
pub use opendal_service_hdfs_native::*;
+ #[cfg(feature = "services-http")]
+ pub use opendal_service_http::*;
#[cfg(feature = "services-huggingface")]
pub use opendal_service_huggingface::*;
#[cfg(feature = "services-ipfs")]