TooTallNate / node-stream-stack

Filter low-level `Stream` instances into stackable, protocol-based streams.

Home Page:http://tootallnate.net/implementing-your-protocol-stack-with-stream-stacks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

clarification of 'stackable'

dominictarr opened this issue · comments

this looks interesting, but I'm not sure what is meant by "stackable"?

how does stackable differ from pipeable?

does.pipe(writable) work with StreamStack?

When I say "stackable", I'm talking mostly about the "protocol stack" that you are needing to interact with. A "protocol stack" is made up of "layers", each of which, 1 subclass of stream-stack could be created for.

Probably easier to visualize with a little diagram. Say you want to stream-stack to implement an HTTP multipart upload (of a gzipped file). This scenario is made up of multiple "layers":

- TCP layer           |  net.Stream (low-level Stream, base of the "stack")
  - HTTP layer        |  http-stack (to parse the http request)
    - Multipart layer |  multipart-stack (to parse out the upload)
      - Gzip layer    |  gzip-stack (for unzipping the uploaded file)

So now in this case, http-stack, multipart-stack, and gzip-stack are subclasses of stream-stack the implement some sort of functionality, based on the type of data they are attempting to work with.

Also, StreamStack is a subclass of the regular Stream, so you can definitely .pipe() it's data events to a writable stream. That's pretty much the whole point of using this module!

Hopefully that explains it ok. Take a look at the subclasses I mentioned above, if you want to see some slightly more complicated examples than in the README. Good luck, and don't hesitate to ask more questions if you have any!

thanks, this is a good explanation.

The overall goal of StreamStacks is to be able to use it with the holy grail of the Stream object: Stream#pipe(writable)."

made me confused, because it sounded like you where working towards that goal, but havn't achieved it yet. I can see now that I was mistaken.

maybe phrasing like this would be less confusing:

All StreamStack inherit the from the nodejs Stream class and thus are always usable with Stream#pipe(writable)

thanks, I'll be checking out your other modules!

Thanks for the suggestion. I'll get on it.