Skip to content

refactor: Remove deprecated APIs #582

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

Merged
merged 2 commits into from
Aug 28, 2022
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
2 changes: 1 addition & 1 deletion .github/workflows/service_test_azblob.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:

- name: Test
shell: bash
run: cargo test azblob --features compress,retry -- --nocapture
run: cargo test azblob --features compress,layers-retry -- --nocapture
env:
RUST_BACKTRACE: full
RUST_LOG: debug
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/service_test_fs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- uses: actions/checkout@v3
- name: Test
shell: bash
run: cargo test fs --features compress,retry -- --nocapture
run: cargo test fs --features compress,layers-retry -- --nocapture
env:
RUST_BACKTRACE: full
RUST_LOG: debug
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/service_test_gcs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- uses: actions/checkout@v3
- name: Test
shell: bash
run: cargo test gcs --features compress,retry -- --nocapture
run: cargo test gcs --features compress,layers-retry -- --nocapture
env:
RUST_BACKTRACE: full
RUST_LOG: debug
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/service_test_hdfs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:

- name: Test
shell: bash
run: cargo test hdfs --features compress,retry,services-hdfs -- --nocapture
run: cargo test hdfs --features compress,layers-retry,services-hdfs -- --nocapture
env:
RUST_BACKTRACE: full
RUST_LOG: debug
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/service_test_http.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

- name: Test
shell: bash
run: cargo test http --features compress,retry,services-http -- --nocapture
run: cargo test http --features compress,layers-retry,services-http -- --nocapture
env:
RUST_BACKTRACE: full
RUST_LOG: debug
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/service_test_memory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- uses: actions/checkout@v3
- name: Test
shell: bash
run: cargo test memory --features compress,retry -- --nocapture
run: cargo test memory --features compress,layers-retry -- --nocapture
env:
RUST_BACKTRACE: full
RUST_LOG: debug
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/service_test_obs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- uses: actions/checkout@v3
- name: Test
shell: bash
run: cargo test obs --features compress,retry -- --nocapture
run: cargo test obs --features compress,layers-retry -- --nocapture
env:
RUST_BACKTRACE: full
RUST_LOG: debug
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/service_test_s3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- uses: actions/checkout@v3
- name: Test
shell: bash
run: cargo test s3 --features compress,retry -- --nocapture
run: cargo test s3 --features compress,layers-retry -- --nocapture
env:
RUST_BACKTRACE: full
RUST_LOG: debug
Expand All @@ -38,7 +38,7 @@ jobs:
- uses: actions/checkout@v3
- name: Test
shell: bash
run: cargo test s3 --features compress,retry -- --nocapture
run: cargo test s3 --features compress,layers-retry -- --nocapture
env:
RUST_BACKTRACE: full
RUST_LOG: debug
Expand All @@ -56,7 +56,7 @@ jobs:
- uses: actions/checkout@v3
- name: Test
shell: bash
run: cargo test s3 --features compress,retry -- --nocapture
run: cargo test s3 --features compress,layers-retry -- --nocapture
env:
RUST_BACKTRACE: full
RUST_LOG: debug
Expand Down Expand Up @@ -94,7 +94,7 @@ jobs:

- name: Test
shell: bash
run: cargo test s3 --features compress,retry -- --nocapture
run: cargo test s3 --features compress,layers-retry -- --nocapture
env:
RUST_BACKTRACE: full
RUST_LOG: debug
Expand Down Expand Up @@ -129,7 +129,7 @@ jobs:

- name: Test
shell: bash
run: cargo test s3 --features compress,retry -- --nocapture
run: cargo test s3 --features compress,layers-retry -- --nocapture
env:
RUST_BACKTRACE: full
RUST_LOG: debug
Expand Down
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ layers-metrics = ["metrics"]
layers-retry = ["backon"]
# Enable layers tracing support.
layers-tracing = ["tracing"]
# DEPRACATED: use layers-retry instead
retry = ["layers-retry"]

# Enable services hdfs support
services-hdfs = ["hdrs"]
Expand Down
33 changes: 0 additions & 33 deletions src/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,39 +224,6 @@ impl Operator {
}
}

/// Configure backoff for operators
///
/// This function only provided if feature `retry` is enabled.
///
/// # Examples
///
/// ```
/// # use std::sync::Arc;
/// # use anyhow::Result;
/// # use opendal::services::fs;
/// # use opendal::services::fs::Builder;
/// use backon::ExponentialBackoff;
/// use opendal::Operator;
/// use opendal::Scheme;
///
/// # #[tokio::main]
/// # async fn main() -> Result<()> {
/// let op = Operator::from_env(Scheme::Fs)?.with_backoff(ExponentialBackoff::default());
/// // All operations will be retried if the error is retryable
/// let _ = op.object("test_file").read();
/// # Ok(())
/// # }
/// ```
#[cfg(feature = "layers-retry")]
#[must_use]
#[deprecated = "Use `Operator::layer` and `RetryLayer` directly"]
pub fn with_backoff(
self,
backoff: impl backon::Backoff + Send + Sync + std::fmt::Debug + 'static,
) -> Self {
self.layer(crate::layers::RetryLayer::new(backoff))
}

