Xuanwo commented on code in PR #2006:
URL:
https://github.com/apache/incubator-opendal/pull/2006#discussion_r1167551604
##########
core/src/layers/mod.rs:
##########
@@ -18,37 +18,53 @@
//! `Layer` is the mechanism to intercept operations.
mod concurrent_limit;
+
Review Comment:
Please don't include unrelated changes.
##########
core/Cargo.toml:
##########
@@ -104,6 +104,7 @@ http = "0.2.5"
hyper = "0.14"
lazy-regex = { version = "2.5.0", optional = true }
log = "0.4"
+madsim = "0.2.19"
Review Comment:
It's better to include `madsim` as `optional` dep. We can add a new feature
called `layers-madsim` for it.
##########
core/src/layers/mod.rs:
##########
@@ -18,37 +18,53 @@
//! `Layer` is the mechanism to intercept operations.
mod concurrent_limit;
+
pub use concurrent_limit::ConcurrentLimitLayer;
mod immutable_index;
+
pub use immutable_index::ImmutableIndexLayer;
mod logging;
+
pub use logging::LoggingLayer;
#[cfg(feature = "layers-chaos")]
mod chaos;
+
#[cfg(feature = "layers-chaos")]
pub use chaos::ChaosLayer;
#[cfg(feature = "layers-metrics")]
mod metrics;
+
#[cfg(feature = "layers-metrics")]
pub use self::metrics::MetricsLayer;
mod retry;
+
pub use self::retry::RetryLayer;
#[cfg(feature = "layers-tracing")]
mod tracing;
+
#[cfg(feature = "layers-tracing")]
pub use self::tracing::TracingLayer;
mod type_eraser;
+
pub(crate) use type_eraser::TypeEraseLayer;
mod error_context;
+
pub(crate) use error_context::ErrorContextLayer;
mod complete;
+
pub(crate) use complete::CompleteLayer;
+
+mod simulation;
+
+pub use simulation::MadsimLayer;
+#[cfg(madsim)]
Review Comment:
I believe opendal is not a right place for adding `cfg`.
- OpenDAL adds a new feautre to control whether we provide madsim layer.
- Users can use the way they prefer to control the logic.
##########
core/src/layers/simulation/real.rs:
##########
@@ -0,0 +1,99 @@
+// 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.
+
+use crate::ops::{OpList, OpRead, OpScan, OpWrite};
+use crate::raw::{Accessor, Layer, LayeredAccessor, RpList, RpRead, RpScan,
RpWrite};
+use async_trait::async_trait;
+
+#[derive(Debug, Copy, Clone, Default)]
+pub struct MadsimLayer;
+
+impl<A: Accessor> Layer<A> for MadsimLayer {
Review Comment:
I feel like we don't need to provide a `real` mod here. It's easier for
users to add a layer or not. For example:
```rust
#[cfg(feature = "layers-chaos")]
let op = {
use opendal::layers::ChaosLayer;
op.layer(ChaosLayer::new(0.1))
};
```
In `MadsimLayer`, we can focus on madsim itself's logic.
##########
core/src/layers/simulation/mod.rs:
##########
Review Comment:
I perfer to have a `madsim.rs` instead a `simulation` mod.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]