[nodejs] How to handle errors for a batch fo async calls

2013-02-25 Thread Glenn Block
Hello all

Let's assume you have an API that results in a batch of HTTP calls which
fire async and which are not sequential. A constraint of the API is that
any errors that occur during the calls need to get returned to the user.

How have you customarily designed this?

One idea was something like the following

function send(message, callback) {
}

where callback is function(error, results) {
}

In this case error if not null is a JSON object with a collection of child
objects with the errors.

An alternative idea I had was to have an additional completion callback per
item.

so:

function send(message, completionCallback, itemCallback) {
}

This introduces a callback for each item that is processed. In this case
the completion callback has a single error if ANY errors occur while the
itemCallback has individual errors as they occur.

This is useful for cases where you might want to stop further processing if
the number of errors is very high.

Thoughts / Experiences?
Glenn

-- 
-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
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 nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [nodejs] How to handle errors for a batch fo async calls

2013-02-25 Thread Pedro Teixeira
Hey Glenn,

For something this complex I think an event emitter may be better suited. 

-- 
Pedro


On Monday, February 25, 2013 at 9:57 AM, Glenn Block wrote:

 Hello all
 
 Let's assume you have an API that results in a batch of HTTP calls which fire 
 async and which are not sequential. A constraint of the API is that any 
 errors that occur during the calls need to get returned to the user. 
 
 How have you customarily designed this?
 
 One idea was something like the following
 
 function send(message, callback) { 
 }
 
 where callback is function(error, results) {
 }
 
 In this case error if not null is a JSON object with a collection of child 
 objects with the errors. 
 
 An alternative idea I had was to have an additional completion callback per 
 item.
 
 so:
 
 function send(message, completionCallback, itemCallback) { 
 }
 
 This introduces a callback for each item that is processed. In this case the 
 completion callback has a single error if ANY errors occur while the   
 itemCallback has individual errors as they occur. 
 
 This is useful for cases where you might want to stop further processing if 
 the number of errors is very high.
 
 Thoughts / Experiences?
 Glenn 
 
 
 
 -- 
 -- 
 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 nodejs@googlegroups.com 
 (mailto:nodejs@googlegroups.com)
 To unsubscribe from this group, send email to
 nodejs+unsubscr...@googlegroups.com 
 (mailto:nodejs+unsubscr...@googlegroups.com)
 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 nodejs+unsubscr...@googlegroups.com 
 (mailto:nodejs+unsubscr...@googlegroups.com).
 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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
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 nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[nodejs] Re: announcing browserify v2

2013-02-25 Thread Alexey Petrushin
Any plans to support custom require in future? It works in node.js - why 
make browser version of `requre` different from its original?

On Saturday, February 23, 2013 4:43:34 AM UTC+4, substack wrote:

 browserify v2 was just released! browserify lets you write node-style 
 require() calls for browser code so that you can package up your scripts 
 and npm modules into a single bundle to serve to browsers. browserify 
 implements exactly the node_modules lookup algorithm so you can use many 
 libraries written for node and published to npm in the browser without any 
 modifications.

 Here's the full writeup of the new changes: 
 http://browserify.org/announcing_browserify_v2
 * static module resolution for tinier bundles. Just ~250 bytes of prelude 
 now.
 * support for multi-file bundles for multi-page apps and better caching of 
 infrequently-updating assets
 * streaming bundle pipeline
 * new browsers field support by https://github.com/shtylman
 * less features

 The core library itself is just 180 sloc now with the bulk of the 
 functionality now handled by completely separate, reusable libraries that 
 you can use to build your own browserify if you want. Most of what 
 browserify provides can now be provided by this shell pipeline:

 $ module-deps main.js | insert-module-globals main.js | browser-pack  
 bundle.js

 Just `npm install -g module-deps insert-module-globals browser-pack` to 
 play around with those streaming components.

 tldr; less features, more unix!


-- 
-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
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 nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[nodejs] Re: How to handle errors for a batch fo async calls

2013-02-25 Thread Geerten van Meel
No need for event emitters, you can do this entirely functional. For this 
sorts of asynchroneous tasks, the async module comes to the rescue. 

A possible implementation would use the queue function with a high value 
for the concurrency of task procession. Whenever an error occurs, or you 
retrieve your desired data, dump that in one (or two seperate) arrays. When 
your queue is drained, your send both the errors and the results back.

In regard to limiting the amount of errors, if your error array is too 
long, you can just skip processing in the worker function. I,.e. a single 
line of if (errors.length  5) return callback(); at the beginning of your 
worker function.

Here's the documentation: https://github.com/caolan/async#queue

Flow control, especially in the context of asynchroneous behaviour, is 
something which you need to wrap your head around when working with node. 
async is one of the most used packages that makes our lives easier for 
tasks like this one.

On Monday, February 25, 2013 10:57:52 AM UTC+1, Glenn Block wrote:

 Hello all

 Let's assume you have an API that results in a batch of HTTP calls which 
 fire async and which are not sequential. A constraint of the API is that 
 any errors that occur during the calls need to get returned to the user.

 How have you customarily designed this?

 One idea was something like the following

 function send(message, callback) {
 }

 where callback is function(error, results) {
 }

 In this case error if not null is a JSON object with a collection of child 
 objects with the errors.

 An alternative idea I had was to have an additional completion callback 
 per item.

 so:

 function send(message, completionCallback, itemCallback) {
 }

 This introduces a callback for each item that is processed. In this case 
 the completion callback has a single error if ANY errors occur while the   
 itemCallback has individual errors as they occur.

 This is useful for cases where you might want to stop further processing 
 if the number of errors is very high.

 Thoughts / Experiences?
 Glenn 





