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.
_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx