Skip to content

Commit

Permalink
fix: FsBuilder can't be used with empty root anymore (#1293)
Browse files Browse the repository at this point in the history
* fix: FsBuilder can't be used with empty root anymore

Signed-off-by: Xuanwo <github@xuanwo.io>

* Fix fut been called after returning error

Signed-off-by: Xuanwo <github@xuanwo.io>

---------

Signed-off-by: Xuanwo <github@xuanwo.io>
  • Loading branch information
Xuanwo authored Feb 7, 2023
1 parent 85b3894 commit d2a52a3
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 14 deletions.
4 changes: 3 additions & 1 deletion bindings/nodejs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ use opendal::Operator;

#[napi]
pub fn debug() -> String {
let op = Operator::from_env::<services::Fs>().unwrap().finish();
let op = Operator::create(services::Memory::default())
.unwrap()
.finish();
format!("{:?}", op.metadata())
}
4 changes: 3 additions & 1 deletion bindings/object_store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,9 @@ mod tests {

#[tokio::test]
async fn test_basic() {
let op = Operator::from_env::<services::Memory>().unwrap().finish();
let op = Operator::create(services::Memory::default())
.unwrap()
.finish();
let object_store: Arc<dyn ObjectStore> = Arc::new(OpendalStore::new(op));

// Retrieve a specific file
Expand Down
4 changes: 3 additions & 1 deletion bindings/python/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ use pyo3::prelude::*;

#[pyfunction]
fn debug() -> PyResult<String> {
let op = Operator::from_env::<services::Fs>().unwrap().finish();
let op = Operator::create(services::Memory::default())
.unwrap()
.finish();
Ok(format!("{:?}", op.metadata()))
}

Expand Down
2 changes: 1 addition & 1 deletion src/layers/chaos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ use crate::*;
/// use opendal::Operator;
/// use opendal::Scheme;
///
/// let _ = Operator::from_env::<services::Fs>()
/// let _ = Operator::create(services::Memory::default())
/// .expect("must init")
/// .layer(ChaosLayer::new(0.1))
/// .finish();
Expand Down
2 changes: 1 addition & 1 deletion src/layers/concurrent_limit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use crate::*;
/// use opendal::Operator;
/// use opendal::Scheme;
///
/// let _ = Operator::from_env::<services::Fs>()
/// let _ = Operator::create(services::Memory::default())
/// .expect("must init")
/// .layer(ConcurrentLimitLayer::new(1024))
/// .finish();
Expand Down
2 changes: 1 addition & 1 deletion src/layers/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ use crate::*;
/// use opendal::Operator;
/// use opendal::Scheme;
///
/// let _ = Operator::from_env::<services::Fs>()
/// let _ = Operator::create(services::Memory::default())
/// .expect("must init")
/// .layer(LoggingLayer::default())
/// .finish();
Expand Down
2 changes: 1 addition & 1 deletion src/layers/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static LABEL_ERROR: &str = "error";
/// use opendal::services;
/// use opendal::Operator;
///
/// let _ = Operator::from_env::<services::Fs>()
/// let _ = Operator::create(services::Memory::default())
/// .expect("must init")
/// .layer(MetricsLayer)
/// .finish();
Expand Down
4 changes: 2 additions & 2 deletions src/layers/retry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use crate::*;
/// use opendal::Operator;
/// use opendal::Scheme;
///
/// let _ = Operator::from_env::<services::Fs>()
/// let _ = Operator::create(services::Memory::default())
/// .expect("must init")
/// .layer(RetryLayer::new(ExponentialBackoff::default()))
/// .finish();
Expand All @@ -64,7 +64,7 @@ where
/// use opendal::Operator;
/// use opendal::Scheme;
///
/// let _ = Operator::from_env::<services::Fs>()
/// let _ = Operator::create(services::Memory::default())
/// .expect("must init")
/// .layer(RetryLayer::new(ExponentialBackoff::default()));
/// ```
Expand Down
2 changes: 1 addition & 1 deletion src/layers/tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use crate::*;
/// use opendal::services;
/// use opendal::Operator;
///
/// let _ = Operator::from_env::<services::Fs>()
/// let _ = Operator::create(services::Memory::default())
/// .expect("must init")
/// .layer(TracingLayer)
/// .finish();
Expand Down
14 changes: 12 additions & 2 deletions src/raw/io/output/into_reader/by_range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,12 @@ impl<A: Accessor> output::Read for RangeReader<A> {
// TODO
//
// we can use RpRead returned here to correct size.
let (_, r) = ready!(Pin::new(fut).poll(cx))?;
let (_, r) = ready!(Pin::new(fut).poll(cx)).map_err(|err| {
// If read future retruns an error, we should reset
// state to Idle so that we can retry it.
self.state = State::Idle;
err
})?;

self.state = State::Reading(r);
self.poll_read(cx, buf)
Expand Down Expand Up @@ -230,7 +235,12 @@ impl<A: Accessor> output::Read for RangeReader<A> {
// TODO
//
// we can use RpRead returned here to correct size.
let (_, r) = ready!(Pin::new(fut).poll(cx))?;
let (_, r) = ready!(Pin::new(fut).poll(cx)).map_err(|err| {
// If read future retruns an error, we should reset
// state to Idle so that we can retry it.
self.state = State::Idle;
err
})?;

self.state = State::Reading(r);
self.poll_next(cx)
Expand Down
4 changes: 2 additions & 2 deletions src/raw/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ mod tests {
use futures::lock::Mutex;

use super::*;
use crate::services::Fs;
use crate::services::Memory;

#[derive(Debug)]
struct Test<A: Accessor> {
Expand Down Expand Up @@ -353,7 +353,7 @@ mod tests {
deleted: Arc::new(Mutex::new(false)),
};

let op = Operator::create(Fs::default())
let op = Operator::create(Memory::default())
.unwrap()
.layer(&test)
.finish();
Expand Down

2 comments on commit d2a52a3

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for opendal ready!

✅ Preview
https://opendal-rgbpqs6ac-databend.vercel.app

Built with commit d2a52a3.
This pull request is being automatically deployed with vercel-action

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Rust Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: d2a52a3 Previous: 85b3894 Ratio
service_fs_read_parallel/2x256 KiB 291659 ns/iter (± 23708) 141467 ns/iter (± 10063) 2.06
service_fs_read_parallel/4x4.00 MiB 8096800 ns/iter (± 484985) 3701168 ns/iter (± 542419) 2.19
service_memory_read_full/256 KiB 30721 ns/iter (± 1371) 13290 ns/iter (± 27) 2.31
service_memory_read_full/16.0 MiB 4057997 ns/iter (± 200084) 1798309 ns/iter (± 483375) 2.26
service_memory_read_parallel/1x4.00 MiB 4837835 ns/iter (± 266000) 2360548 ns/iter (± 308337) 2.05
service_memory_read_parallel/2x4.00 MiB 10038793 ns/iter (± 750283) 4390391 ns/iter (± 46202) 2.29
service_memory_read_parallel/4x4.00 MiB 21504304 ns/iter (± 1497052) 9183153 ns/iter (± 3118995) 2.34
service_memory_read_parallel/8x4.00 MiB 40115410 ns/iter (± 3532132) 18352890 ns/iter (± 2360346) 2.19
service_memory_read_parallel/16x4.00 MiB 76890807 ns/iter (± 5466893) 36325044 ns/iter (± 3199118) 2.12
service_fs_write_once/4.00 KiB 556004 ns/iter (± 136955) 236255 ns/iter (± 149767) 2.35

This comment was automatically generated by workflow using github-action-benchmark.

CC: @Xuanwo

Please sign in to comment.