-- 
-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
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 nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [nodejs] Re: How to handle errors for a batch fo async calls

2013-02-25 Thread Pedro Teixeira
When I advised using an event emitter, I was referring to the exposed API, 
which looked like what Glenn was asking about.

That operation he mentioned can emit several different events throughout time, 
and the best fit would be, in my opinion, an event emitter. It's universally 
known to node programmers and makes the most sense, plus has error handling 
built-in that is pluggable with domains if the API user wishes to.

When it comes to the *implementation* of the exposed API, sure, you can use 
async if you like it, or any control-flow API, or just roll out your own flow 
control thing, but that choice should never surface to the API user. 

-- 
Pedro


On Monday, February 25, 2013 at 12:52 PM, Geerten van Meel wrote:

 No need for event emitters, you can do this entirely functional. For this 
 sorts of asynchroneous tasks, the async module comes to the rescue. 
 
 A possible implementation would use the queue function with a high value 
 for the concurrency of task procession. Whenever an error occurs, or you 
 retrieve your desired data, dump that in one (or two seperate) arrays. When 
 your queue is drained, your send both the errors and the results back.
 
 In regard to limiting the amount of errors, if your error array is too long, 
 you can just skip processing in the worker function. I,.e. a single line of 
 if (errors.length  5) return callback(); at the beginning of your worker 
 function.
 
 Here's the documentation: https://github.com/caolan/async#queue
 
 Flow control, especially in the context of asynchroneous behaviour, is 
 something which you need to wrap your head around when working with node. 
 async is one of the most used packages that makes our lives easier for 
 tasks like this one.
 
 On Monday, February 25, 2013 10:57:52 AM UTC+1, Glenn Block wrote:
  Hello all
  
  Let's assume you have an API that results in a batch of HTTP calls which 
  fire async and which are not sequential. A constraint of the API is that 
  any errors that occur during the calls need to get returned to the user. 
  
  How have you customarily designed this?
  
  One idea was something like the following
  
  function send(message, callback) { 
  }
  
  where callback is function(error, results) {
  }
  
  In this case error if not null is a JSON object with a collection of child 
  objects with the errors. 
  
  An alternative idea I had was to have an additional completion callback per 
  item.
  
  so:
  
  function send(message, completionCallback, itemCallback) { 
  }
  
  This introduces a callback for each item that is processed. In this case 
  the completion callback has a single error if ANY errors occur while the   
  itemCallback has individual errors as they occur. 
  
  This is useful for cases where you might want to stop further processing if 
  the number of errors is very high.
  
  Thoughts / Experiences?
  Glenn 
  
  
  
 -- 
 -- 
 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 nodejs@googlegroups.com 
 (mailto:nodejs@googlegroups.com)
 To unsubscribe from this group, send email to
 nodejs+unsubscr...@googlegroups.com 
 (mailto:nodejs+unsubscr...@googlegroups.com)
 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 nodejs+unsubscr...@googlegroups.com 
 (mailto:nodejs+unsubscr...@googlegroups.com).
 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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
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 nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [nodejs] How to handle errors for a batch fo async calls

2013-02-25 Thread Oleg Slobodskoi
I wrote this to handle such stuff:

https://github.com/kof/do


Possibly I have to add a complete callback for the case one want to when it is 
finished and than get the array of errors.

Normally you don't want go further when error is happened.


Am 25.02.2013 um 10:57 schrieb Glenn Block glenn.bl...@gmail.com:

 Hello all
 
 Let's assume you have an API that results in a batch of HTTP calls which fire 
 async and which are not sequential. A constraint of the API is that any 
 errors that occur during the calls need to get returned to the user.
 
 How have you customarily designed this?
 
 One idea was something like the following
 
 function send(message, callback) {
 }
 
 where callback is function(error, results) {
 }
 
 In this case error if not null is a JSON object with a collection of child 
 objects with the errors.
 
 An alternative idea I had was to have an additional completion callback per 
 item.
 
 so:
 
 function send(message, completionCallback, itemCallback) {
 }
 
 This introduces a callback for each item that is processed. In this case the 
 completion callback has a single error if ANY errors occur while the   
 itemCallback has individual errors as they occur.
 
 This is useful for cases where you might want to stop further processing if 
 the number of errors is very high.
 
 Thoughts / Experiences?
 Glenn 
 
 
 
 
 -- 
 -- 
 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 nodejs@googlegroups.com
 To unsubscribe from this group, send email to
 nodejs+unsubscr...@googlegroups.com
 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 nodejs+unsubscr...@googlegroups.com.
 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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
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 nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [nodejs] Re: why fallocate is not exposed?

2013-02-25 Thread Matt
I'd happily take a patch to add something to fs-ext. Especially if it comes
with a patch to support gyp :)


