Re: [nodejs] Help writing async Readable stream

2013-08-16 Thread Brian Lalor
On Aug 16, 2013, at 6:43 AM, Ben Noordhuis wrote: >> Thanks, Ben. Is there any feedback to the process that this is happening? > > Yes and no. Libuv knows when the kernel's send buffer is full but it > doesn't yet convey that information to node.js. > > It would require some rework to get tha

Re: [nodejs] Help writing async Readable stream

2013-08-16 Thread Ben Noordhuis
On Fri, Aug 16, 2013 at 12:06 PM, Brian Lalor wrote: > On Aug 16, 2013, at 6:05 AM, Ben Noordhuis wrote: > >>> To your point about pause/resume, Jake: there's no flow control with UDP. >>> What're the consequences of not honoring a return of false from >>> Readable#push()? >> >> There is no flow

Re: [nodejs] Help writing async Readable stream

2013-08-16 Thread Brian Lalor
On Aug 16, 2013, at 6:05 AM, Ben Noordhuis wrote: >> To your point about pause/resume, Jake: there's no flow control with UDP. >> What're the consequences of not honoring a return of false from >> Readable#push()? > > There is no flow control but UDP is still rate-limited - a process > cannot se

Re: [nodejs] Help writing async Readable stream

2013-08-16 Thread Ben Noordhuis
On Fri, Aug 16, 2013 at 11:54 AM, Brian Lalor wrote: > Thank you, Jake and Pedro. You confirmed my approach was valid; my mistake > is that I included an encoding in the options to the Readable constructor, > which apparently overrides objectMode. And, no, I don't know why I had that > there; it

Re: [nodejs] Help writing async Readable stream

2013-08-16 Thread Brian Lalor
Thank you, Jake and Pedro. You confirmed my approach was valid; my mistake is that I included an encoding in the options to the Readable constructor, which apparently overrides objectMode. And, no, I don't know why I had that there; it makes no sense. :-) To your point about pause/resume, Jak

Re: [nodejs] Help writing async Readable stream

2013-08-15 Thread Jake Verbaten
You want to create a Readable stream from a push source. The general strategy is to create a stream, set _read to the function that does the resume() logic. Listen to the push source and call push() whenever you have data. When push() returns false you should do the pause() logic. In the UDP ca

Re: [nodejs] Help writing async Readable stream

2013-08-15 Thread Pedro Teixeira
The way I do it is by implementing a no-op _read and pushing whenever I need to. -- Pedro On Friday, August 16, 2013 at 3:03 AM, Brian Lalor wrote: > I'm trying to implement a Readable stream that emits objects parsed from UDP > datagrams. I've been looking for some good stream tutorials, bu

[nodejs] Help writing async Readable stream

2013-08-15 Thread Brian Lalor
I'm trying to implement a Readable stream that emits objects parsed from UDP datagrams. I've been looking for some good stream tutorials, but nothing's really clicking for me. I think this is compounded by the fact that the stream documentation on nodejs.org says that Readable.push() and Writa