The fascinating thing about all of this is that node's Readable
streams API is perfect for what I want. If I could consume a readable
stream when people send data to a client, (and the user calls .push()
to write) the semantics match perfectly. But I think implementing a
duplex stream using two readable streams isn't any better than
inventing my own streams API to expose.

... Which is what I'm doing now and it works fine, and what I'll
probably continue doing.

-J

On Mon, Feb 24, 2014 at 2:48 PM, Joseph Gentle <[email protected]> wrote:
> Thanks guys. I emailed Dominic Tarr and he recommends against using
> node streams v2 for this stuff as well.
>
> Fedor - thats cute, but say if I call:
>
> s.on('finish', function() { process.exit(); });
> s.end();
>
> ... My process will exit while data is still in the buffer. The
> annoying this is that I can provide that guarantee right now from my
> code - I get message acknowledgements, so I can tell you exactly when
> all messages have been received by the client. But I can't control
> when finish is emitted using streams 2.0 - it gets sent automatically
> after the _write() callback is called on the last message. If the
> stream 'writes' to an internal memory buffer, those guarantees are all
> lost.
>
> Also imagine this code:
>
> middleware = function(req, res) {
>   // Process messages in the request, then send the responses in the response
>   s.push(req.body.message);
>
>   // When there's data available, send it to the client
>   s.on('avail', function() {
>     process.nextTick(function() {
>       res.end(s.buffer);
>     });
>   });
> }
>
> then:
>
> s.on('data', function(msg) {
>   s.write('one');
>   s.write('two');
> });
>
> ^--- the request will only be sent 'one' but not 'two' because of how
> _write works.
>
>
> On Mon, Feb 24, 2014 at 2:13 PM, Fedor Indutny <[email protected]> wrote:
>> Joseph,
>>
>> Take a look at following snippet:
>> https://gist.github.com/indutny/e3fcb35fc25399bb7f7b
>>
>> On Tue, Feb 25, 2014 at 1:40 AM, Arnout Kazemier <[email protected]> wrote:
>>> Primus is still using the Streams 1 interface.
>>>
>>> On Monday 24 February 2014 at 19:33, Joseph Gentle wrote:
>>>
>>> Does anyone know how primus deals with this?
>>>
>>>
>>> --
>>> --
>>> Job Board: http://jobs.nodejs.org/
>>> Posting guidelines:
>>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>>> You received this message because you are subscribed to the Google
>>> Groups "nodejs" group.
>>> To post to this group, send email to [email protected]
>>> To unsubscribe from this group, send email to
>>> [email protected]
>>> For more options, visit this group at
>>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>>
>>> ---
>>> You received this message because you are subscribed to the Google Groups
>>> "nodejs" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to [email protected].
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>> --
>> --
>> Job Board: http://jobs.nodejs.org/
>> Posting guidelines: 
>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>> You received this message because you are subscribed to the Google
>> Groups "nodejs" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>
>> ---
>> You received this message because you are subscribed to a topic in the 
>> Google Groups "nodejs" group.
>> To unsubscribe from this topic, visit 
>> https://groups.google.com/d/topic/nodejs/l0Lb6XXPhOc/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to 
>> [email protected].
>> For more options, visit https://groups.google.com/groups/opt_out.

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to