On Sun, Feb 24, 2013 at 5:47 PM, Ben Noordhuis i...@bnoordhuis.nl wrote:

 On Sun, Feb 24, 2013 at 11:00 PM, Marcel Laverdet mar...@laverdet.com
 wrote:
  others. Really this is something that might just be better off in fs-ext
  (which I'm already using for flock) if you can't emulate it in Windows.

 To be clear, it's not just Windows.  fallocate() is a _Linux-ism_.

 The nearest thing on other Unices is posix_fallocate() or
 fcntl(F_PREALLOCATE).

 --
 --
 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 nodejs@googlegroups.com
 To unsubscribe from this group, send email to
 nodejs+unsubscr...@googlegroups.com
 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 nodejs+unsubscr...@googlegroups.com.
 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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
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 nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [nodejs] Re: How to handle errors for a batch fo async calls

2013-02-25 Thread Geerten van Meel
@Pedro: This is the nice thing about JavaScript, you can handle problems in 
lots of different ways. I'm just pointing out one alternative approach. 
EventEmitters make a lot more sense when you are trying to make reusable 
components, given the (very small) overhead they imply.

On Monday, February 25, 2013 1:58:08 PM UTC+1, Pedro Teixeira wrote:

 When I advised using an event emitter, I was referring to the exposed API, 
 which looked like what Glenn was asking about.

 That operation he mentioned can emit several different events throughout 
 time, and the best fit would be, in my opinion, an event emitter. It's 
 universally known to node programmers and makes the most sense, plus has 
 error handling built-in that is pluggable with domains if the API user 
 wishes to.

 When it comes to the *implementation* of the exposed API, sure, you can 
 use async if you like it, or any control-flow API, or just roll out your 
 own flow control thing, but that choice should never surface to the API 
 user.

 -- 
 Pedro

 On Monday, February 25, 2013 at 12:52 PM, Geerten van Meel wrote:

 No need for event emitters, you can do this entirely functional. For this 
 sorts of asynchroneous tasks, the async module comes to the rescue. 

 A possible implementation would use the queue function with a high value 
 for the concurrency of task procession. Whenever an error occurs, or you 
 retrieve your desired data, dump that in one (or two seperate) arrays. When 
 your queue is drained, your send both the errors and the results back.

 In regard to limiting the amount of errors, if your error array is too 
 long, you can just skip processing in the worker function. I,.e. a single 
 line of if (errors.length  5) return callback(); at the beginning of your 
 worker function.

 Here's the documentation: https://github.com/caolan/async#queue

 Flow control, especially in the context of asynchroneous behaviour, is 
 something which you need to wrap your head around when working with node. 
 async is one of the most used packages that makes our lives easier for 
 tasks like this one.

 On Monday, February 25, 2013 10:57:52 AM UTC+1, Glenn Block wrote:

 Hello all

 Let's assume you have an API that results in a batch of HTTP calls which 
 fire async and which are not sequential. A constraint of the API is that 
 any errors that occur during the calls need to get returned to the user.

 How have you customarily designed this?

 One idea was something like the following

 function send(message, callback) {
 }

 where callback is function(error, results) {
 }

 In this case error if not null is a JSON object with a collection of child 
 objects with the errors.

 An alternative idea I had was to have an additional completion callback 
 per item.

 so:

 function send(message, completionCallback, itemCallback) {
 }

 This introduces a callback for each item that is processed. In this case 
 the completion callback has a single error if ANY errors occur while the   
 itemCallback has individual errors as they occur.

 This is useful for cases where you might want to stop further processing 
 if the number of errors is very high.

 Thoughts / Experiences?
 Glenn 



  -- 
 -- 
 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 nod...@googlegroups.com javascript:
 To unsubscribe from this group, send email to
 nodejs+un...@googlegroups.com javascript:
 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 nodejs+un...@googlegroups.com javascript:.
 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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
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 nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[nodejs] Re: announcing browserify v2

2013-02-25 Thread Bradley Meck
We are doing some dark magic upcoming 
using https://github.com/bmeck/node-module-system +1 if we can get a 
standardized require shim. Does not need to be ours.

-- 
-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
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 nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [nodejs] How to handle errors for a batch fo async calls

2013-02-25 Thread Glenn Block
Thanks Pedro



On Mon, Feb 25, 2013 at 2:16 AM, Pedro Teixeira pedro.teixe...@gmail.comwrote:

 Hey Glenn,

 For something this complex I think an event emitter may be better suited.

 --
 Pedro

 On Monday, February 25, 2013 at 9:57 AM, Glenn Block wrote:

 Hello all

 Let's assume you have an API that results in a batch of HTTP calls which
 fire async and which are not sequential. A constraint of the API is that
 any errors that occur during the calls need to get returned to the user.

 How have you customarily designed this?

 One idea was something like the following

 function send(message, callback) {
 }

 where callback is function(error, results) {
 }

 In this case error if not null is a JSON object with a collection of child
 objects with the errors.

 An alternative idea I had was to have an additional completion callback
 per item.

 so:

 function send(message, completionCallback, itemCallback) {
 }

 This introduces a callback for each item that is processed. In this case
 the completion callback has a single error if ANY errors occur while the
 itemCallback has individual errors as they occur.

 This is useful for cases where you might want to stop further processing
 if the number of errors is very high.

 Thoughts / Experiences?
 Glenn



  --
 --
 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 nodejs@googlegroups.com
 To unsubscribe from this group, send email to
 nodejs+unsubscr...@googlegroups.com
 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 nodejs+unsubscr...@googlegroups.com.
 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 nodejs@googlegroups.com
 To unsubscribe from this group, send email to
 nodejs+unsubscr...@googlegroups.com
 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 nodejs+unsubscr...@googlegroups.com.
 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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
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 nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [nodejs] How to handle errors for a batch fo async calls

2013-02-25 Thread Glenn Block
Normally you don't want go further when error is happened.

In this case it is acceptable to continue processing as long as you capture
the received errors. If there were a high amt of failures you might
consider cancelling though.


On Mon, Feb 25, 2013 at 6:00 AM, Oleg Slobodskoi oleg...@googlemail.comwrote:

 I wrote this to handle such stuff:

 https://github.com/kof/do


 Possibly I have to add a complete callback for the case one want to when
 it is finished and than get the array of errors.

 Normally you don't want go further when error is happened.


 Am 25.02.2013 um 10:57 schrieb Glenn Block glenn.bl...@gmail.com:

 Hello all

 Let's assume you have an API that results in a batch of HTTP calls which
 fire async and which are not sequential. A constraint of the API is that
 any errors that occur during the calls need to get returned to the user.

 How have you customarily designed this?

 One idea was something like the following

 function send(message, callback) {
 }

 where callback is function(error, results) {
 }

 In this case error if not null is a JSON object with a collection of child
 objects with the errors.

 An alternative idea I had was to have an additional completion callback
 per item.

 so:

 function send(message, completionCallback, itemCallback) {
 }

 This introduces a callback for each item that is processed. In this case
 the completion callback has a single error if ANY errors occur while the
 itemCallback has individual errors as they occur.

 This is useful for cases where you might want to stop further processing
 if the number of errors is very high.

 Thoughts / Experiences?
 Glenn




 --
 --
 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 nodejs@googlegroups.com
 To unsubscribe from this group, send email to
 nodejs+unsubscr...@googlegroups.com
 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 nodejs+unsubscr...@googlegroups.com.
 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 nodejs@googlegroups.com
 To unsubscribe from this group, send email to
 nodejs+unsubscr...@googlegroups.com
 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 nodejs+unsubscr...@googlegroups.com.
 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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
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 nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [nodejs] How to handle errors for a batch fo async calls

2013-02-25 Thread Glenn Block
Jose, thanks for the clarification.

Literally right after sending the mail I was thinking I forgot all about
event emitters :-)

