stream: implement WritableBase without buffering#33515
stream: implement WritableBase without buffering#33515ronag wants to merge 5 commits intonodejs:masterfrom
Conversation
|
This is very much WIP but I would like some initial feedback whether this is worth further engagement. |
|
@nodejs/streams |
lib/_stream_writable.js
Outdated
There was a problem hiding this comment.
extends WritableBase.WritableState
|
Might also be useful for the QUIC work. |
|
I really like the direction this is going, however I would prefer to land this together with the changes in the other places it is targeting. I suspect you want to try making |
Good. I just wanted to make sure this is worth spending more time on. I'll start with |
|
(Keep them on separate commits, so that we can easily split it up if we need to for ease of backporting). |
8ae28ff to
2935f72
Compare
c83723e to
a3fdb90
Compare
|
@mcollina: This kind of works now... Still has some details I would like to improve upon. However, when trying to use it to implement
Maybe @jasnell would have use of this for quic... not sure where to take it from here. Maybe put on ice for now? |
|
Given all the above, I would put on ice. Unless @jasnell (or somebody else) has a good use for this. |
This separates the
Writableclass into two classes aWritableBaseclass which implements allWritablelogic except for anything related to buffering, and aWritableclass which inheritsWritableBaseand adds the buffering logic.This is in order to be able to consistently and in a performant way implement
Writablestreams that want to implement their own buffering or are simply wrapping existing streams.WritableBaseexpects 2 methods passed throughoptions:write: which is basically thewriteOrBufferimplementation from today.flush: which is basicallyend()+ wait for completion from today.Note, that this is for now only for internal core usage not meant for public API.
This will help with making
Writablelike implementations where we want to avoid buffering or sequential writes more streams compliant, e.g.OutgoingMessage.It will also help with some optimization e.g. avoid buffering both input and output of
Transformstream by implementing it in terms ofReadable+WritableBaseinstead ofReadable+Writable.Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes