This is an automated email from the ASF dual-hosted git repository. koushiro pushed a commit to branch extract-immutable-index-layer in repository https://gitbox.apache.org/repos/asf/opendal.git
commit 30424c5674bd30c25c90ac6de75bd3e142178ccc Author: koushiro <[email protected]> AuthorDate: Thu Dec 11 14:03:50 2025 +0800 refactor: Split immutable-index layer to new crate --- core/Cargo.lock | 13 +++++++ core/Cargo.toml | 2 ++ core/core/src/layers/mod.rs | 3 -- core/layers/immutable-index/Cargo.toml | 42 ++++++++++++++++++++++ .../immutable-index/src/lib.rs} | 21 ++++++----- core/src/lib.rs | 2 ++ 6 files changed, 69 insertions(+), 14 deletions(-) diff --git a/core/Cargo.lock b/core/Cargo.lock index b8671c60a..8641aca02 100644 --- a/core/Cargo.lock +++ b/core/Cargo.lock @@ -5485,6 +5485,7 @@ dependencies = [ "opendal-layer-await-tree", "opendal-layer-capability-check", "opendal-layer-fastmetrics", + "opendal-layer-immutable-index", "opendal-layer-metrics", "opendal-layer-observe-metrics-common", "opendal-layer-otelmetrics", @@ -5695,6 +5696,18 @@ dependencies = [ "opendal-layer-observe-metrics-common", ] +[[package]] +name = "opendal-layer-immutable-index" +version = "0.55.0" +dependencies = [ + "anyhow", + "futures", + "log", + "opendal-core", + "tokio", + "tracing-subscriber", +] + [[package]] name = "opendal-layer-metrics" version = "0.55.0" diff --git a/core/Cargo.toml b/core/Cargo.toml index cae8ccce8..5c6afef4c 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -92,6 +92,7 @@ layers-capability-check = ["dep:opendal-layer-capability-check"] layers-chaos = ["opendal-core/layers-chaos"] layers-dtrace = ["opendal-core/layers-dtrace"] layers-fastmetrics = ["dep:opendal-layer-fastmetrics"] +layers-immutable-index = ["dep:opendal-layer-immutable-index"] layers-fastrace = ["opendal-core/layers-fastrace"] layers-metrics = ["dep:opendal-layer-metrics"] layers-mime-guess = ["opendal-core/layers-mime-guess"] @@ -196,6 +197,7 @@ opendal-layer-otelmetrics = { path = "layers/otelmetrics", version = "0.55.0", o opendal-layer-prometheus = { path = "layers/prometheus", version = "0.55.0", optional = true, default-features = false } opendal-layer-prometheus-client = { path = "layers/prometheus-client", version = "0.55.0", optional = true, default-features = false } opendal-layer-fastmetrics = { path = "layers/fastmetrics", version = "0.55.0", optional = true, default-features = false } +opendal-layer-immutable-index = { path = "layers/immutable-index", version = "0.55.0", optional = true, default-features = false } opendal-service-aliyun-drive = { path = "services/aliyun-drive", version = "0.55.0", optional = true, default-features = false } opendal-service-azblob = { path = "services/azblob", version = "0.55.0", optional = true, default-features = false } opendal-service-azdls = { path = "services/azdls", version = "0.55.0", optional = true, default-features = false } diff --git a/core/core/src/layers/mod.rs b/core/core/src/layers/mod.rs index 4b1012ff6..375ac2b9d 100644 --- a/core/core/src/layers/mod.rs +++ b/core/core/src/layers/mod.rs @@ -32,9 +32,6 @@ pub use simulate::SimulateLayer; mod concurrent_limit; pub use concurrent_limit::ConcurrentLimitLayer; -mod immutable_index; -pub use immutable_index::ImmutableIndexLayer; - mod logging; pub use logging::LoggingInterceptor; pub use logging::LoggingLayer; diff --git a/core/layers/immutable-index/Cargo.toml b/core/layers/immutable-index/Cargo.toml new file mode 100644 index 000000000..d821c190b --- /dev/null +++ b/core/layers/immutable-index/Cargo.toml @@ -0,0 +1,42 @@ +# 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 immutable-index layer" +name = "opendal-layer-immutable-index" + +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 } + +[dev-dependencies] +anyhow = { version = "1.0.100", features = ["std"] } +futures = { workspace = true, default-features = true } +log = { workspace = true } +opendal-core = { path = "../../core", version = "0.55.0", features = ["services-http"] } +tokio = { workspace = true, features = ["macros", "rt-multi-thread"] } +tracing-subscriber = { version = "0.3", features = ["env-filter", "tracing-log"] } diff --git a/core/core/src/layers/immutable_index.rs b/core/layers/immutable-index/src/lib.rs similarity index 97% rename from core/core/src/layers/immutable_index.rs rename to core/layers/immutable-index/src/lib.rs index b3fc17b03..ff61c0b74 100644 --- a/core/core/src/layers/immutable_index.rs +++ b/core/layers/immutable-index/src/lib.rs @@ -19,8 +19,8 @@ use std::collections::HashSet; use std::fmt::Debug; use std::vec::IntoIter; -use crate::raw::*; -use crate::*; +use opendal_core::raw::*; +use opendal_core::*; /// Add an immutable in-memory index for underlying storage services. /// @@ -30,12 +30,12 @@ use crate::*; /// /// ```rust, no_run /// # use std::collections::HashMap; -/// -/// # use opendal_core::layers::ImmutableIndexLayer; +/// # /// # use opendal_core::services; /// # use opendal_core::Operator; /// # use opendal_core::Result; -/// +/// # use opendal_layer_immutable_index::ImmutableIndexLayer; +/// # /// # fn main() -> Result<()> { /// let mut iil = ImmutableIndexLayer::default(); /// @@ -46,7 +46,7 @@ use crate::*; /// let op = Operator::from_iter::<services::Memory>(HashMap::<_, _>::default())? /// .layer(iil) /// .finish(); -/// Ok(()) +/// # Ok(()) /// # } /// ``` #[derive(Default, Debug, Clone)] @@ -211,7 +211,6 @@ impl oio::List for ImmutableDir { } #[cfg(test)] -#[cfg(feature = "services-http")] mod tests { use std::collections::HashMap; use std::collections::HashSet; @@ -219,12 +218,12 @@ mod tests { use anyhow::Result; use futures::TryStreamExt; use log::debug; + use opendal_core::EntryMode; + use opendal_core::Operator; + use opendal_core::layers::LoggingLayer; + use opendal_core::services::HttpConfig; use super::*; - use crate::EntryMode; - use crate::Operator; - use crate::layers::LoggingLayer; - use crate::services::HttpConfig; #[tokio::test] async fn test_list() -> Result<()> { diff --git a/core/src/lib.rs b/core/src/lib.rs index 594e9d079..d2d6e5b41 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -58,6 +58,8 @@ pub mod layers { pub use opendal_layer_capability_check::*; #[cfg(feature = "layers-fastmetrics")] pub use opendal_layer_fastmetrics::*; + #[cfg(feature = "layers-immutable-index")] + pub use opendal_layer_immutable_index::*; #[cfg(feature = "layers-metrics")] pub use opendal_layer_metrics::*; #[cfg(feature = "layers-otel-metrics")]