In terms of error, are you saying that any time you emit an event called
Error the runtime exits if there is no listener?




On Mon, Feb 25, 2013 at 3:12 AM, José F. Romaniello
jfromanie...@gmail.comwrote:

 +1 on event emitter. Callback with an array of errors is not that common.
 You should return an event emitter with complete and error events. be
 aware that when you emit an 'error' event and no one is listening in the
 application exits


 2013/2/25 Pedro Teixeira pedro.teixe...@gmail.com

 Hey Glenn,

 For something this complex I think an event emitter may be better suited.

 --
 Pedro

 On Monday, February 25, 2013 at 9:57 AM, Glenn Block wrote:

 Hello all

 Let's assume you have an API that results in a batch of HTTP calls which
 fire async and which are not sequential. A constraint of the API is that
 any errors that occur during the calls need to get returned to the user.

 How have you customarily designed this?

 One idea was something like the following

 function send(message, callback) {
 }

 where callback is function(error, results) {
 }

 In this case error if not null is a JSON object with a collection of
 child objects with the errors.

 An alternative idea I had was to have an additional completion callback
 per item.

 so:

 function send(message, completionCallback, itemCallback) {
 }

 This introduces a callback for each item that is processed. In this case
 the completion callback has a single error if ANY errors occur while the
 itemCallback has individual errors as they occur.

 This is useful for cases where you might want to stop further processing
 if the number of errors is very high.

 Thoughts / Experiences?
 Glenn



  --
 --
 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 nodejs@googlegroups.com
 To unsubscribe from this group, send email to
 nodejs+unsubscr...@googlegroups.com
 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 nodejs+unsubscr...@googlegroups.com.
 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 nodejs@googlegroups.com
 To unsubscribe from this group, send email to
 nodejs+unsubscr...@googlegroups.com
 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 nodejs+unsubscr...@googlegroups.com.
 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 nodejs@googlegroups.com
 To unsubscribe from this group, send email to
 nodejs+unsubscr...@googlegroups.com
 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 nodejs+unsubscr...@googlegroups.com.
 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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
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 nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [nodejs] How to handle errors for a batch fo async calls

2013-02-25 Thread José F . Romaniello
yes

http://nodejs.org/api/events.html#events_class_events_eventemitter


