I'm a two year Node.js user and fan, very like Node's design and
simplicity. Even I'd
promoted Node's adopt in our company.
We use Node's stream/pipe to do realtime dataflow style computing on Hadoop
for our
AD system.
I love the simple and stupid stream system prior v0.10. But when v0.10
landing, the new
Streams2 make me very fear. Belows are my complains..., maybe these can't
change anything,
but I want you get our hopes...
Complains
---------
1. Streams2/3 has two modes (or 3 modes), maybe too complex, violate KISS
and "Small core,
big userland" rule;
Streams3 support these modes: init, paused, flowing. If I share stream in
multiple
subsystem and, if there has anyone listen on `data`, modes switched...,
OMG...
2. `read()` and `readable` flavor is not consist with other modules (e.g.,
dgram, fs, and
W3C websocket API);
Dgram always emit `message`, Websocket use `onmessage`, all emit data but
not `readable`
like state indicator. Emit data is flexible, support multi-reader dataflow
driven computing.
On other hand, `read()` only support one reader once and, the interface
more like sync flavor
instead async/callback flavor.
3. Streams3 has incompatible issue with `unshift()`;
Streams3 on paused mode, `read()` can emit `data` event. If I use
`unshift()`, there should be
re-emit these unshift data.
4. Breaks the net/http/fs module's api stablity guarantee:
Net/http/fs all declare them are in 'Stability: 3 - Stable', but with these
Streams2/3
chanages, there should had api changes sliently.
Suggests
--------
1. KISS, move `read()` and `readable` out to userland. User can easy to
implement a transform
stream to archive same usage.
But keeps buffered `pause()` sematic. Very simple for implement..., keep we
have small vanilla
core.
2. Or, remove `readable`, provide async `read(bytes, cb)`, and turn stream
default on plain
old flowing mode. User must call `pause()` first for manual reading.
Calling `read(bytes, cb)`
does not emit `data` event.
Sample code:
```javascript
var stream = foobar.connect();
var mode;
...
stream.pause();
stream.read(4, function (data) {
if (String(data) === 'FOOB') {
stream.read(8, function (data) {
mode = String(data);
stream.unshift(data);
stream.resume();
});
} else {
stream.destroy();
}
});
stream.on('data', function (data) {
// ...
});
```
Thanks for reading,
Wenlin
--
--
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.