[ANN] ngx_lua v0.1.5: ability to capture multiple parallel subrequests

Eugaia ngx.eugaia at gmail.com
Thu Feb 10 12:05:18 MSK 2011


Hi,

On 10/02/2011 07:30, agentzh wrote:
>> Is it also possible to pass an array of requests and get an array of
>> responses, or otherwise send requests in parallel when you don't know in
>> advance how many subrequests you want to issue?
> Sure! For instance,
>
>      -- construct the requests table
>      local reqs = {}
>      table.insert(reqs, { "/mysql" })
>      table.insert(reqs, { "/postgres" })
>      table.insert(reqs, { "/redis" })
>      table.insert(reqs, { "/memcached" })
>
>      -- issue all the requests at once and wait when they all return
>      local resps = { ngx.location.capture_multi(reqs) }
>
>      -- loop over the responses table
>      for i, resp in ipairs(resps) do
>           -- process the response table "resp"
>      end
>
> Well, it's mostly a feature on the Lua language level ;)
>
Great - thanks for the example.  I'm not overly familiar with Lua yet, 
but hopefully will be more so soon.

Cheers,

Marcus.



More information about the nginx mailing list