IMO your object should be a readStream if you expect it to:

   - Have data to consume sequentially, texts, buffers or objects.
   - Handle back-pressure without worrying too much about it
   - Be pipeable to something else

Anyone correct me if I'm wrong

On Thursday, 2 May 2013 01:08:30 UTC+2, Postlethwaite wrote:
>
> I have a simple library, 
> levelnet<https://github.com/bpostlethwaite/levelnet>, 
> that takes an API and reproduces it remotely using 
> mux-demux<https://github.com/dominictarr/mux-demux>and 
> dnode <https://github.com/substack/dnode>. I am trying to settle on an 
> API for the setup phase and was looking for suggestions. Perhaps the whole 
> module should be a stream?
>
> right now on the server I am doing
>
> var leveltcp = levelnet(db)var server = 
> net.createServer(leveltcp).listen(PORT)
>
> which connects the local API to a stream. 
> Then on the client I am doing something kind of ugly
>
> var stream = net.connect(PORT)var remotedb = levelnet().connect(stream)
> remotedb.on('connection', function () {
>   remotedb.get(key, callback)
> })
>
> Personally I hate the two connect calls, one for net and one for levelnet.
>
> If I made the whole library a stream (can you make a duplex stream that 
> internally connects mux-demux <https://github.com/dominictarr/mux-demux>
>  and dnode <https://github.com/substack/dnode> to itself? Probably) then 
> the API would be more like
>
> var leveltcp = levelnet(db)var server = net.createServer(function (stream) {  
> leveltcp.pipe(stream).pipe.leveltcp
> }).listen(PORT)
>
> which follows the pattern of the two streaming modules it wraps. However, 
> the remote API call remotedb.createReadStream(options)  would be a 
> stream.createReadStream() call and I am unsure if this is better.
>
> Any suggestions?
>

-- 
-- 
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