2013/2/25 Glenn Block glenn.bl...@gmail.com

 Jose, thanks for the clarification.

 Literally right after sending the mail I was thinking I forgot all about
 event emitters :-)

 In terms of error, are you saying that any time you emit an event called
 Error the runtime exits if there is no listener?




 On Mon, Feb 25, 2013 at 3:12 AM, José F. Romaniello 
 jfromanie...@gmail.com wrote:

 +1 on event emitter. Callback with an array of errors is not that common.
 You should return an event emitter with complete and error events. be
 aware that when you emit an 'error' event and no one is listening in the
 application exits


 2013/2/25 Pedro Teixeira pedro.teixe...@gmail.com

 Hey Glenn,

 For something this complex I think an event emitter may be better suited.

 --
 Pedro

 On Monday, February 25, 2013 at 9:57 AM, Glenn Block wrote:

 Hello all

 Let's assume you have an API that results in a batch of HTTP calls which
 fire async and which are not sequential. A constraint of the API is that
 any errors that occur during the calls need to get returned to the user.

 How have you customarily designed this?

 One idea was something like the following

 function send(message, callback) {
 }

 where callback is function(error, results) {
 }

 In this case error if not null is a JSON object with a collection of
 child objects with the errors.

 An alternative idea I had was to have an additional completion callback
 per item.

 so:

 function send(message, completionCallback, itemCallback) {
 }

 This introduces a callback for each item that is processed. In this case
 the completion callback has a single error if ANY errors occur while the
 itemCallback has individual errors as they occur.

 This is useful for cases where you might want to stop further processing
 if the number of errors is very high.

 Thoughts / Experiences?
 Glenn



  --
 --
 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 nodejs@googlegroups.com
 To unsubscribe from this group, send email to
 nodejs+unsubscr...@googlegroups.com
 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 nodejs+unsubscr...@googlegroups.com.
 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 nodejs@googlegroups.com
 To unsubscribe from this group, send email to
 nodejs+unsubscr...@googlegroups.com
 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 nodejs+unsubscr...@googlegroups.com.
 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 nodejs@googlegroups.com
 To unsubscribe from this group, send email to
 nodejs+unsubscr...@googlegroups.com
 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 nodejs+unsubscr...@googlegroups.com.
 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 nodejs@googlegroups.com
 To unsubscribe from this group, send email to
 nodejs+unsubscr...@googlegroups.com
 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 nodejs+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting 

Re: [nodejs] How to handle errors for a batch fo async calls

2013-02-25 Thread Mikeal Rogers
Agreed, sometimes a yes or no question is answered by an error or success in a 
callback in node. You don't see this in blocking systems as much because 
try/catch is cumbersome but it's fairly common in node.

On Feb 25, 2013, at February 25, 201311:51 AM, Glenn Block 
glenn.bl...@gmail.com wrote:

 Normally you don't want go further when error is happened.
 
 In this case it is acceptable to continue processing as long as you capture 
 the received errors. If there were a high amt of failures you might 
 consider cancelling though.
 
 
 On Mon, Feb 25, 2013 at 6:00 AM, Oleg Slobodskoi oleg...@googlemail.com 
 wrote:
 I wrote this to handle such stuff:
 
 https://github.com/kof/do
 
 
 Possibly I have to add a complete callback for the case one want to when it 
 is finished and than get the array of errors.
 
 Normally you don't want go further when error is happened.
 
 
 Am 25.02.2013 um 10:57 schrieb Glenn Block glenn.bl...@gmail.com:
 
 Hello all
 
 Let's assume you have an API that results in a batch of HTTP calls which 
 fire async and which are not sequential. A constraint of the API is that any 
 errors that occur during the calls need to get returned to the user.
 
 How have you customarily designed this?
 
 One idea was something like the following
 
 function send(message, callback) {
 }
 
 where callback is function(error, results) {
 }
 
 In this case error if not null is a JSON object with a collection of child 
 objects with the errors.
 
 An alternative idea I had was to have an additional completion callback per 
 item.
 
 so:
 
 function send(message, completionCallback, itemCallback) {
 }
 
 This introduces a callback for each item that is processed. In this case the 
 completion callback has a single error if ANY errors occur while the   
 itemCallback has individual errors as they occur.
 
 This is useful for cases where you might want to stop further processing if 
 the number of errors is very high.
 
 Thoughts / Experiences?
 Glenn 
 
 
 
 
 -- 
 -- 
 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 nodejs@googlegroups.com
 To unsubscribe from this group, send email to
 nodejs+unsubscr...@googlegroups.com
 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 nodejs+unsubscr...@googlegroups.com.
 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 nodejs@googlegroups.com
 To unsubscribe from this group, send email to
 nodejs+unsubscr...@googlegroups.com
 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 nodejs+unsubscr...@googlegroups.com.
 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 nodejs@googlegroups.com
 To unsubscribe from this group, send email to
 nodejs+unsubscr...@googlegroups.com
 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 nodejs+unsubscr...@googlegroups.com.
 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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
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 nodejs+unsubscr...@googlegroups.com.
For more options, visit 

Re: [nodejs] How to handle errors for a batch fo async calls

2013-02-25 Thread José F . Romaniello
quoting docs:

When an EventEmitter instance experiences an error, the typical action is
to emit an 'error' event. Error events are treated as a special case in
node. If there is no listener for it, then the default action is to print a
stack trace and exit the program.


