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

docs(core): add the description of version parameter for operator #5144

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
119 changes: 119 additions & 0 deletions core/src/types/operator/operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,25 @@ impl Operator {
/// # }
/// ```
///
/// ## `version`
///
/// Set `version` for this `stat` request.
///
/// This feature can be used to retrieve the file metadata that matches a specified version.
Copy link
Member

Choose a reason for hiding this comment

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

Hi, the way about discussing version is a bit confusing to me. Unlike ETag, Version is not used for matching. Instead, we request the specified version directly. We will return NotFound if the requested version does not exist for the given path.

Copy link
Contributor Author

@meteorgan meteorgan Oct 2, 2024

Choose a reason for hiding this comment

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

how about

    /// This feature can be used to retrieve the path's metadata of a specific version.
    ///
    /// If the version doesn't exist, an error with kind [`ErrorKind::NotFound`] will be returned.

///
/// If file exists, but the version doesn't match, an error with kind [`ErrorKind::NotFound`]
Copy link
Member

Choose a reason for hiding this comment

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

the same.

/// will be returned.
///
/// ```no_run
/// # use opendal::Result;
/// # use opendal::Operator;
///
/// # async fn test(op: Operator, version: &str) -> Result<()> {
/// let mut metadata = op.stat_with("path/to/file").version(version).await?;
/// # Ok(())
/// # }
/// ```
///
/// # Examples
///
/// ## Get metadata while `ETag` matches
Expand Down Expand Up @@ -531,6 +550,26 @@ impl Operator {
/// # }
/// ```
///
/// ## `version`
///
/// Set `version` for this `read` request.
///
/// By default, OpenDAL reads a file using the current version. By setting the `version`, OpenDAL will read
/// the file with the specified version.
///
/// If the file exists, but the version doesn't match, an error with kind [`ErrorKind::NotFound`]
Copy link
Member

Choose a reason for hiding this comment

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

the same.

/// will be returned.
///
/// ```no_run
/// # use opendal::Result;
/// # use opendal::Operator;
///
/// # async fn test(op: Operator, version: &str) -> Result<()> {
/// let mut bs = op.read_with("path/to/file").version(version).await?;
/// # Ok(())
/// # }
/// ```
///
/// # Examples
///
/// Read the whole path into a bytes.
Expand Down Expand Up @@ -650,6 +689,26 @@ impl Operator {
/// # }
/// ```
///
/// ## `version`
///
/// Set `version` for this `reader`.
///
/// By default, OpenDAL reads a file using the current version. By setting the `version`, OpenDAL will read
/// the file with the specified version.
///
/// If the file exists, but the version doesn't match, an error with kind [`ErrorKind::NotFound`]
Copy link
Member

Choose a reason for hiding this comment

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

the same.

/// will be returned.
///
/// ```no_run
/// # use opendal::Result;
/// # use opendal::Operator;
///
/// # async fn test(op: Operator, version: &str) -> Result<()> {
/// let mut bs = op.reader_with("path/to/file").version(version).await?;
/// # Ok(())
/// # }
/// ```
///
/// # Examples
///
/// ```no_run
Expand Down Expand Up @@ -1279,6 +1338,30 @@ impl Operator {
///
/// - Deleting a file that does not exist won't return errors.
///
/// # Options
///
/// ## `version`
///
/// Set `version` for this `delete` request.
///
/// If `versioning` is not enabled, a `delete` request will permanently remove the file.
///
/// when `versioning` is enabled, a simple `delete` request won't permanently remove the file,
/// it can still be accessed using its version.
/// By setting the `version`, OpenDAL will permanently remove the file with the specified version.
Comment on lines +1347 to +1351
Copy link
Member

Choose a reason for hiding this comment

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

Hi, it's better not to discuss "permanently delete" here. This behavior is determined by the service itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

how about

    /// Set `version` for this `delete` request.
    ///
    /// remove a specific version of the given path.
    ///
    /// If the version doesn't exist, OpenDAL will not return errors.

///
/// If the file exists, but the version doesn't match, OpenDAL will not return errors.
///
/// ```no_run
/// # use opendal::Result;
/// # use opendal::Operator;
///
/// # async fn test(op: Operator, version: &str) -> Result<()> {
/// op.delete_with("path/to/file").version(version).await?;
/// # Ok(())
/// # }
///```
///
/// # Examples
///
/// ```
Expand Down Expand Up @@ -1636,6 +1719,24 @@ impl Operator {
/// # }
/// ```
///
/// ## `version`
///
/// Specify whether to list all object versions or not
Copy link
Member

Choose a reason for hiding this comment

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

The behavior we implemented is "list files along with their versions." Please always remember that OpenDAL's vision is "accessing data freely." We should do our best to distinguish OpenDAL's API from the underlying storage services' implementation details.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

how about

    /// ## `version`
    ///
    /// Specify whether to list files along with all their versions or not
    ///
    /// if `version` is not enabled, or is set to false, only the current files will be returned.
    ///
    /// if `version` is set to true, all the file versions will be returned.

///
/// if `version` is not set, or is set to false, only the active files with the current version will be returned.
///
/// when `version` is set to true and the backend service has `versioning` enabled, all object versions will be returned.
/// if `versioning` is not enabled, an error with kind [`ErrorKind::Unsupported`] will be returned.
///
/// ```no_run
/// # use opendal::Result;
/// # use opendal::Operator;
/// # async fn test(op: Operator) -> Result<()> {
/// let mut entries = op.list_with("path/to/dir/").version(true).await?;
/// # Ok(())
/// # }
/// ```
///
/// # Examples
///
/// ## List all entries recursively
Expand Down Expand Up @@ -1840,6 +1941,24 @@ impl Operator {
/// # }
/// ```
///
/// ## `version`
///
/// Specify whether to list all object versions or not
///
/// if `version` is not set, or is set to false, only the active files with the current version will be returned.
Copy link
Member

Choose a reason for hiding this comment

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

if version is not set, or is set to false,

If version is not enabled?

///
/// when `version` is set to true and the backend service has `versioning` enabled, all object versions will be returned.
Copy link
Member

Choose a reason for hiding this comment

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

As previously discussed, please refrain from disclosing details about backend services.

/// if `versioning` is not enabled, an error with kind [`ErrorKind::Unsupported`] will be returned.
Copy link
Member

Choose a reason for hiding this comment

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

I will discuss this at #5145. Generally, I don't want to declare it as part of our public API (or expected behavior).

///
/// ```no_run
/// # use opendal::Result;
/// # use opendal::Operator;
/// # async fn test(op: Operator) -> Result<()> {
/// let mut entries = op.lister_with("path/to/dir/").version(true).await?;
/// # Ok(())
/// # }
/// ```
///
/// # Examples
///
/// ## List all files recursively
Expand Down
Loading