-
Notifications
You must be signed in to change notification settings - Fork 195
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
Stream implementation (wrapper) for PaginationStream #3299
Conversation
for a number of reasons, I think that is the best you can do. Since you need to box the future, you then can't know for sure that the stream is alive long enough. Luckily, there is a better way! We can expose I think there are a couple of remaining items we should do:
s3.list_buckets().into_paginator().send().as_stream_03x().map(...) // and other stream trait useful functions
|
Thanks! Some questions:
|
|
Does it look good now? |
Btw, if tokio-stream re-exports futures::Stream and we don't even use StreamExt for anything, then that means we simply bring in more dependencies than necessary. Shouldn't we just use |
Nice, that would be useful to have! In the meantime we've done something pretty similar, which seems to work for us (plus an extension trait to add a broken codepub struct PaginationStreamAdapter<T>(PaginationStream<T>);
impl<T> futures::stream::Stream for PaginationStreamAdapter<T> {
type Item = T;
fn poll_next(
mut self: Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Option<Self::Item>> {
let fut = self.0.next();
pin_mut!(fut);
fut.poll(cx)
}
} |
@abusch I'm not sure but isn't it wrong to call |
FYI I'm pretty sure that implementation is wrong — It may work due to a
coincidence of how our demand driven paginator works but I wouldn't
recommend relying on that
…On Thu, Dec 14, 2023, 2:35 AM Antoine Büsch ***@***.***> wrote:
Nice, that would be useful to have! In the meantime we've done something
pretty similar, which seems to work for us (plus an extension trait to add
a .into_stream() method):
pub struct PaginationStreamAdapter<T>(PaginationStream<T>);
impl<T> futures::stream::Stream for PaginationStreamAdapter<T> {
type Item = T;
fn poll_next(
mut self: Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Option<Self::Item>> {
let fut = self.0.next();
pin_mut!(fut);
fut.poll(cx)
}}
—
Reply to this email directly, view it on GitHub
<#3299 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADYKZ37BBIWTBU75TEYIU3YJKT3ZAVCNFSM6AAAAABAMQI67CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNJVGMZDINRSHA>
.
You are receiving this because your review was requested.Message ID:
***@***.***>
|
Hmm, yeah, you might be right 😓 |
yeah that's fair. In that case, I think we should use We should probably include a comment suggesting that tokio_stream is where most of the useful utilities live, though |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is looking great! just a couple of suggestions then we'll get this merged. Thanks for working on this, I think customers are really going to appreciate it.
remove unnecessary trait impl bounds
deea76e
to
11f1e64
Compare
I implemented the suggested changes, and rebased onto latest upstream |
Co-authored-by: Russell Cohen <russell.r.cohen@gmail.com>
Add futures_core::stream to external types
Motivation and Context
awslabs/aws-sdk-rust#995
Description
I tried to implement futures::Stream for a wrapper struct around
PaginationStream
. I am unsure if I did it in the best way. After fighting with the borrow checker for a while I decided to tryArc<Mutex<_>>
- is this the way to go or does there exist a better way?Even then, does the code look correct? I used it in my project and my integration tests do pass but I am not 100% that these tests will catch any error in paginated ListObjectsV2.
I would appreciate any feedback so far.
Testing
In progress while waiting for feedback on code
Checklist
CHANGELOG.next.toml
if I made changes to the smithy-rs codegen or runtime cratesBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.