2013/2/25 Glenn Block glenn.bl...@gmail.com

 Jose, thanks for the clarification.

 Literally right after sending the mail I was thinking I forgot all about
 event emitters :-)

 In terms of error, are you saying that any time you emit an event called
 Error the runtime exits if there is no listener?




 On Mon, Feb 25, 2013 at 3:12 AM, José F. Romaniello 
 jfromanie...@gmail.com wrote:

 +1 on event emitter. Callback with an array of errors is not that common.
 You should return an event emitter with complete and error events. be
 aware that when you emit an 'error' event and no one is listening in the
 application exits


 2013/2/25 Pedro Teixeira pedro.teixe...@gmail.com

 Hey Glenn,

 For something this complex I think an event emitter may be better suited.

 --
 Pedro

 On Monday, February 25, 2013 at 9:57 AM, Glenn Block wrote:

 Hello all

 Let's assume you have an API that results in a batch of HTTP calls which
 fire async and which are not sequential. A constraint of the API is that
 any errors that occur during the calls need to get returned to the user.

 How have you customarily designed this?

 One idea was something like the following

 function send(message, callback) {
 }

 where callback is function(error, results) {
 }

 In this case error if not null is a JSON object with a collection of
 child objects with the errors.

 An alternative idea I had was to have an additional completion callback
 per item.

 so:

 function send(message, completionCallback, itemCallback) {
 }

 This introduces a callback for each item that is processed. In this case
 the completion callback has a single error if ANY errors occur while the
 itemCallback has individual errors as they occur.

 This is useful for cases where you might want to stop further processing
 if the number of errors is very high.

 Thoughts / Experiences?
 Glenn



  --
 --
 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 nodejs@googlegroups.com
 To unsubscribe from this group, send email to
 nodejs+unsubscr...@googlegroups.com
 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 nodejs+unsubscr...@googlegroups.com.
 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 nodejs@googlegroups.com
 To unsubscribe from this group, send email to
 nodejs+unsubscr...@googlegroups.com
 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 nodejs+unsubscr...@googlegroups.com.
 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 nodejs@googlegroups.com
 To unsubscribe from this group, send email to
 nodejs+unsubscr...@googlegroups.com
 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 nodejs+unsubscr...@googlegroups.com.
 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 nodejs@googlegroups.com
 To unsubscribe from this group, send email to
 nodejs+unsubscr...@googlegroups.com
 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 

Re: [nodejs] How to handle errors for a batch fo async calls

2013-02-25 Thread Adam Crabtree
Short answer, most control-flow libraries support grouping and some form of
error coalescing.

Also, you can use stepdown for this. Stepdown supports error coalescing,
and domains for async catching. It also functions by default as an EE as
well:

var $$ = require('stepdown')

function foo(callback) {
  $$([
function($) {
  var group = $.group()
  urls.forEach(function(url) {
request.get(url, group())
  })
}
  ], callback)
}

or...

function foo(callback) {
  var task = $$([
function($) {
  var group = $.group()
  urls.forEach(function(url) {
request.get(url, group())
  })
}
  ])

  task.on('error', callback)
  task.on('complete', callback.bind(null, null))
  return task
}


On Mon, Feb 25, 2013 at 12:00 PM, José F. Romaniello jfromanie...@gmail.com
 wrote:

 quoting docs:

 When an EventEmitter instance experiences an error, the typical action is
 to emit an 'error' event. Error events are treated as a special case in
 node. If there is no listener for it, then the default action is to print a
 stack trace and exit the program.


 2013/2/25 Glenn Block glenn.bl...@gmail.com

 Jose, thanks for the clarification.

 Literally right after sending the mail I was thinking I forgot all about
 event emitters :-)

 In terms of error, are you saying that any time you emit an event called
 Error the runtime exits if there is no listener?




 On Mon, Feb 25, 2013 at 3:12 AM, José F. Romaniello 
 jfromanie...@gmail.com wrote:

 +1 on event emitter. Callback with an array of errors is not that common.
 You should return an event emitter with complete and error events. be
 aware that when you emit an 'error' event and no one is listening in the
 application exits


 2013/2/25 Pedro Teixeira pedro.teixe...@gmail.com

 Hey Glenn,

 For something this complex I think an event emitter may be better
 suited.

 --
 Pedro

 On Monday, February 25, 2013 at 9:57 AM, Glenn Block wrote:

 Hello all

 Let's assume you have an API that results in a batch of HTTP calls
 which fire async and which are not sequential. A constraint of the API is
 that any errors that occur during the calls need to get returned to the
 user.

 How have you customarily designed this?

 One idea was something like the following

 function send(message, callback) {
 }

 where callback is function(error, results) {
 }

 In this case error if not null is a JSON object with a collection of
 child objects with the errors.

 An alternative idea I had was to have an additional completion callback
 per item.

 so:

 function send(message, completionCallback, itemCallback) {
 }

 This introduces a callback for each item that is processed. In this
 case the completion callback has a single error if ANY errors occur while
 the   itemCallback has individual errors as they occur.

 This is useful for cases where you might want to stop further
 processing if the number of errors is very high.

 Thoughts / Experiences?
 Glenn



  --
 --
 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 nodejs@googlegroups.com
 To unsubscribe from this group, send email to
 nodejs+unsubscr...@googlegroups.com
 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 nodejs+unsubscr...@googlegroups.com.
 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 nodejs@googlegroups.com
 To unsubscribe from this group, send email to
 nodejs+unsubscr...@googlegroups.com
 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 nodejs+unsubscr...@googlegroups.com.
 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 nodejs@googlegroups.com
 To unsubscribe from this group, send email to
 nodejs+unsubscr...@googlegroups.com
 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 

Re: [nodejs] How to handle errors for a batch fo async calls

2013-02-25 Thread Glenn Block
Thanks. I hate to admit I've created emitters before and didn't realize
this.


On Mon, Feb 25, 2013 at 12:00 PM, José F. Romaniello jfromanie...@gmail.com
 wrote:

 quoting docs:

 When an EventEmitter instance experiences an error, the typical action is
 to emit an 'error' event. Error events are treated as a special case in
 node. If there is no listener for it, then the default action is to print a
 stack trace and exit the program.


 2013/2/25 Glenn Block glenn.bl...@gmail.com

 Jose, thanks for the clarification.

 Literally right after sending the mail I was thinking I forgot all about
 event emitters :-)

 In terms of error, are you saying that any time you emit an event called
 Error the runtime exits if there is no listener?




 On Mon, Feb 25, 2013 at 3:12 AM, José F. Romaniello 
 jfromanie...@gmail.com wrote:

 +1 on event emitter. Callback with an array of errors is not that common.
 You should return an event emitter with complete and error events. be
 aware that when you emit an 'error' event and no one is listening in the
 application exits


 2013/2/25 Pedro Teixeira pedro.teixe...@gmail.com

 Hey Glenn,

 For something this complex I think an event emitter may be better
 suited.

 --
 Pedro

 On Monday, February 25, 2013 at 9:57 AM, Glenn Block wrote:

 Hello all

 Let's assume you have an API that results in a batch of HTTP calls
 which fire async and which are not sequential. A constraint of the API is
 that any errors that occur during the calls need to get returned to the
 user.

 How have you customarily designed this?

 One idea was something like the following

 function send(message, callback) {
 }

 where callback is function(error, results) {
 }

 In this case error if not null is a JSON object with a collection of
 child objects with the errors.

 An alternative idea I had was to have an additional completion callback
 per item.

 so:

 function send(message, completionCallback, itemCallback) {
 }

 This introduces a callback for each item that is processed. In this
 case the completion callback has a single error if ANY errors occur while
 the   itemCallback has individual errors as they occur.

 This is useful for cases where you might want to stop further
 processing if the number of errors is very high.

 Thoughts / Experiences?
 Glenn



  --
 --
 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 nodejs@googlegroups.com
 To unsubscribe from this group, send email to
 nodejs+unsubscr...@googlegroups.com
 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 nodejs+unsubscr...@googlegroups.com.
 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 nodejs@googlegroups.com
 To unsubscribe from this group, send email to
 nodejs+unsubscr...@googlegroups.com
 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 nodejs+unsubscr...@googlegroups.com.
 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 nodejs@googlegroups.com
 To unsubscribe from this group, send email to
 nodejs+unsubscr...@googlegroups.com
 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 nodejs+unsubscr...@googlegroups.com.
 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 nodejs@googlegroups.com
 To unsubscribe from this group, send email to
 nodejs+unsubscr...@googlegroups.com
 For more options, visit this group at
 

Re: [nodejs] MongoDB / Mongoose - prevent field update

2013-02-25 Thread smak
Dan,

Thanks for the information... I will knock around and see what I can do 
with that approach.

Thanks,

smak

On Friday, February 22, 2013 10:01:45 AM UTC-5, Dan Milon wrote:

 It's up to you to filter and validate the input. (ok, mongoose has 
 some basic validation but that won't help you here). 

 here's what I do. Hope that helps: 

 ```javascript 
 // User.UPDATE_ATTRS is an array of the permitted attributes 
 // for updating. 
 // 
 // filter returns an object with only those keys 
 var attrs = filter(req.body, User.UPDATE_ATTRS) 

 // the second parameter is an array of the keys I want 
 // to validate for. (its not User.UPDATE_ATTRS because 
 // I want to validate only what's present in this request) 
 var err = validators.user(attrs, Object.keys(attrs)) 
 if (err) { 
   return next(err) 
 } 

 User.update({ _id: ... }, attrs, ...) 
 ``` 

 On 02/22/2013 08:01 AM, smak wrote: 
  Note:  I am new to the Node stack and am still in the learning 
  stages. 
  
  Setup:  Node / Express / Mongoose / MongoDB for a web application. 
  
  
  Issue:  How does one prevent the updating of a field in a 
  document. i.e. createdAt or userName.  In theory, some values 
  should be created and then be read only [under most circumstances]. 
  As best I can tell if a value is passed back from the UI it gets 
  mapped to the schema and updated in the database. 
  
  It looks like there are some options in the schema to prevent 
  values being passed back on the query side but nothing to block on 
  the update side. 
  
  Can anyone point to an example or documentation that would help 
  solve the issue. 
  
  Thanks, 
  
  smak 
  
  -- -- 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 
  nod...@googlegroups.com javascript: To unsubscribe from this group, 
 send email 
  to nodejs+un...@googlegroups.com javascript: 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 
  nodejs+un...@googlegroups.com javascript:. 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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
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 nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[nodejs] Re: announcing browserify v2

2013-02-25 Thread TJ Koury
Question to all concerned who are creating these tools that bundle:

How do you handle dependencies in purely client-side code?  I built a 
little library that uses transitive reduction along with a manifest file 
that lists all known dependencies for each of the browser-side scripts, so 
for example jQuery gets loaded before jQueryUI.  My library also makes sure 
that no file is referenced twice, but that all dependencies are fulfilled 
before compressing the result and sending it to the browser.
I'd like to just switch over to using Browserify, but so far it doesn't 
seem like I can use libraries for GUI development easily with this library 
without a bunch of (!isServer) checks.

On Friday, February 22, 2013 7:43:34 PM UTC-5, substack wrote:

 browserify v2 was just released! browserify lets you write node-style 
 require() calls for browser code so that you can package up your scripts 
 and npm modules into a single bundle to serve to browsers. browserify 
 implements exactly the node_modules lookup algorithm so you can use many 
 libraries written for node and published to npm in the browser without any 
 modifications.

 Here's the full writeup of the new changes: 
 http://browserify.org/announcing_browserify_v2
 * static module resolution for tinier bundles. Just ~250 bytes of prelude 
 now.
 * support for multi-file bundles for multi-page apps and better caching of 
 infrequently-updating assets
 * streaming bundle pipeline
 * new browsers field support by https://github.com/shtylman
 * less features

 The core library itself is just 180 sloc now with the bulk of the 
 functionality now handled by completely separate, reusable libraries that 
 you can use to build your own browserify if you want. Most of what 
 browserify provides can now be provided by this shell pipeline:

 $ module-deps main.js | insert-module-globals main.js | browser-pack  
 bundle.js

 Just `npm install -g module-deps insert-module-globals browser-pack` to 
 play around with those streaming components.

 tldr; less features, more unix!


-- 
-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
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 nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [nodejs] Upnp + NodeJS (Question)

2013-02-25 Thread Fedor Indutny
You can try taking this module as a base, and extending it with other
functions: https://github.com/indutny/node-nat-upnp

Cheers,
Fedor.


On Tue, Feb 26, 2013 at 12:52 AM, Tim Montague tfmonta...@gmail.com wrote:

 *Can I use NodeJS to detect a upnp device, and send it a SOAP message?*

 Currently, I'm using Miranda.py to scan for a UPNP device, and send a SOAP
 message, that goes like this in a python shell:


 PYTHON:

  from miranda import upnp
  conn = upnp()
  resp = conn.sendSOAP( uri, urn, url, etc. )


 *I'd like to do this in Node.js.*

 --
 --
 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 nodejs@googlegroups.com
 To unsubscribe from this group, send email to
 nodejs+unsubscr...@googlegroups.com
 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 nodejs+unsubscr...@googlegroups.com.
 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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
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 nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[nodejs] Re: announcing browserify v2

2013-02-25 Thread Bradley Meck
Generally I abstract out my implementations and my interfaces. This means a 
more verbose code base, but allows me to have the renderer inserted via 
dependency injection. It is independent of bundling tech and I have used it 
with browserify as well as with AMD to great success. Decoupling those 
allows you to reuse interfaces on server side, but implementations will 
always need rewriting. If you do dep injection though only the renderer 
generally needs a rewrite though which is a huge win.

-- 
-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
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 nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[nodejs] [ANN] reStore, a personal remoteStorage server

2013-02-25 Thread James Coglan
I've just made the first public release of reStore, a Node.js server that
implements the remoteStorage protocol. This lets web applications delegate
their storage needs to a server chosen by the user, and is part of the
Unhosted project.

http://blog.jcoglan.com/2013/02/25/announcing-restore-a-personal-remotestorage-server-for-node/

This is still alpha software but I'm very keen to get user feedback to make
it as solid as possible.

Thanks,
James

-- 
James Coglan
http://jcoglan.com
+44 (0) 7771512510

-- 
-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
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 nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [nodejs] node.js database driver for SAP HANA in-memory database

2013-02-25 Thread am_p1
I'm using node odbc a LOT with db2... it's c++, non blocking and therefore 
very fast...

google odbc sap hana...

On Friday, February 22, 2013 4:43:34 PM UTC-5, TJ wrote:

 On 22/02/13 20:49, Zhibin wrote: 
  Hi, 

  Is anyone interested to build a node.js database driver for SAP HANA 
  in-memory database?  Please send me an email if you are interested! 

 This is something I would be very interested in pursuing. 


-- 
-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
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 nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [nodejs] Secure distribution of NodeJS applications

2013-02-25 Thread Roger WANG
Jeremy Rudd jrudd.develo...@gmail.com writes:

 *What:* Can NodeJS apps be distributed as binary? ie. you compile the .js 
 app via V8 into its native binary, and distribute the binary to our 
 clients? ... or is minifying the code all you can do?

 *Why:* We build serverside applications in NodeJS for clients, that have 
 often to be hosted on the client's servers. Distributing source code means 
 clients can easily steal our solution and stop paying licensing fees. This 
 opens up the possibility of easy reverse-engineering or reuse of our apps 
 without our awareness.

 *Shamelessly cross posted on*: 
 http://stackoverflow.com/questions/9413123/secure-distribution-of-nodejs-applications

In node-webkit we just released an experimental feature for this -- the
JavaScript source code is compiled to native binary with v8 snapshot
feature. I believe the same thing can be done for Node.js

See
https://github.com/rogerwang/node-webkit/wiki/Protect-JavaScript-source-code-with-v8-snapshot

Thanks
-- 
Roger WANG Intel Open Source Technology Center

https://github.com/rogerwang/node-webkit
node-webkit: Call all Node.js modules directly from DOM and enable
a new way of writing applications with all Web technologies.

-- 
-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
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 nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.