Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(layers): check the examples when running tests #5104

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 111 additions & 0 deletions core/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ services-icloud = ["internal-path-cache"]
services-ipfs = ["dep:prost"]
services-ipmfs = []
services-koofr = []
services-lakefs = []
services-libsql = ["dep:hrana-client-proto"]
services-memcached = ["dep:bb8"]
services-memory = []
Expand Down Expand Up @@ -200,7 +201,7 @@ services-vercel-blob = []
services-webdav = []
services-webhdfs = []
services-yandex-disk = []
services-lakefs = []

[lib]
bench = false

Expand Down Expand Up @@ -374,22 +375,26 @@ probe = { version = "0.5.1", optional = true }

[target.'cfg(target_arch = "wasm32")'.dependencies]
backon = { version = "1.0.1", features = ["gloo-timers-sleep"] }
tokio = { version = "1.27", features = ["time"] }
getrandom = { version = "0.2", features = ["js"] }
tokio = { version = "1.27", features = ["time"] }

[dev-dependencies]
criterion = { version = "0.5", features = ["async", "async_tokio"] }
dotenvy = "0.15"
fastrace = { version = "0.7", features = ["enable"] }
fastrace-jaeger = "0.7"
libtest-mimic = "0.7"
opentelemetry = { version = "0.24", default-features = false, features = [
"trace",
] }
opentelemetry-otlp = "0.17"
opentelemetry_sdk = "0.24"
pretty_assertions = "1"
rand = "0.8"
sha2 = "0.10"
size = "0.4"
tokio = { version = "1.27", features = ["fs", "macros", "rt-multi-thread"] }
tracing-opentelemetry = "0.25.0"
tracing-subscriber = { version = "0.3", features = [
"env-filter",
"tracing-log",
Expand Down
17 changes: 9 additions & 8 deletions core/src/layers/async_backtrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,19 @@ use crate::*;
/// # Examples
///
/// ```no_run
/// use anyhow::Result;
/// use opendal::layers::AsyncBacktraceLayer;
/// use opendal::services;
/// use opendal::Operator;
/// use opendal::Scheme;
/// # use opendal::layers::AsyncBacktraceLayer;
/// # use opendal::services;
/// # use opendal::Operator;
/// # use opendal::Result;
/// # use opendal::Scheme;
///
/// let _ = Operator::new(services::Memory::default())
/// .expect("must init")
/// # fn main() -> Result<()> {
/// let _ = Operator::new(services::Memory::default())?
/// .layer(AsyncBacktraceLayer::default())
/// .finish();
/// Ok(())
/// # }
/// ```

#[derive(Clone, Default)]
pub struct AsyncBacktraceLayer;

Expand Down
18 changes: 10 additions & 8 deletions core/src/layers/await_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use futures::FutureExt;
use crate::raw::*;
use crate::*;

/// Add a Instrument await-tree for actor-based applications to the underlying services.
/// Add an Instrument await-tree for actor-based applications to the underlying services.
///
/// # AwaitTree
///
Expand All @@ -33,16 +33,18 @@ use crate::*;
/// # Examples
///
/// ```no_run
/// use anyhow::Result;
/// use opendal::layers::AwaitTreeLayer;
/// use opendal::services;
/// use opendal::Operator;
/// use opendal::Scheme;
/// # use opendal::layers::AwaitTreeLayer;
/// # use opendal::services;
/// # use opendal::Operator;
/// # use opendal::Result;
/// # use opendal::Scheme;
///
/// let _ = Operator::new(services::Memory::default())
/// .expect("must init")
/// # fn main() -> Result<()> {
/// let _ = Operator::new(services::Memory::default())?
/// .layer(AwaitTreeLayer::new())
/// .finish();
/// Ok(())
/// # }
/// ```
#[derive(Clone, Default)]
pub struct AwaitTreeLayer {}
Expand Down
39 changes: 19 additions & 20 deletions core/src/layers/blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ use crate::*;
/// BlockingLayer will use current async context's runtime to handle the async calls.
///
/// ```rust,no_run
/// # use anyhow::Result;
/// use opendal::layers::BlockingLayer;
/// use opendal::services::S3;
/// use opendal::BlockingOperator;
/// use opendal::Operator;
/// # use opendal::layers::BlockingLayer;
/// # use opendal::services;
/// # use opendal::BlockingOperator;
/// # use opendal::Operator;
/// # use opendal::Result;
///
/// #[tokio::main]
/// async fn main() -> Result<()> {
/// // Create fs backend builder.
/// let mut builder = S3::default().bucket("test").region("us-east-1");
/// let mut builder = services::S3::default().bucket("test").region("us-east-1");
///
/// // Build an `BlockingOperator` with blocking layer to start operating the storage.
/// let _: BlockingOperator = Operator::new(builder)?
Expand All @@ -63,11 +63,11 @@ use crate::*;
/// This often happens in the case that async function calls blocking function.
///
/// ```rust,no_run
/// use opendal::layers::BlockingLayer;
/// use opendal::services::S3;
/// use opendal::BlockingOperator;
/// use opendal::Operator;
/// use opendal::Result;
/// # use opendal::layers::BlockingLayer;
/// # use opendal::services;
/// # use opendal::BlockingOperator;
/// # use opendal::Operator;
/// # use opendal::Result;
///
/// #[tokio::main]
/// async fn main() -> Result<()> {
Expand All @@ -77,7 +77,7 @@ use crate::*;
///
/// fn blocking_fn() -> Result<BlockingOperator> {
/// // Create fs backend builder.
/// let mut builder = S3::default().bucket("test").region("us-east-1");
/// let mut builder = services::S3::default().bucket("test").region("us-east-1");
///
/// let handle = tokio::runtime::Handle::try_current().unwrap();
/// let _guard = handle.enter();
Expand All @@ -98,24 +98,23 @@ use crate::*;
/// > runtime on demand.
///
/// ```rust,no_run
/// use once_cell::sync::Lazy;
/// use opendal::layers::BlockingLayer;
/// use opendal::services::S3;
/// use opendal::BlockingOperator;
/// use opendal::Operator;
/// use opendal::Result;
/// # use once_cell::sync::Lazy;
/// # use opendal::layers::BlockingLayer;
/// # use opendal::services;
/// # use opendal::BlockingOperator;
/// # use opendal::Operator;
/// # use opendal::Result;
///
/// static RUNTIME: Lazy<tokio::runtime::Runtime> = Lazy::new(|| {
/// tokio::runtime::Builder::new_multi_thread()
/// .enable_all()
/// .build()
/// .unwrap()
/// });
/// ///
///
/// fn main() -> Result<()> {
/// // Create fs backend builder.
/// let mut builder = S3::default().bucket("test").region("us-east-1");
/// let mut builder = services::S3::default().bucket("test").region("us-east-1");
///
/// // Fetch the `EnterGuard` from global runtime.
/// let _guard = RUNTIME.enter();
Expand Down
16 changes: 9 additions & 7 deletions core/src/layers/chaos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,18 @@ use crate::*;
/// # Examples
///
/// ```no_run
/// use anyhow::Result;
/// use opendal::layers::ChaosLayer;
/// use opendal::services;
/// use opendal::Operator;
/// use opendal::Scheme;
/// # use opendal::layers::ChaosLayer;
/// # use opendal::services;
/// # use opendal::Operator;
/// # use opendal::Result;
/// # use opendal::Scheme;
///
/// let _ = Operator::new(services::Memory::default())
/// .expect("must init")
/// # fn main() -> Result<()> {
/// let _ = Operator::new(services::Memory::default())?
/// .layer(ChaosLayer::new(0.1))
/// .finish();
/// Ok(())
/// # }
/// ```
#[derive(Debug, Clone)]
pub struct ChaosLayer {
Expand Down
Loading
Loading