fn inner(&self) -> Arc<dyn Accessor> {
self.accessor.clone()
}
Expand Down
12 changes: 0 additions & 12 deletions src/services/azblob/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,6 @@ impl Builder {
_account_name: mem::take(&mut self.account_name).unwrap_or_default(),
})
}

/// Consume builder to build an azblob backend.
#[deprecated = "Use Builder::build() instead"]
pub async fn finish(&mut self) -> Result<Arc<dyn Accessor>> {
Ok(Arc::new(self.build()?))
}
}

/// Backend for azblob services.
Expand All @@ -243,12 +237,6 @@ pub struct Backend {
}

impl Backend {
/// Create a builder for azblob.
#[deprecated = "Use Builder::default() instead"]
pub fn build() -> Builder {
Builder::default()
}

pub(crate) fn from_iter(it: impl Iterator<Item = (String, String)>) -> Result<Self> {
let mut builder = Builder::default();

Expand Down
46 changes: 0 additions & 46 deletions src/services/fs/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,46 +103,6 @@ impl Builder {
info!("backend build finished: {:?}", &self);
Ok(Backend { root })
}

/// Consume current builder to build an fs backend.
#[deprecated = "Use Builder::build() instead"]
pub async fn finish(&mut self) -> Result<Arc<dyn Accessor>> {
info!("backend build started: {:?}", &self);

// Make `/` as the default of root.
let root = match &self.root {
None => "/".to_string(),
Some(v) => {
debug_assert!(!v.is_empty());

let mut v = v.clone();

if !v.starts_with('/') {
return Err(other(BackendError::new(
HashMap::from([("root".to_string(), v.clone())]),
anyhow!("Root must start with /"),
)));
}
if !v.ends_with('/') {
v.push('/');
}

v
}
};

// If root dir is not exist, we must create it.
if let Err(e) = fs::metadata(&root).await {
if e.kind() == std::io::ErrorKind::NotFound {
fs::create_dir_all(&root)
.await
.map_err(|e| other(anyhow!("create dir in {} error {:?}", &root, e)))?;
}
}

info!("backend build finished: {:?}", &self);
Ok(Arc::new(Backend { root }))
}
}

/// Backend is used to serve `Accessor` support for posix alike fs.
Expand All @@ -152,12 +112,6 @@ pub struct Backend {
}

impl Backend {
/// Create a builder.
#[deprecated = "Use Builder::default() instead"]
pub fn build() -> Builder {
Builder::default()
}

pub(crate) fn from_iter(it: impl Iterator<Item = (String, String)>) -> Result<Self> {
let mut builder = Builder::default();

Expand Down
12 changes: 0 additions & 12 deletions src/services/hdfs/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,6 @@ impl Builder {
client: Arc::new(client),
})
}

/// Finish the building and create hdfs backend.
#[deprecated = "Use Builder::build() instead"]
pub async fn finish(&mut self) -> Result<Arc<dyn Accessor>> {
Ok(Arc::new(self.build()?))
}
}

/// Backend for hdfs services.
Expand All @@ -172,12 +166,6 @@ unsafe impl Send for Backend {}
unsafe impl Sync for Backend {}

impl Backend {
/// Create a builder.
#[deprecated = "Use Builder::default() instead"]
pub fn build() -> Builder {
Builder::default()
}

pub(crate) fn from_iter(it: impl Iterator<Item = (String, String)>) -> Result<Self> {
let mut builder = Builder::default();

Expand Down
12 changes: 0 additions & 12 deletions src/services/http/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,6 @@ impl Builder {
index: Arc::new(Mutex::new(mem::take(&mut self.index))),
})
}

/// Build a HTTP backend.
#[deprecated = "Use Builder::build() instead"]
pub async fn finish(&mut self) -> Result<Arc<dyn Accessor>> {
Ok(Arc::new(self.build()?))
}
}

/// Backend is used to serve `Accessor` support for http.
Expand Down Expand Up @@ -238,12 +232,6 @@ impl Debug for Backend {
}

impl Backend {
/// Create a new builder for s3.
#[deprecated = "Use Builder::default() instead"]
pub fn build() -> Builder {
Builder::default()
}

pub(crate) fn from_iter(it: impl Iterator<Item = (String, String)>) -> Result<Self> {
let mut builder = Builder::default();

Expand Down
14 changes: 0 additions & 14 deletions src/services/memory/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,6 @@ impl Builder {
inner: Arc::new(Mutex::new(HashMap::default())),
})
}

/// Consume builder to build a memory backend.
#[deprecated = "Use Builder::build() instead"]
pub async fn finish(&mut self) -> Result<Arc<dyn Accessor>> {
Ok(Arc::new(self.build()?))
}
}

/// Backend is used to serve `Accessor` support in memory.
Expand All @@ -74,14 +68,6 @@ pub struct Backend {
inner: Arc<Mutex<HashMap<String, Bytes>>>,
}

impl Backend {
/// Create a builder.
#[deprecated = "Use Builder::default() instead"]
pub fn build() -> Builder {
Builder::default()
}
}

#[async_trait]
impl Accessor for Backend {
fn metadata(&self) -> AccessorMetadata {
Expand Down
Loading