News for hackers. Stuff that matters.
Re:Fixing the callback spaghetti in node.js by skrebbel on Thursday September 29, 2011 @03:13AM (#3051475)
This kind of stuff always makes me doubt why particular stacks are the most popular.

Wondering, is the OpenResty solution otherwise single-threaded-with-an-eventloop much like node?

Re:Fixing the callback spaghetti in node.js by justincormack on Thursday September 29, 2011 @03:30AM (#3051506)
Well, you can configure how many processes nginx runs with at startup, but otherwise yes it is an event loop based system. Lua is just a module like anything else in Nginx, and uses the Nginx event loop.
Re:Fixing the callback spaghetti in node.js by skrebbel on Thursday September 29, 2011 @06:00AM (#3051792)
Ah right, I see.

From the nginx wiki:

> Unlike Apache's mod_lua and Lighttpd's mod_magnet, Lua code written atop this module can be 100% non-blocking on network traffic as long as you use the ngx.location.capture or ngx.location.capture_multi interfaces to let the nginx core do all your requests to mysql, postgresql, memcached, redis, upstream http web services, and etc etc etc (see HttpDrizzleModule, ngx_postgres, HttpMemcModule, HttpRedis2Module and HttpProxyModule modules for details).

Is that talk-via-nginx-commands thing cumbersome in practice?

Re:Fixing the callback spaghetti in node.js by SomeCallMeTim on Thursday September 29, 2011 @12:06PM (#3052997)
No, it's pretty easy. An example:

    local doc = ngx.location.capture(  "/couchdb/hamster/"..uid );
This queries the local CouchDB for a particular user record, and stores it in a local variable.