Skip to content

Move get blob to pageable #850

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 12 commits into from
Jun 27, 2022
Merged

Conversation

bmc-msft
Copy link
Contributor

This PR does two main things:

  1. Extends the Continuation model to support String (as used by most of the SDKs) and Range as used by get_blob.
  2. Moves the get_blob to not require the user to specify a chunk size, but by default will download in 1MB chunks. I think this simplifies the interface while also not shooting the user in the foot by default downloading the entire blob into memory.

@bmc-msft
Copy link
Contributor Author

Note, the Continuation code for all of the generated crates will need to be updated, though the update is minimal. I will do that tomorrow.

Comment on lines 86 to +87
pub trait Continuable {
fn continuation(&self) -> Option<String>;
fn continuation(&self) -> Option<Continuation>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do any endpoints allow for multiple types of continuations? It seems like right now the Continuation header with a continuation token is the happy path and we're using panics to ensure that we don't use a Continuation::Range when we don't meant time.

What if we were to trying the following;

pub trait Continuable {
   type Continuation: crate::AsHeaders;
    fn continuation(&self) -> Option<Self::Continuation>;
}

The make_request function then becomes impl Fn(Option<T::Continuation>) -> F + Clone + 'static + Send

This would make the system more robust. Every continuable response just needs to provide the headers it uses for specifying how it continues.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Examples of different Continuation methods:

  • BlobClient.get uses Range header
  • Cosmos's list_attachments uses Continuation header
  • ContainerClient.list_blobs uses marker URI parameter
  • datalake's file_systems_list uses maker URI parameter. Note, this one also accepts next_marker from the builder, which probably shouldn't be available.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok so we couldn't do type Continuation: crate::AsHeaders but we could do type Continuation: crate::AsContinuation and implement AsContinuation for all the appropriate types.

@bmc-msft bmc-msft requested a review from rylev June 24, 2022 15:41
@@ -173,6 +129,62 @@ impl Continuable for GetBlobResponse {
}
}

// caclculate the first Range for use at the beginning of the Pageable.
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI: even though these are internal APIs they should still be /// doc comments so that they show up in rust-analyzer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants