-
Notifications
You must be signed in to change notification settings - Fork 653
Current 0.3 Sink interface inflicts complexity on implementers #1665
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
Comments
So I think the goal around splitting poll_ready and send is similar to the goal for why we have poll_ready in tower_service::Service. It allows you to send items off task and poll for readiness separately from having to submit an item. I think for your usecase you could just have a sink inbetween that buffers and does the calculations then submits similar to the compat type. |
The counter to that goal, is that there is at least a subset of Sink implementations, where readiness is either (minimally) dependent on the To your last point, yes I agree, my proposed support would also need a |
I've made some progress implementing 0.3 https://github.com/dekellum/tardy-sink/blob/f5afecca4/src/lib.rs#L51 Unfortunately there is still a lot about
So I would appreciate some feedback on this with either of the following goals in a new PR:
|
That's the compatibility layer, we need to map any 0.1
Those bounds can be removed by adding some pin-projection in to the (Whether this should be added to |
That's a relief, thank you. I thought I might be missing something fundamental.
Fair enough. So it does come back to the need for clarification as to the intention/goals of the 0.3 Who might be able to authoritatively answer? |
I managed to implement the pin-projections and removed the https://github.com/dekellum/tardy-sink/blob/master/src/lib.rs |
RFC: Any positive or negative opinion on at least the problem statement of this issue? @cramertj? @taiki-e? @seanmonstar? (Just picking folks I see contributing/commenting frequently on the project, who haven't yet commented. Apologies if this is unwelcome.) If something like |
@dekellum I'm sorry if i may be missing something but at a high level im assuming what you want is something like this? https://github.com/libra/libra/blob/master/network/src/sink/buffered_send.rs |
I haven't commented because I thought others did a fair job.
I read through the original issue, and the replies, and now I don't know what exactly the problem statement is. |
@LucioFranco At a quick glance, your |
@seanmonstar Fair enough, my initial report was less informed/articulate and the thread spends more time on solution implementation details. Reformulated Problem StatementThere is at least a subset of In futures 0.1, the Thus I'm offering and suggesting merging such a secondary utility as |
How about SinkExt::buffer? |
I saw |
I think this is safe to close now that there are workarounds (although they may not have exactly the same performance characteristics of those based on the previous |
Part of what I was looking for, in opening this issue 5 months ago, was the details of "quite a bit of feedback" and the design justification for the new |
Uh oh!
There was an error while loading. Please reload this page.
In my existing futures 0.1
Sink
implementations, the singlestart_send
method was able to access theSinkItem
(it needs the item buffer's length), callingtokio_threadpool::blocking
if necessary and depending on that result, consuming the item buffer and returningReady
, or giving the item back viaNotReady
:https://github.com/dekellum/body-image/blob/316596356fd72042cba2c6c4dc00b584ea99576d/body-image-futio/src/uni_sink.rs#L68
I'm now trying to port these Sinks to futures 0.3-alpha. With the current
Sink
interface, it is necessary to signal any potential forPoll::Pending
(forSink
meaning lack of readiness to receive) in the trait methodpoll_ready
, before theItem
buffer is given.https://github.com/dekellum/body-image/blob/316596356fd72042cba2c6c4dc00b584ea99576d/body-image-futio/src/uni_sink.rs#L134
The futures compatibility layer already deals with this interface difference, in the
Sink01As03
shim (#1364), by maintaining an additional buffer of oneItem
, and deferring the actual consumption of thatItem
to subsequent calls topoll_ready
andpoll_flush
.I couldn't find an original rationale for this change to the
Sink
interface? Intuitively I would think it should simplify aspects of theForward
combinator, but at the expense of pushing the issue to mostSink
implementers, where the complexity risks bugs. As we are still alpha, is there any willingness to reconsider this interface change? Alternatively, would it be reasonable to introduce here some alternative trait, e.g.TardySink
:...and
impl Sink<Item> for TardySink<Item>
using the same 1-item buffering strategy as inSink01As03
, but not depending on anything from futures 0.1? Note, the tuple return type ofpoll_send
above is awkward. An alternative would be aTardyPoll<Item>
enum withTardyPoll::Pending(Item)
variant and some easy conversion toPoll
.The text was updated successfully, but these errors were encountered: