Re: [nodejs] Re: Callback hell and how to get around it?
Instead of nesting functions within function, use a state object and named functions: function printCommentsForUser(login, password, done) { var s = {}; authenticateUser(login, password, authenticated); function authenticated(err, user) { if (err) { return done(err); } s.user = user; getComments(s.user.id, gotComments); } function gotComments(err, comments) { if (err) { return done(err); } renderComments(s.user, comments, done); s = null; } } Reads much nicer even if it is more lines of code. Tim On Mon, Sep 15, 2014 at 01:20:05PM -0700, Alexey Petrushin wrote: I wrote short article http://jslang.info/blog/2014/escape-from-callback-hell about simple approach that turn this var printCommentsForUser = function(login, password, cb){ authenticateUser(login, password, function(err, user){ if(err) return cb(err) getComments(user.id, function(err, comments){ if(err) return cb(err) renderComments(user, comments, cb) }) }) } Into this var printCommentsForUserWithFork = function(login, password, ecb, cb){ authenticateUser(login, password, ecb, function(user){ getComments(user.id, ecb, function(comments){ renderComments(user, comments, ecb, cb) }) }) } Or this var printCommentsForUserWithTwoCallbacks = function(login, password, ecb, cb){ authenticateUser(login, password, ecb, function(user){ getComments(user.id, ecb, function(comments){ renderComments(user, comments, ecb, cb) }) }) } On Monday, 15 September 2014 20:28:28 UTC+4, Ingwie Phoenix wrote: Hai, everyone. So I just figured out that Connect’s static file servers dont work well with symlinks…so I had tow rite myself a little workaround, a fallback router, per-se. But whilst I did so, I had a nice meeting with the callback hell. Here’s my code: CDN.use(config.CDN.baseUrl, function(req, res, next){ if(err) { next(); throw err; } fs.lstat(config.base+/cdn+req.url, function(err,stats){ if(stats.isSymbolicLink()) { fs.readlink(config.base+/cdn+req.url, function(err, linkstr){ if(err) throw err; log.info(Redirecting request \+req.url+\ to \+linkstr); fs.readFile(linkstr, function(err, data){ if(err) throw err; res.writeHead(200,{Content-type:text/html}); res.end(data); }); }); } }); }); }); Okay…thats lots. And how does one get around this and into a bit of nicer code? It almost looks like a little pyramid there… Kind regards, Ingwie. -- Job board: http://jobs.nodejs.org/ New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md Old group rules: 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 unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. To post to this group, send email to nodejs@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/32603590-e433-43a9-860a-8c12fdbac3f9%40googlegroups.com. For more options, visit https://groups.google.com/d/optout. signature.asc Description: Digital Signature
Re: [nodejs] horizontal scaling with NodeJS on same physical machine
I scaled on a single machine using haproxy and thalassa. The gist of it: var http = require('http') var app = require('./app') var pkg = require('./package.json') var server = http.createServer() server.on('request', app) // Listen on port 0. This finds a random, free port. server.listen(0, funciton () { var port = server.address().port // Here you would register the port / host combination with some sort of // registry, which would dynamically update haproxy. In my case I used // thalassa. // // registry.register('myservice', pkg.version, port) // registry.start() }) What I love about this approach is that you can easily go multi-machine later down the track. On Thu, Dec 19, 2013 at 08:50:03AM -0800, Bijuv V wrote: Hi , I have a Web server with an Application developed using express. In the application we do mention the port at which the application should listen for requests. For eg 3000. If I spawn multiple node processes on the same machine, there will be a conflict on the ports. How can this be achieved (apart from the below options)? The options that Im aware of are a. Use Cluster feature of node. Everything is handled by node. Still experimental AFAIK. b. Use multiple VM's to deploy each instance c. start node on different ports - 3001 - 3008. Put a hardware LB before the same which will send the requests to one of the Node instances. - Dont want to invest on a H/W LB. I was watching the video from Ryan. http://www.youtube.com/watch?v=F6k8lTrAE2g He mentions about the limitations of node being single threaded and also talks about server file descriptors usage to build Web Servers. However, I could not get the details of how the file descriptors should be configured so that the requests go to one of the 8 instances on the machine. -- -- 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. signature.sig Description: Digital Signature
Re: [nodejs] Re: Ben Noordhuis's Departure
Sounds like the main issue was a lack of communication and trust between the core team / leadership. This breakdown led to public-which-should-have-been-private mentioning of others in commit messages and *cooperate* blog posts, in all cases were toned negatively and counter-productive. What I learned from this fiasco: * Never pull down / cast others in a negative light publicly. Always consult them in private with a professional manner. * Slow down and talk to fellow team members before making assumptions about their actions. On Tue, Dec 10, 2013 at 02:43:44AM +0100, Ben Noordhuis wrote: On Mon, Dec 9, 2013 at 9:38 PM, Ben Noordhuis i...@bnoordhuis.nl wrote: On Mon, Dec 9, 2013 at 7:29 PM, Mikeal Rogers mikeal.rog...@gmail.com wrote: On Dec 9, 2013, at 9:13AM, Jorge Chamorro jo...@jorgechamorro.com wrote: stepping over the guy who is in charge of libuv and pissing him off No part of this is accurate. On the contrary, it's 100% accurate. The reason I stepped down is not because of the Twitter brouhaha, I was unmoved by that. It's because I feel I can no longer trust Isaac to do the right thing and that makes working together impossible. I'm retracting my previous statement. After talking it through some more with Bert, it turns out that he and Isaac agreed to land the patch to avoid further commotion. I can't really reconstruct that from IRC logs but I'll take Bert's word for it. So, it seems that Isaac could have had the good grace to follow up with an email and I could have had the good grace to give him the benefit of the doubt. Isaac, for what it's worth, I'm sorry about that. -- -- 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. signature.sig Description: Digital Signature
Re: [nodejs] Node.JS for sysadmin scripting or non-web stuff - books, guides, examples?
Grunt.js is a great place to start: http://gruntjs.com/ On Thu, Nov 21, 2013 at 05:23:59PM -0800, Victor Hooi wrote: Hi, I'm curious on people's experiences with using Node.JS for sys-admin scripts or non-Web glue stuff - i.e. the sorts of things you might use Perl or Python for (e.g. log parsing, manipulating config files etc.) Is Node.JS suitable for these things? Are there any books or guides out there on these sorts of things? (Most of the books I've seen are geared to Node.JS purely as a web app language). Or any detailed examples people have posted up of what they use it for? Cheers, Victor -- -- 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. signature.sig Description: Digital Signature
Re: [nodejs] Node.js should delete __proto__ while we still have a chance (before we hit 1.0)
Please don't, `__proto__` is great if not abused. Swapping out the prototype of an object is extremely useful. function MyEventEmitter () { EventEmitter.call(this) } MyEventEmitter.prototype.__proto__ = EventEmitter.prototype Extremely easy inheritance and you don't have to mess with the constructor property etc. Also allows you to do cool things with the default constructors without messing with their prototypes. var superArrayProto = { forEach : myCustomForEachFunction } superArrayProto.__proto__ = Array.prototype function makeSuperArray (arr) { arr.__proto__ = superArrayProto return arr } var superArray = makeSuperArray([]) (myCustomForEachFunction === superArray.forEach) // true On Thu, Sep 19, 2013 at 12:35:59PM -0700, Andrew Kelley wrote: I'm sure this has been discussed before but I don't know where. Here are some facts: 1. Putting user data (and other kinds of data if you're not careful) inside an object is a huge security problem. Domenic explains this quite well in the readme of his dict module: https://github.com/domenic/dict 2. Object.getPrototypeOf() is available as a perfect substitution for __proto__. It does exactly what you want, without the security risk. 3. Developers *will* use __proto__ if it is available, and they *will* put user data in objects. Here is an opinion: DELETE IT FOREVER!! -- -- 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: Callbacks are Pretty Okay
One other rule that I use a lot, is a state object: On 21 August 2013 07:11, Mark Hahn m...@reevuit.com wrote: We are down to just opinions so I'll shut up now. On Tue, Aug 20, 2013 at 11:57 AM, Andrew Kelley superjo...@gmail.com wrote: I'm not going to remove mention of the fact that coffee-script does not support function hoisting, which is the main suggestion of the style guide. Your only algorithm change destroys the ability to put synchronous code first, followed by purely a list of function declarations, which is the very thing the article is talking about. This is a simple provable fact. I'm confused as to why you are arguing about something that is so logically obvious. On Tuesday, August 20, 2013 2:47:57 PM UTC-4, Mark Hahn wrote: I meant to show that applying this pattern without knowing what it actually does can lead to cases where it simply doesn't work. Of course if someone doesn't apply the pattern correctly it won't work. This is true for all patterns. There is nothing inherently dangerous about this one. I don't know why people have negative opinions about something simple that makes code readable. Maybe it is a bias against coffeescript in general. I am still of the strong opinion that the blog linked in the OP should be edited to remove the claim that coffeescript can't implement the pattern. I defy anyone to show me some javascript code for that pattern that I can't convert to coffeescript with the only algorithm change being to add a start call at the bottom. That call does not negate any advantages of the blog's pattern. -- -- 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] Re: Callbacks are Pretty Okay
Sorry, one more time: https://gist.github.com/tim-smart/6290338 A simple state object makes a heap of difference in terms of code nesting. I'm not too sure if it has performance implications. On 21 August 2013 16:28, Tim Smart t...@fostle.com wrote: One other rule that I use a lot, is a state object: On 21 August 2013 07:11, Mark Hahn m...@reevuit.com wrote: We are down to just opinions so I'll shut up now. On Tue, Aug 20, 2013 at 11:57 AM, Andrew Kelley superjo...@gmail.com wrote: I'm not going to remove mention of the fact that coffee-script does not support function hoisting, which is the main suggestion of the style guide. Your only algorithm change destroys the ability to put synchronous code first, followed by purely a list of function declarations, which is the very thing the article is talking about. This is a simple provable fact. I'm confused as to why you are arguing about something that is so logically obvious. On Tuesday, August 20, 2013 2:47:57 PM UTC-4, Mark Hahn wrote: I meant to show that applying this pattern without knowing what it actually does can lead to cases where it simply doesn't work. Of course if someone doesn't apply the pattern correctly it won't work. This is true for all patterns. There is nothing inherently dangerous about this one. I don't know why people have negative opinions about something simple that makes code readable. Maybe it is a bias against coffeescript in general. I am still of the strong opinion that the blog linked in the OP should be edited to remove the claim that coffeescript can't implement the pattern. I defy anyone to show me some javascript code for that pattern that I can't convert to coffeescript with the only algorithm change being to add a start call at the bottom. That call does not negate any advantages of the blog's pattern. -- -- 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.
[nodejs] Superemitter - EventEmitter prototype - Really fast!
For anyone to play around with and maybe develop further: https://gist.github.com/tim-smart/5801765 Has some benchmarks at the bottom of the file, run it and see the results :) Idea came from felixge's performance talk on the MySQL client - would love to see where this goes as a high-performance simple event-emitter. Tim -- -- 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] Superemitter - EventEmitter prototype - Really fast!
I definitely wouldn't recommend something like this if you have to create many listeners at a time - creating new listeners is quite expensive as it has to roll-out all the loops then compile the new `emit` function. Small use case, but it could be really useful for protocol parsers or the like, where you set up one bunch of listeners per 'instance'. On Tue, Jun 18, 2013 at 03:54:52AM +0300, Dan Milon wrote: `.on` seems a pretty heavy operation given that it crafts a new function every time. In the real world I assume it's a pretty hot path (take data listeners for http for example). It would be interesting to provide a real-world test, with `.on` benchmarked too. On 06/18/2013 03:38 AM, Tim Smart wrote: For anyone to play around with and maybe develop further: https://gist.github.com/tim-smart/5801765 Has some benchmarks at the bottom of the file, run it and see the results :) Idea came from felixge's performance talk on the MySQL client - would love to see where this goes as a high-performance simple event-emitter. Tim -- -- 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] meaning of the semver ~
A - true B - true C - true D - false E - true Time to look at the documentation :) On Thu, May 30, 2013 at 09:52:47PM +0200, Dominic Tarr wrote: without looking in the documentation or trying it in the repl what do you expect to be the results of these tests on semver ranges? A. semver.satisfies('~1.2.3', '1.2.4') B. semver.satisfies('~1.2', '1.3.0') C. semver.satisfies('~1.2', '1.2.6') D. semver.satisfies('1.2', '1.3.0') E. semver.satisfies('1.2', '1.2.4') please don't look at the documentation, the question is: what do you think it means? -- -- 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] Streams writev API
My vote is with B), including the amendment of uncorking automatically in the end() call. res.cork() res.writeHead(200, ...) res.end(template.render()) If corked instead of using the hot path (squashing everything into one string to write) it would use writev to combine the headers with the template blob/buffer. Tim On Mon, Apr 22, 2013 at 05:01:50PM -0700, Isaac Schlueter wrote: There's a syscall called `writev` that lets you write an array (ie, Vector) of buffers of data rather than a single buffer. I'd like to support something like this for Streams in Node, mostly because it will allow us to save a lot of TCP write() calls, without having to copy data around, especially for chunked encoding writes. (We write a lot of tiny buffers for HTTP, it's kind of a nightmare, actually.) Fedor Indutny has already done basically all of the legwork to implement this. Where we're stuck is the API surface, and here are some options. Node is not a democracy, but your vote counts anyway, especially if it's a really good vote with some really good argument behind it :) Goals: 1. Make http more good. 2. Don't break existing streams. 3. Don't make things hard. 4. Don't be un-node-ish For all of these, batched writes will only be available if the Writable stream implements a `_writev()` method. No _writev, no batched writes. Any bulk writes will just be passed to _write(chunk, encoding, callback) one at a time in the order received. In all cases, any queued writes will be passed to _writev if that function is implemented, even if they're just backed up from a slow connection. Ideas: A) stream.bulk(function() { stream.write('hello'); stream.write('world'); stream.end('!\n') }) Any writes done in the function passed to `stream.bulk()` will be batched into a single writev. Upside: - Easier to not fuck up and stay frozen forever. There is basically zero chance that you'll leave the stream in a corked state. (Same reason why domain.run() is better than enter()/exit().) Downsides: - easier to fuck up and not actually batch things. eg, s.bulk(function(){setTimeout(...)}) - bulk is a weird name. batch maybe? Nothing else really seems appropriate either. - somewhat inflexible, since all writes have to be done in the same function call B) stream.cork(); stream.write('hello'); stream.write('world'); stream.end('!\n'); stream.uncork(); Any writes done while corked will be flushed to _writev() when uncorked. Upside: - Easy to implement - Strictly more flexible than stream.bulk(writer). (Can trivially implement a bulk function using cork/uncork) - Useful for cases outside of writev (like corking a http request until the connection is established) Downsides: - Easy to fuck up and stay corked forever. - Two functions instead of just one (double the surface area increase) C) stream.writev([chunks,...], [encodings,...], callback) That is, implement a first-class top-level function called writev() which you can call with an array of chunks and an array of encodings. Upside: - No unnecessary surface area increase - NOW IT'S YOUR PROBLEM, NOT MINE, HAHA! (Seriously, though, it's less magical, simpler stream.Writable implementation, etc.) Downside: - A little bit tricky when you don't already have a list of chunks to send. (For example, with cork, you could write a bunch of stuff into it, and then uncork all at the end, and do one writev, even if it took a few ms to get it all.) - parallel arrays, ew. D) stream.writev([ {chunk:buf, encoding: blerg}, ...], callback) That is, same as C, but with an array of {chunk,encoding} objects instead of the parallel arrays. Same +/- as C, except the parallel array bit. This is probably how we'd call the implementation's stream._writev() anyway, so it'd be a bit simpler. Which of these seems like it makes the most sense to you? Is there another approach that you'd like to see here? (Note: save all writes until end of tick always and copy into one big buffer approaches are not feasible for obvious performance reasons.) -- -- 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:
Re: [nodejs] Streams writev API
Ryan did this a while back, and couldn't get it fast enough for small writes (might need some reference here) Simply put - the overhead of abstraction wasn't worth it. A lot of people using template engines are practically doing response.writeHead(200, ...); response.end(template.compile()) which doesn't need the writev fluff. Tim On 23 April 2013 14:15, Mikeal Rogers mikeal.rog...@gmail.com wrote: Is there a reason not to just have the underlying libuv *always* writev when it has more than one pending buffer to write? I'm wondering whey we can't just optimize this behind the scenes, is there a reason we need to map each stream write a write syscall? -Mikeal On Apr 22, 2013, at 5:01PM, Isaac Schlueter i...@izs.me wrote: There's a syscall called `writev` that lets you write an array (ie, Vector) of buffers of data rather than a single buffer. I'd like to support something like this for Streams in Node, mostly because it will allow us to save a lot of TCP write() calls, without having to copy data around, especially for chunked encoding writes. (We write a lot of tiny buffers for HTTP, it's kind of a nightmare, actually.) Fedor Indutny has already done basically all of the legwork to implement this. Where we're stuck is the API surface, and here are some options. Node is not a democracy, but your vote counts anyway, especially if it's a really good vote with some really good argument behind it :) Goals: 1. Make http more good. 2. Don't break existing streams. 3. Don't make things hard. 4. Don't be un-node-ish For all of these, batched writes will only be available if the Writable stream implements a `_writev()` method. No _writev, no batched writes. Any bulk writes will just be passed to _write(chunk, encoding, callback) one at a time in the order received. In all cases, any queued writes will be passed to _writev if that function is implemented, even if they're just backed up from a slow connection. Ideas: A) stream.bulk(function() { stream.write('hello'); stream.write('world'); stream.end('!\n') }) Any writes done in the function passed to `stream.bulk()` will be batched into a single writev. Upside: - Easier to not fuck up and stay frozen forever. There is basically zero chance that you'll leave the stream in a corked state. (Same reason why domain.run() is better than enter()/exit().) Downsides: - easier to fuck up and not actually batch things. eg, s.bulk(function(){setTimeout(...)}) - bulk is a weird name. batch maybe? Nothing else really seems appropriate either. - somewhat inflexible, since all writes have to be done in the same function call B) stream.cork(); stream.write('hello'); stream.write('world'); stream.end('!\n'); stream.uncork(); Any writes done while corked will be flushed to _writev() when uncorked. Upside: - Easy to implement - Strictly more flexible than stream.bulk(writer). (Can trivially implement a bulk function using cork/uncork) - Useful for cases outside of writev (like corking a http request until the connection is established) Downsides: - Easy to fuck up and stay corked forever. - Two functions instead of just one (double the surface area increase) C) stream.writev([chunks,...], [encodings,...], callback) That is, implement a first-class top-level function called writev() which you can call with an array of chunks and an array of encodings. Upside: - No unnecessary surface area increase - NOW IT'S YOUR PROBLEM, NOT MINE, HAHA! (Seriously, though, it's less magical, simpler stream.Writable implementation, etc.) Downside: - A little bit tricky when you don't already have a list of chunks to send. (For example, with cork, you could write a bunch of stuff into it, and then uncork all at the end, and do one writev, even if it took a few ms to get it all.) - parallel arrays, ew. D) stream.writev([ {chunk:buf, encoding: blerg}, ...], callback) That is, same as C, but with an array of {chunk,encoding} objects instead of the parallel arrays. Same +/- as C, except the parallel array bit. This is probably how we'd call the implementation's stream._writev() anyway, so it'd be a bit simpler. Which of these seems like it makes the most sense to you? Is there another approach that you'd like to see here? (Note: save all writes until end of tick always and copy into one big buffer approaches are not feasible for obvious performance reasons.) -- -- 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
Re: [nodejs] Simple Node/Redis Taskqueue
You might want to give us a link to the code? On 13 April 2013 09:34, Tom Dunn tidun...@gmail.com wrote: Hello all! I am somewhat new here, but have been using nodejs and javascript in general for some time now. I needed a way to distribute task created by an initiator to some number of workers. This is a quick prototype that I hacked together yesterday. If anyone has any feedback to give, I would greatly appreciate it. Specifically I am looking for feedback regarding my design, and whether or not there is interest in this. Thanks! Tom -- -- 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] ctags/jsctags alternatives?
I have ended up creating some custom ctags patterns. Nothing fancy but enough to jump around files in vim. https://gist.github.com/414e59e28b84e0fa07f2 Tim. On Sun, Mar 17, 2013 at 03:41:28PM -0700, Jeffrey Law wrote: Hi, I just started node.js development. I have been using vim casually. I love the vim for the flexibility and speed. I heard lots of good things using vim for node.js but vim doesnt seem to be good at navigating through javascript objects (jump to another source file for a method/class definition, etc). That is pretty important for me, esp picking up and learning a new open source framework and I have got used to IDE like IDEA. It can speed things up a lot when I need to know which source file a method is from, e. I understand this is not an easy feat with Javascript given the dynamic nature. I have tried doctorjs but it's too buggy to deal with. Ctags doesnt seem to do well with Javascript either. Am I out of choices? Or maybe there are different approaches in navigating javascript objects that I'm not aware of?? Any helps would be greatly appreciated... Thx. J -- -- 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: [ANN] then-redis - A small, promise-based Redis client for node.js
Another client you can include in your benchmarks etc. https://github.com/tim-smart/node-redis I'm a fan of the standard callback style as it plays nice with all the control flow libraries. Tim. On 16 March 2013 17:26, Michael Jackson mjijack...@gmail.com wrote: Hi Chaoran, Thanks for asking this. I haven't had very much time to optimize the code yet, but I thought I should go ahead and run a benchmark anyway just to know what neighborhood I'm in. I copied and pasted the benchmark that node_redis uses into then-redis and made a few tweaks to make it work with then-redis. You can see the results in the benchmarks branch up on GitHub. FWIW, I ran the benchmarks on my MacBook Air 1.7 GHz running node 0.10.0 and Redis 2.9.7. The mean difference in ops/sec between then-redis and node_redis right now is ~5,000. There are quite a few benchmarks where then-redis seems to be faster, especially when the pipeline is small. It seems I have some room for improvement when there are lots of commands in the pipeline. Overall though I think the results are pretty encouraging. As with most benchmarks, take them with a grain of salt. These things are hard to get down to a science. :) -- Michael Jackson @mjackson On Wed, Mar 13, 2013 at 11:50 AM, Chaoran Yang chaoran.y...@gmail.com wrote: It would be good if you can show some performance results, comparing with node_redis. What is the overhead like using promises? -Chaoran On Thursday, March 7, 2013 11:16:29 AM UTC-6, Michael Jackson wrote: :D Thanks David. I've been programming almost exclusively in promises these past few months and it feels pretty good. Plus, I'm a big believer in tiny modules and simple code bases. Helps me grok them a bit easier when they're small. Also, thanks for your work on node_redis! -- Michael Jackson @mjackson On Wed, Mar 6, 2013 at 8:54 PM, DTrejo dtr...@cs.brown.edu wrote: Redis is 300 LOC!? ;) Cheers and good to have some competition to make us node_redis maintainers get into gear. D On Wednesday, March 6, 2013 1:23:25 PM UTC-5, Michael Jackson wrote: Hello, then-redis is a small, promise-based Redis client for node.js that I've been working on over the past few weeks. It supports all the features of Redis in a simple, user-friendly package. I thought others might enjoy using it as well, so I released the source this morning. https://github.com/mjijackson/then-redis The two major differences between then-redis and node_redis are: 1. then-redis returns a promise when you issue a command 2. The entire codebase is very small (~300 LOC), just like Redis Other than that the APIs are very similar. If you're using Redis and you enjoy promise-style programming please check it out and let me know what you think. Install it: npm install then-redis Enjoy! -- Michael Jackson @mjackson -- -- 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 To unsubscribe from this group, send email to nodejs+un...@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+un...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups Redis DB group. To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+unsubscr...@googlegroups.com. To post to this group, send email to redis...@googlegroups.com. Visit this group at http://groups.google.com/group/redis-db?hl=en. 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
Re: [nodejs] Missing execSync in NodeJS
Callback hell is a place you decide to go on your own. I'm not following you down there... Here is an alternative example made in callback heaven, where we embrace asyncronous control flow like our first-born: var async = require('async-array').async var fs= require('fs') var spawn = require('child_process').spawn fs.readdir('/my/amazing/directory/', function (err, filenames) { if (err) throw err async(filenames) // Only keep files .filter(function (filename, i, next) { fs.lstat(filename, function (err, stat) { if (err) return next(err) next(null, stat.isFile()) }) }) // Pipe files to my-awesome-process .forEach(function (filename, i, next) { var awesome = spawn('my-awesome-process') fs.createReadStream(filename).pipe(awesome.stdin) awesome.on('exit', next) }) // Run it .exec(function (err) { if (err) throw err console.log('All done') }) }) I encourage you to try make your own control flow library. It helps you to get your head around callbacks and all that jazz. Tim On Thu, Mar 14, 2013 at 01:32:18PM -0700, Sebi wrote: Many functions in NodeJS have a Sync pendant to the non-blocking functions. Why is there no blocking pendant in the child_process module? I've giving up as I tried to iterate over a directory and call for every file child.exec how should my app now, that every process completed his task? I'm going to run in trouble, because to use a timer to check that seems to be not a powerful resolution. Think there should be a sync pendant in the core child module Sometimes you're going to the callback hell... -- -- 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] Version 0.10.0 (Stable)
A huge thanks to all of the ladies and gentlemen who contribute to node.js in some way or another! Whether documentation, converting work-mates or hacking the code itself; I can't just shake off the bit of pride I have in using a tool that is built upon the work of excellent people. Keep it up, and endure the bug reports for 0.10 (The days to come) Tim On Mon, Mar 11, 2013 at 09:05:39AM -0700, Isaac Schlueter wrote: I am pleased to announce a new stable version of Node. This branch brings significant improvements to many areas, with a focus on API polish, ease of use, and backwards compatibility. For a very brief overview of the relevant API changes since v0.8, please see the API changes wiki page: https://github.com/joyent/node/wiki/Api-changes-between-v0.8-and-v0.10 For a more thorough breakdown of what changed, you can read the blog post on this release: http://blog.nodejs.org/2013/03/11/node-v0-10-0-stable/ (It would not fit comfortably in an email this time.) Thank you very much to everyone who helped bring this to fruition, especially those of you who have been using streams2 in your modules, and banging away on the unstable releases. Node's continued progress and stability depends on your input. And now, the traditional release notes: 2013.03.11, Version 0.10.0 (Stable) * npm: Upgrade to 1.2.14 * core: Append filename properly in dlopen on windows (isaacs) * zlib: Manage flush flags appropriately (isaacs) * domains: Handle errors thrown in nested error handlers (isaacs) * buffer: Strip high bits when converting to ascii (Ben Noordhuis) * win/msi: Enable modify and repair (Bert Belder) * win/msi: Add feature selection for various Node parts (Bert Belder) * win/msi: use consistent registry key paths (Bert Belder) * child_process: support sending dgram socket (Andreas Madsen) * fs: Raise EISDIR on Windows when calling fs.read/write on a dir (isaacs) * unix: fix strict aliasing warnings, macro-ify functions (Ben Noordhuis) * unix: honor UV_THREADPOOL_SIZE environment var (Ben Noordhuis) * win/tty: fix typo in color attributes enumeration (Bert Belder) * win/tty: don't touch insert mode or quick edit mode (Bert Belder) Source Code: http://nodejs.org/dist/v0.10.0/node-v0.10.0.tar.gz Macintosh Installer (Universal): http://nodejs.org/dist/v0.10.0/node-v0.10.0.pkg Windows Installer: http://nodejs.org/dist/v0.10.0/node-v0.10.0-x86.msi Windows x64 Installer: http://nodejs.org/dist/v0.10.0/x64/node-v0.10.0-x64.msi Windows x64 Files: http://nodejs.org/dist/v0.10.0/x64/ Linux 32-bit Binary: http://nodejs.org/dist/v0.10.0/node-v0.10.0-linux-x86.tar.gz Linux 64-bit Binary: http://nodejs.org/dist/v0.10.0/node-v0.10.0-linux-x64.tar.gz Solaris 32-bit Binary: http://nodejs.org/dist/v0.10.0/node-v0.10.0-sunos-x86.tar.gz Solaris 64-bit Binary: http://nodejs.org/dist/v0.10.0/node-v0.10.0-sunos-x64.tar.gz Other release files: http://nodejs.org/dist/v0.10.0/ Website: http://nodejs.org/docs/v0.10.0/ Documentation: http://nodejs.org/docs/v0.10.0/api/ Shasums: ``` b9e9bca99cdb5563cad3d3f04baa262e317b827c node-v0.10.0-darwin-x64.tar.gz 0227c9bc3df5b62267b9d4e3b0a92b3a70732229 node-v0.10.0-darwin-x86.tar.gz 9f5f7350d6f889ea8e794516ecfea651e8e53d24 node-v0.10.0-linux-x64.tar.gz cc5f1cd6a2f2530bc400e761144bbaf8fcb66cc4 node-v0.10.0-linux-x86.tar.gz 42c14b7eab398976b1ac0a8e6e96989059616af5 node-v0.10.0-sunos-x64.tar.gz ddcadbac66d1acea48aa6c5462d0a0d7308ea823 node-v0.10.0-sunos-x86.tar.gz 70eacf2cca7abec79fac4ca502e8d99590a2108a node-v0.10.0-x86.msi c48c269b9b0f0a95e6e9234d4597d1c8a1c45c5a node-v0.10.0.pkg 7321266347dc1c47ed2186e7d61752795ce8a0ef node-v0.10.0.tar.gz f8c6f55469551243ea461f023cc57c024f57fef2 node.exe 253ae79e411fcfddcf28861559ececb4b335db64 node.exp acb8febb5ea714c065f201ced5423b0838fdf1b6 node.lib 0fdad1400036dd26d720070f783d3beeb3bb9c0a node.pdb abcaf8ef606655a05e73ee5d06715ffd022aad22 x64/node-v0.10.0-x64.msi e5d0c235629b26430b6e07c07ee2c7dcda82f35e x64/node.exe 43b3fb3a6aaf6a04f578ee607a9455c1e23acf08 x64/node.exp 87dd6eb6c8127a1af0dcca639961441fc303d75a x64/node.lib 50aca715777fa42b854e6cfc56b6199a54aabd3c x64/node.pdb ``` -- -- 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] NPM Packages
What happens if two apps requires different versions of the same dependency? Install the dependency locally for that specific app? Tim On Tue, Mar 05, 2013 at 09:36:11AM -0800, Sergey Shteyn wrote: Hi, I was wondering if anybody can help me with a project. I have a large project with different apps in different directories. Each app it's own package.son file. I would like to install the packages for all the apps into a root directory of my project with npm install. Is this possible and good practice? Thanks, Sergey -- -- 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] node-redis blocking question
When you refer to 'node-redis', I assume you mean the npm 'redis' library and not the 'node-redis' one? subclient.on('message', function () { ... }) subclient.subscribe('channel', function (err) { if (err) throw err redisclient.publish('channel', 'data') }) As Micheil was saying, don't go using pub/sub if you need any retention; but that isn't really in scope with your question. The 'subscribe' command in redis essentially soft-blocks the redis-client. Reason behind this is so the 1-command-to-reply in-and-out standard non-blocking redis commands don't screw up when you (possibly) have a multitude of messages coming down the pipe as a result of one subscribe command. Tim. On 25 January 2013 21:41, Stefan Zehe s.z...@upjers.com wrote: Am 24.01.2013 18:46, schrieb Micheil Smith: Hi Stefan, Due to how redis works, calling subscribe() will block that connection to redis, however, your library may do fancy connection management under the hood. It's recommend to use one connection for subscribe's and another for everything else. I do use a second connection for calling publish (redis2.publish()). But is redis1 already successfully subscribed to channel 'foo' when redis2.publish is called? redis1.on('message', function Trigger(res) { console.log(res); } redis1.subscribe('foo'); redis2.publish('foo', 'bar'); -- -- 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 -- -- 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] [ANN] catcher - tiny, flow-less
I usually have have something like this at the top of my callbacks. function mycallback (err, data) { if (err) return onerror(err) dosomestuffwith(data) } `onerror` is usually a callback passed by express, or something I write in a utilities file / at the top of the file. Tim. On Thu, Jan 10, 2013 at 02:26:00AM -0800, Stuart P. Bentley wrote: Hey guys, new(ish) to Node, first time posting. I made an npm account shortly after I started for programming, but I haven't written anything that really called for a reusable npm package until now. So, the code I'm writing doesn't use any flow-control/promise-chain libraries like seq or step or q or first or async or queue-async (although I have used the last one a little). However, it still has a few callbacks, and it rarely (if ever) cares about what to do if there's an error (other than panic, of course). Anyway, to avoid endless if(err){console.error(err)} else { typing, I found myself copy-pasting something like this at the top of all my scripts to wrap all my callbacks in: function errorHandlingCb(errCb){ return function onSuccess(successCb){ return function(err) { if (err) { errCb(err); } else { successCb.apply(this,Array.prototype.slice.call(arguments,1)); } } } (or some variant on the onSuccess function with console.error or throw err) Eventually I started writing something with its functionality spread across files, got tired of having the same 7-9 lines in multiple files in one project (let alone across multiple projects, and decided I'd turn it into a module: https://github.com/stuartpb/catcher/blob/master/index.js I reset my npm password (which I'd unsurprisingly forgotten) and published it: https://npmjs.org/package/catcher What do you think? I don't know if I'm replicating some existing thing, or if I've overlooked something, or made some assumption I shouldn't. Here are some ideas I have for 0.2: - errorize any non-Error strings / objects (to amerliorate the problems detailed in http://www.devthought.com/2011/12/22/a-string-is-not-an-error/) by replacing line 5 with this: if (err instanceof Error) ecb(err); else ecb(new Error(err)); - dropp throwNewErr (in light of the above change) - New functions oriented toward different combinations of wrapping the method and error handler for calling the method with the success callback, rather than just wrapping the error handler, then the success callback, then using that in the method -- 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 -- 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
Re: [nodejs] Waiting for two Mysql Functions?
Hello. If you spend enough time in node.js you will eventually run into the need of a control flow library. Creating your own control flow library is almost the hello world of node.js. My library is called async-array. var async = require('async-array').async var mysql = require('mysql').createConnection() mysql.connect() function mysqlmap (query, i, next) { mysql.query(query, next) } function mysqldone (err, results) { // OMG There was an error somewhere. Handle it houston. if (err) throw err // Change results from an AsyncArray back to a normal array. results.array() // Results are mapped to the same place as the query. results[0] results[1] } async( [ 'SELECT * FROM my_ultimate_table' , 'SELECT bacon FROM the_fridge' ] ) .map(mysqlmap) .exec(mysqldone) It tries to keep the basic semantics of a normal array, adding some asyncronous magic. https://github.com/tim-smart/async-array Tim. On Tue, Dec 25, 2012 at 09:14:27AM -0800, Joman Sierra wrote: I have this scenario: function one { Makes a query to a big mysql table } Function two { Makes another query to a big myslq table } res.render(showing results of the queries) The problem is that when render is executed the mysql queries are still in progress. What's the best way to be sure that the functions has finished before sending the render? -- 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 -- 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
Re: [nodejs] How to set up a Node.js server to work with PHP?
Hi, If it were me, I would use some sort of central work queue / event system to push messages to the node processes. Redis pubsub is a good example. You could then from php push a message to the node server, which would then update the client with socket.io or something of the like. Tim. On Wed, Dec 12, 2012 at 09:09:12PM -0800, Kay wrote: Hello there, Our site is running on PHP/Apache. How should we set up an additional Node.js server along side, that will allow the PHP portion to co-work seamlessly with the Node.js part? For example - a logged-in user opens up 3 browser tabs of our site, then proceed to log out from our site in one of the browser tabs. How to make it so that when logout.php is about to finish running, it calls for Node.js to push out a signal to the client-side (either via long-polling or WebSocket), to allow the other 2 remaining tabs' JavaScript know of the logout event as well? Since I need to convince my supervisor, it needs to be a robust and secure enough solution. What I currently have in mind is a vague putting Node.js behind an Nginx reverse proxy on a separate machine other than the PHP one idea, but then I have no further clue on how to link up PHP with Node.js, and how to persuade our MIS personnel. Hope can get some helps or directions, thanks! -- 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 -- 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
Re: [nodejs] Re: Can you build a CMS in 14 days? $10,000 Prize
I think I can help you out here. Here is what I think you wanted / should have said: Hey node.js folks, I am looking to employ someone to work on a tailored CMS solution for my business. You will have a 14 day deadline and a $10,000 budget payed out in negotiable installments. If you are interested or have further inquires please send me a e-mail on a private channel (j...@compamy.com) I am open to recommendations to other CMS solutions I might have missed. Thanks for your time. A professional, concise and no-nonsense tone will get you professional, concise and no-nonsense responses. Try to avoid words like 'ninja' and other l337 things when trying to attract good developers. I wish you luck with your endeavours. On Fri, Jul 13, 2012 at 10:47:45PM -0700, Marak Squires wrote: I don't think you will find anyone that can help you here. Come back when you are either: a) Serious b) Not running a scam Good luck. On Fri, Jul 13, 2012 at 10:28 PM, Joseph Khoury kjoseph...@gmail.comwrote: Hehehe 10/14 +10/14 + ... = 10k over a 14 days period You'r having fun, e? hourly*8 hours * 14 becomes daily. No one will pay you for your hourly rates every 60 minutes. You will get paid either at the end of the day or week depending on what you agree on. Maybe someone will: Hey, 60 minutes passed already. Let us take a break and let me pay you for your hour! Thank you I am answering you because I am enjoying the silliness of this conversation :) for me prize = reward = something you get for something you did enough on this. Now seriously, I am looking for a node.js Ninja. (Note to Az ;) On Fri, Jul 13, 2012 at 8:32 PM, Mark Hahn m...@hahnca.com wrote: I'm so confused. On Fri, Jul 13, 2012 at 7:22 PM, Martín Ciparelli mcipare...@gmail.com wrote: For Christ sake Marak you ARE REALLY bad at math, do you see it now? Lol El 13/07/2012 22:30, Marak Squires marak.squi...@gmail.com escribió: Waithow does 1k a day for 14 days add up to 10k? That IS hard to understand. On Fri, Jul 13, 2012 at 6:13 PM, Joseph Khoury kjoseph...@gmail.com wrote: How hard is it for you to understand 1k a day for 14 days 1+1+1+ ...+1 = 14 no one will wait until the end of day 14 to get paid. This is an hourly, daily contract with a minimum of 14 days availability commitment. I appreciate helpful feedback or guidance into the right direction, like Olag's comment On Fri, Jul 13, 2012 at 5:10 PM, mgutz mario.l.gutier...@gmail.com wrote: I'll take the challenge if you pay $9,999 up front. I trust you're good for the other $1. On Thursday, July 12, 2012 11:22:49 PM UTC-7, HackerOUT wrote: Hi, We want a CMS built with node.js. We checked what's available and they are too basic. We want something that's easy to use but has minimum functionality. in place editing collaboration revisions roles ( editors, admins ... ) template based What do you think? Can you do it? 2 JavaScript Ninjas are ready to work on it. Are you willing to be the 3rd and lead? 10K in 14 days, Bonus for extra features. Regards, Joseph -- 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 -- 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 -- 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 -- 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
Re: [nodejs] Re: Can you build a CMS in 14 days? $10,000 Prize
Well, I'll only call someone a 'turd' after I have worked with them and found it out the hard way. I can't really judge someone over discussion on a mailing list. Tim. On Fri, Jul 13, 2012 at 11:34:31PM -0700, Marak Squires wrote: If you place a turd in box with nice wrapping paper, it's still going be a turd after you open it up. On Fri, Jul 13, 2012 at 11:32 PM, Tim Smart t...@fostle.com wrote: I think I can help you out here. Here is what I think you wanted / should have said: Hey node.js folks, I am looking to employ someone to work on a tailored CMS solution for my business. You will have a 14 day deadline and a $10,000 budget payed out in negotiable installments. If you are interested or have further inquires please send me a e-mail on a private channel (j...@compamy.com) I am open to recommendations to other CMS solutions I might have missed. Thanks for your time. A professional, concise and no-nonsense tone will get you professional, concise and no-nonsense responses. Try to avoid words like 'ninja' and other l337 things when trying to attract good developers. I wish you luck with your endeavours. On Fri, Jul 13, 2012 at 10:47:45PM -0700, Marak Squires wrote: I don't think you will find anyone that can help you here. Come back when you are either: a) Serious b) Not running a scam Good luck. On Fri, Jul 13, 2012 at 10:28 PM, Joseph Khoury kjoseph...@gmail.com wrote: Hehehe 10/14 +10/14 + ... = 10k over a 14 days period You'r having fun, e? hourly*8 hours * 14 becomes daily. No one will pay you for your hourly rates every 60 minutes. You will get paid either at the end of the day or week depending on what you agree on. Maybe someone will: Hey, 60 minutes passed already. Let us take a break and let me pay you for your hour! Thank you I am answering you because I am enjoying the silliness of this conversation :) for me prize = reward = something you get for something you did enough on this. Now seriously, I am looking for a node.js Ninja. (Note to Az ;) On Fri, Jul 13, 2012 at 8:32 PM, Mark Hahn m...@hahnca.com wrote: I'm so confused. On Fri, Jul 13, 2012 at 7:22 PM, Martín Ciparelli mcipare...@gmail.com wrote: For Christ sake Marak you ARE REALLY bad at math, do you see it now? Lol El 13/07/2012 22:30, Marak Squires marak.squi...@gmail.com escribió: Waithow does 1k a day for 14 days add up to 10k? That IS hard to understand. On Fri, Jul 13, 2012 at 6:13 PM, Joseph Khoury kjoseph...@gmail.com wrote: How hard is it for you to understand 1k a day for 14 days 1+1+1+ ...+1 = 14 no one will wait until the end of day 14 to get paid. This is an hourly, daily contract with a minimum of 14 days availability commitment. I appreciate helpful feedback or guidance into the right direction, like Olag's comment On Fri, Jul 13, 2012 at 5:10 PM, mgutz mario.l.gutier...@gmail.com wrote: I'll take the challenge if you pay $9,999 up front. I trust you're good for the other $1. On Thursday, July 12, 2012 11:22:49 PM UTC-7, HackerOUT wrote: Hi, We want a CMS built with node.js. We checked what's available and they are too basic. We want something that's easy to use but has minimum functionality. in place editing collaboration revisions roles ( editors, admins ... ) template based What do you think? Can you do it? 2 JavaScript Ninjas are ready to work on it. Are you willing to be the 3rd and lead? 10K in 14 days, Bonus for extra features. Regards, Joseph -- 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 -- 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
Re: [nodejs] Re: Can you build a CMS in 14 days? $10,000 Prize
Haha well I'll say no more. I bow down to your superior internet skills. On Fri, Jul 13, 2012 at 11:50:15PM -0700, Marak Squires wrote: I can, and it's worked out pretty well for me so far. On Fri, Jul 13, 2012 at 11:40 PM, Tim Smart t...@fostle.com wrote: Well, I'll only call someone a 'turd' after I have worked with them and found it out the hard way. I can't really judge someone over discussion on a mailing list. Tim. On Fri, Jul 13, 2012 at 11:34:31PM -0700, Marak Squires wrote: If you place a turd in box with nice wrapping paper, it's still going be a turd after you open it up. On Fri, Jul 13, 2012 at 11:32 PM, Tim Smart t...@fostle.com wrote: I think I can help you out here. Here is what I think you wanted / should have said: Hey node.js folks, I am looking to employ someone to work on a tailored CMS solution for my business. You will have a 14 day deadline and a $10,000 budget payed out in negotiable installments. If you are interested or have further inquires please send me a e-mail on a private channel (j...@compamy.com) I am open to recommendations to other CMS solutions I might have missed. Thanks for your time. A professional, concise and no-nonsense tone will get you professional, concise and no-nonsense responses. Try to avoid words like 'ninja' and other l337 things when trying to attract good developers. I wish you luck with your endeavours. On Fri, Jul 13, 2012 at 10:47:45PM -0700, Marak Squires wrote: I don't think you will find anyone that can help you here. Come back when you are either: a) Serious b) Not running a scam Good luck. On Fri, Jul 13, 2012 at 10:28 PM, Joseph Khoury kjoseph...@gmail.com wrote: Hehehe 10/14 +10/14 + ... = 10k over a 14 days period You'r having fun, e? hourly*8 hours * 14 becomes daily. No one will pay you for your hourly rates every 60 minutes. You will get paid either at the end of the day or week depending on what you agree on. Maybe someone will: Hey, 60 minutes passed already. Let us take a break and let me pay you for your hour! Thank you I am answering you because I am enjoying the silliness of this conversation :) for me prize = reward = something you get for something you did enough on this. Now seriously, I am looking for a node.js Ninja. (Note to Az ;) On Fri, Jul 13, 2012 at 8:32 PM, Mark Hahn m...@hahnca.com wrote: I'm so confused. On Fri, Jul 13, 2012 at 7:22 PM, Martín Ciparelli mcipare...@gmail.com wrote: For Christ sake Marak you ARE REALLY bad at math, do you see it now? Lol El 13/07/2012 22:30, Marak Squires marak.squi...@gmail.com escribió: Waithow does 1k a day for 14 days add up to 10k? That IS hard to understand. On Fri, Jul 13, 2012 at 6:13 PM, Joseph Khoury kjoseph...@gmail.com wrote: How hard is it for you to understand 1k a day for 14 days 1+1+1+ ...+1 = 14 no one will wait until the end of day 14 to get paid. This is an hourly, daily contract with a minimum of 14 days availability commitment. I appreciate helpful feedback or guidance into the right direction, like Olag's comment On Fri, Jul 13, 2012 at 5:10 PM, mgutz mario.l.gutier...@gmail.com wrote: I'll take the challenge if you pay $9,999 up front. I trust you're good for the other $1. On Thursday, July 12, 2012 11:22:49 PM UTC-7, HackerOUT wrote: Hi, We want a CMS built with node.js. We checked what's available and they are too basic. We want something that's easy to use but has minimum functionality. in place editing collaboration revisions roles ( editors, admins ... ) template based What do you think? Can you do it? 2 JavaScript Ninjas are ready to work on it. Are you willing to be the 3rd and lead? 10K in 14 days, Bonus for extra features. Regards, Joseph -- 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
Re: [nodejs] Re: Can you build a CMS in 14 days? $10,000 Prize
OK now this thread is getting personal. I'm out of here. Please don't drag someones past actions into a (sort of) professional argument. Not cool on both sides of the internet. Tim. On Fri, Jul 13, 2012 at 11:53:12PM -0700, Joseph Khoury wrote: Marak, What did you feel when people accused you of things that you did not do? Until someone had a deeper look and made it clearer. https://gist.github.com/716164 -- 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 -- 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
Re: [nodejs] Can you build a CMS in 14 days? $10,000 Prize
He should do what theoatmeal.com did with the Bear Love Good, Cancer Bad project. http://theoatmeal.com/blog/charity_money Tim On Fri, Jul 13, 2012 at 03:18:49PM -0700, Marak Squires wrote: I hope that I have answered your concerns, You haven't at all. Based on these emails I'm going to predict with a high certainty that any developers who choose to work on this project will not get paid. No legitimate development shop would be pitching a development position like this. If you are paying 14k for one developer out of three, logically I'd have to infer your total budget has to be greater then 14k ( assuming you will pay the other developers and yourself ). In reality it's unlikely any legitimate client would agree to pay so much money for something that is already freely available, particularly from a non-existent development shop. If a budget actually exists for this project, it's doubtful it will ever be paid out. On Fri, Jul 13, 2012 at 11:07 AM, HackerOUT kjoseph...@gmail.com wrote: Hi Thank you for your reply and feedback. You'r right it doesn't sound right. What I mean is this: We need to create a customized CMS. It would take us almost the same time to customize the free available ones which are bulky. We are looking for a very slim cms that we can add features too. WordPress, Joomla are good but we can not use PHP. The payment is not a promise of payment in 14 days, but a contract paid in parts during the work until the end of the 14 days. The point was that in 14 days you'll make the 10k and not after the 14 days We are a small consulting company with a small team. Details, contact and contract will be shared with those who are really interested. I hope that I have answered your concerns, Joseph -- 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 -- 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 -- 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
Re: [nodejs] [off] how to convince my boss to invest on realtime technologies
First you should probably convince us why you need real-time technology. If you want reasons to use node, then this topic has come up before. Some common reasons are: - Node has a great community that attracts lots of smart people - Which leads on to `npm` and how node has sane package management. - One language for both browser and server. - Fast for *some* things. Reasons you shouldn't use node: - You don't have the resources (time and $) to hire node people. Remember node isn't as commonplace as Java. - To rewrite you entire application. While this might sound cool, you will find out the hard way it isn't. - To write a load balancer or a simple file server; or something that has already been done better (eg. haproxy or nginx) or could be done better in another technology. These lists are definitely not non-exhaustive, but really what I am trying to say is don't use node just because it is cool. Think and think again and make sure you use the right tool for the job. Tim. On 12 July 2012 23:20, Arunoda Susiripala arunoda.susirip...@gmail.comwrote: Hi, This question is bit off topic. Im from a company where we build some cloud based tools for a local telecommunication providers. Basically we are building developer tools which reside on the cloud. I need to convince my management to allocate resources for realtime web technologies. Specially on *Socket.IO *and Some Cloud Services like *Pubnub.* * * I need your thoughts what are the best way to convince my upper management. Thanks. -- 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 -- 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
Re: [nodejs] Pubsub Redis concerns for MMO game
Hello, I would definitely recommend just adding one listener and doing all your routing from there. Something like: redis.subscribe('channel1') redis.subscribe('channel2') redis.on('message', function (channel, message) { // emitter.emit(channel, message) // // -or // // if (methods[channel]) methods[channel](message) // // -or // // switch (channel) { // case 'channel1': // break // case 'channel2': // break // } }) The main reason being no matter how many clients you have, they will all receive the same messages as each other; which means your clients will be doubling up on emit operations. Tim On Fri, Jul 13, 2012 at 11:43:25AM +0700, hd nguyen wrote: Hi all, I have a concern when using pubsub mechanism of redis in my real application. I built a MMO game with 5 servers (NodeJs) and use pubsub of Redis to broadcast game state between servers. But I concern which is the best practice to utilize this mechanism efficiently with a lot of users connect and interact simultaneously? I would love to hear your ideas about following problems: 1/ Should I create NEW channel for each action or just ONE channel for ALL actions? Ex: user1 connect to server1, user2-server2,...userN-serverN When user1 move/fight and lost his health, those action should be broadcast to other servers, so each time want to broadcast I should use: pub1.publish(pub1, action data sent from pub1); //just one channel for ALL actions OR pub1.publish(pub1_actionID, action data sent from pub1); // each channel for EACH action 2/ And in each servers we create a client to listen: //subscribe ALL channels from ALL OTHER servers client = redis.createClient(port, host); client.subscribe(pub1); client.subscribe(pub2); client.subscribe(pubN); client.on(message, function(channel, message){ console.log(host + : + channel + : + message); }); As above snippet code, each server should be a client to listen ALL CHANNELS published by ALL other servers. But I concern whether I should use just ONE client to listen ALL channels or ONE client for EACH channel? //each subscribe for each channel client1 = redis.createClient(port, host); client2 = redis.createClient(port, host); client1.subscribe(pub1); client2.subscribe(pub2); client1.on(message, function(channel, message){ console.log(host + : + channel + : + message); }); client2.on(message, function(channel, message){ console.log(host + : + channel + : + message); }); ... 3/ Could you tell me how many connections redis can handle maximum in a second? (each time we createClient() we should create a connection to Redis server, right? Does it take a lot of time and overhead?) 4/ Any tool to evaluate performance of pubsub mechanism for a MMO game with multiple requests at the same time? Thanks for your time. -- Nguyen Hai Duy Mobile : 0914 72 1900 Yahoo: nguyenhd_lucky -- 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 -- 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
Re: [nodejs] Pubsub Redis concerns for MMO game
The `npm install redis` client has a (very generalised) throughput of around 50k messages per second. If you think that will be a ceiling for you, then client pooling might become an option. Another alternative is a redis client I made that can roughly double the performance for small messages. Take a look at https:/github.com/tim-smart/node-redis if this interests you. Tim. On Fri, Jul 13, 2012 at 12:29:22PM +0700, hd nguyen wrote: Thanks Tim for your suggestion about subscriber part. Any suggestions for publisher part(one publisher for each ACTION or one publisher for ALL ACTION)? I want to hear about it. Thanks. On Fri, Jul 13, 2012 at 12:07 PM, Tim Smart t...@fostle.com wrote: Hello, I would definitely recommend just adding one listener and doing all your routing from there. Something like: redis.subscribe('channel1') redis.subscribe('channel2') redis.on('message', function (channel, message) { // emitter.emit(channel, message) // // -or // // if (methods[channel]) methods[channel](message) // // -or // // switch (channel) { // case 'channel1': // break // case 'channel2': // break // } }) The main reason being no matter how many clients you have, they will all receive the same messages as each other; which means your clients will be doubling up on emit operations. Tim On Fri, Jul 13, 2012 at 11:43:25AM +0700, hd nguyen wrote: Hi all, I have a concern when using pubsub mechanism of redis in my real application. I built a MMO game with 5 servers (NodeJs) and use pubsub of Redis to broadcast game state between servers. But I concern which is the best practice to utilize this mechanism efficiently with a lot of users connect and interact simultaneously? I would love to hear your ideas about following problems: 1/ Should I create NEW channel for each action or just ONE channel for ALL actions? Ex: user1 connect to server1, user2-server2,...userN-serverN When user1 move/fight and lost his health, those action should be broadcast to other servers, so each time want to broadcast I should use: pub1.publish(pub1, action data sent from pub1); //just one channel for ALL actions OR pub1.publish(pub1_actionID, action data sent from pub1); // each channel for EACH action 2/ And in each servers we create a client to listen: //subscribe ALL channels from ALL OTHER servers client = redis.createClient(port, host); client.subscribe(pub1); client.subscribe(pub2); client.subscribe(pubN); client.on(message, function(channel, message){ console.log(host + : + channel + : + message); }); As above snippet code, each server should be a client to listen ALL CHANNELS published by ALL other servers. But I concern whether I should use just ONE client to listen ALL channels or ONE client for EACH channel? //each subscribe for each channel client1 = redis.createClient(port, host); client2 = redis.createClient(port, host); client1.subscribe(pub1); client2.subscribe(pub2); client1.on(message, function(channel, message){ console.log(host + : + channel + : + message); }); client2.on(message, function(channel, message){ console.log(host + : + channel + : + message); }); ... 3/ Could you tell me how many connections redis can handle maximum in a second? (each time we createClient() we should create a connection to Redis server, right? Does it take a lot of time and overhead?) 4/ Any tool to evaluate performance of pubsub mechanism for a MMO game with multiple requests at the same time? Thanks for your time. -- Nguyen Hai Duy Mobile : 0914 72 1900 Yahoo: nguyenhd_lucky -- 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 -- 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 -- Nguyen Hai Duy Mobile : 0914 72 1900 Yahoo: nguyenhd_lucky -- Job Board: http://jobs.nodejs.org/ Posting
Re: [nodejs] npm install redis error
I'm pretty sure that is just a warning. You don't need hiredis to use the redis module. The last line of the output says that redis@0.7.2 was installed into ../node_modules. Tim. On Tuesday, 10 July 2012, hd nguyen wrote: Hi, I'm using windows 7 64 bit, nodeJs 0.8.1 and intend to create a simple example about pub/sub with Redis. But now I cannot install nodejs redis module to use, get error when executing: *npm install redis* or *npm install hiredis* * * *[image: Inline image 1] * * * Not sure anything wrong here, so appreciate your help a lot to figure it out. Thanks in advance. -- Nguyen Hai Duy Mobile : 0914 72 1900 Yahoo: nguyenhd_lucky -- 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.comjavascript:_e({}, 'cvml', 'nodejs@googlegroups.com'); To unsubscribe from this group, send email to nodejs+unsubscr...@googlegroups.com javascript:_e({}, 'cvml', 'nodejs%2bunsubscr...@googlegroups.com'); For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en -- 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 image.png