Simplify remote store load_bytes API - #18034
Merged
Merged
Conversation
This reverts commit 42be198.
stuhood
approved these changes
Jan 18, 2023
stuhood
left a comment
Member
There was a problem hiding this comment.
Thanks, looks good. My only minor concern is that to resolve #17065, we will need to change this API again to return a stream, and it seems like this is probably as good a time as any to do that? But happy for this just to be a cleanup instead.
stuhood
enabled auto-merge (squash)
January 18, 2023 18:35
Contributor
Author
|
Ah, yeah, fair enough. I'll do that as follow up (no guarantee when, though!). |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is an no-functionality-change refactoring of
store::remote::ByteStore::load_bytes_withthat's arguably cleaner and also step towards #11149. In particular:load_bytes(...) -> Result<Option<Bytes>, String>load_bytesmethod itself, which is both easier to use, and keeps implementation details like gRPC (previously exposed as theByteStoreError::Grpc/tonic::Statuserror variant) entirely contained tostore::remote::ByteStoreByteStoreErrorenum can thus become private, because it's an implementation detail ofstore::remote::ByteStore, no longer exposed in the public APIStep 1 resolves (and removes) a TODO comment. That TODO references #17065, but this patch doesn't fix that issue.
(NB. a significant fraction of the diff is just reindenting after change the nesting level.)
Background: this gets closer to #11149 by making it easier to factor out a "provider" trait:
store::remote::ByteStorestores anArc<dyn ByteStoreProvider>, where theByteStoreProvidertrait might be something like the following, implemented for the REAPI gRPC services and also for HTTP backends (as sketched in #17840):This trait needs to avoid generic methods (like the old
load_bytes_with), so that it can be used as adyntrait object.