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

Get Request Precondition Support #2241

Closed
tustvold opened this issue Jul 30, 2022 · 4 comments · Fixed by #4212
Closed

Get Request Precondition Support #2241

tustvold opened this issue Jul 30, 2022 · 4 comments · Fixed by #4212
Assignees
Labels
enhancement Any new improvement worthy of a entry in the changelog help wanted object-store Object Store Interface

Comments

@tustvold
Copy link
Contributor

tustvold commented Jul 30, 2022

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

There are 4 broadly supported request preconditions:

  • If-Match
  • If-None-Match
  • If-Modified-Since
  • If-Unmodified-Since

https://cloud.google.com/storage/docs/request-preconditions
https://docs.microsoft.com/en-us/rest/api/storageservices/specifying-conditional-headers-for-blob-service-operations
https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html#API_GetObject_RequestSyntax

Describe the solution you'd like

I would like to propose adding

#[derive(Debug, Default)]
struct GetOptions {
    pub if_match: Option<String>,
    pub if_none_match: Option<String>,
    pub if_modified_since: Option<DateTime<Utc>>,
    pub if_unmodified_since: Option<DateTime<Utc>>,
    pub range: Option<usize>
}

pub trait ObjectStore {
     async fn get_opts(&self, location: &Path, options: GetOptions) -> Result<GetResult>
     ...
}

pub enum Error {
    #[snafu(display("Precondition failed: {}", source))]
    Precondition {
        source: Box<dyn std::error::Error + Send + Sync + 'static>,
    }

    #[snafu(display("Not modified: {}", source))]
    NotModified {
        source: Box<dyn std::error::Error + Send + Sync + 'static>,
    }
}

Describe alternatives you've considered

We could not add support for this

Additional context

#2230
#2240

@tustvold tustvold added enhancement Any new improvement worthy of a entry in the changelog object-store Object Store Interface labels Jul 30, 2022
@crepererum
Copy link
Contributor

How do you model stores that don't support these checks? Do they just return "unsupported" errors?

@tustvold
Copy link
Contributor Author

tustvold commented Aug 1, 2022

All stores support these for get requests.

@crepererum
Copy link
Contributor

All stores support these for get requests.

I think this crate also provides some extendable interface, i.e. users can implement their own stores and use for example etcd as a storage backend. But I suppose every store could implement this check client-side if the "other end" doesn't support it, so this is OK then.

@tustvold
Copy link
Contributor Author

tustvold commented Aug 1, 2022

Yeah, I would expect such stores to return Error::NotSupported if the feature cannot be supported, and Error::NotImplemented if it simply has not been implemented

@tustvold tustvold self-assigned this May 11, 2023
tustvold added a commit to tustvold/arrow-rs that referenced this issue May 12, 2023
tustvold added a commit to tustvold/arrow-rs that referenced this issue May 12, 2023
tustvold added a commit that referenced this issue May 15, 2023
* Add ObjectStore::get_opts (#2241)

* Cleanup error handling

* Review feedback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Any new improvement worthy of a entry in the changelog help wanted object-store Object Store Interface
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants