feat!: use 'static lifetime for delete_stream#524
Conversation
|
The changes are covered by existing tests since |
| /// let client = Arc::clone(&self.client); | ||
| /// locations | ||
| /// .map(move |location| { | ||
| /// let client = Arc::clone(&client); |
| /// following implementation deletes each object with up to 10 concurrent | ||
| /// requests: | ||
| /// | ||
| /// ```ignore |
There was a problem hiding this comment.
Could you please make this an actual example that compiles (so we are sure it won't drift over time)?
Perhaps following the model f the examples below.
We can do this as a follow on PR
| /// than one object per a request. The default implementation will call | ||
| /// the single object delete method for each location, but with up to 10 | ||
| /// concurrent requests. | ||
| /// than one object per a request. Otherwise, the implementation may call |
There was a problem hiding this comment.
We should probably call this out as a behavior change too in the API docs (but I think it is better to avoid implementing concurrent requests by default)
Also I think the documentation to explain how to get the old behavior is good
There was a problem hiding this comment.
Done!
I called out the behavior change in the docs and mentioned that the example can be used to get the previous behavior.
| self.inner.delete(location).await | ||
| } | ||
|
|
||
| fn delete_stream( |
There was a problem hiding this comment.
I wonder if we should add a test for this new implementation, following the other tests at this file
|
Thanks @alamb for the review! I feel I can update the docs and tests in the same PR. I'll work on this today! |
| @@ -873,9 +873,8 @@ pub trait ObjectStore: std::fmt::Display + Send + Sync + Debug + 'static { | |||
| /// Delete all the objects at the specified locations | |||
| /// | |||
| /// When supported, this method will use bulk operations that delete more | |||
There was a problem hiding this comment.
It would be nice as an end user to know which backends (at least of those provided by object-store) support bulk delete
There was a problem hiding this comment.
| /// that deletes each object with up to 10 concurrent requests. This default | ||
| /// behavior has been removed, and each implementation must now provide its | ||
| /// own `delete_stream` implementation explicitly. The following example | ||
| /// shows how to implement `delete_stream` to get the previous default |
|
Thanks for the review @kylebarron |
Which issue does this PR close?
Closes #518.
Rationale for this change
The current
delete_streammethod looks like this:This PR changes the
delete_streammethod to work with'staticlifetime. The reason for this change was discussed in the corresponding issue #518.What changes are included in this PR?
As I work on this PR, the changes appeared to be more complex than thought. The challenge is that
delete_streamhas a default implementation that takes&self, so the returned stream cannot be'static. I've considered the following options for this challenge.Option 1: Only change the input stream to be
'staticwithout changing the lifetime of the output stream. The method would look like this:Or equivalently (with unnecessary lifetime elided):
This would result in minimum code change but the result is still not very elegant, since we're not fully migrating to
BoxStream<'static, _>.Option 2: Change both the input and output stream to be
'staticand requires the implementation to definedelete_streamexplicitly (i.e. no more default implementation). The method would look like this:I ended up choosing Option 2 for this PR. This is more work but gives a clean end result so that all
ObjectStoremethods now handle input/outputBoxStreamof'staticlifetime.And fortunately, it likely won't be challenging for downstream implementations even if
delete_streamis now required. Most implementations already useArcfor internal states, which can be cheaply cloned and moved into the'staticoutput stream. From the changes I made to variousObjectStoreimplementations in this PR, we can see that the logic is straightforward. And I've documented the pattern inlib.rsfor downstream implementations to follow.Are there any user-facing changes?
This is a breaking change that could be considered for 0.13 (#367).