Hi David
On Tue, Dec 22, 2015 at 11:18 AM, David Birdsong wrote:
> I'm going through trial and error now, but a faster way of reasoning about
> what's available in balancer_by_lua would be really helpful.
>
The balancer_by_lua thing is still a new territory and we are also
exploring possibilities there ourselves. Support for more and more Lua
APIs are added upon user requests. So if you want to use some API
functions there but they break, please just file a ticket on GitHub
(or better, submitting a GitHub pull request) under the
lua-nginx-module repos :)
> It looks like ngx.req.set_uri runs but has no effect which I'm not too
> surprised by given those actions probably have to happen much earlier.
>
My hunch is that the upstream request is already constructed from the
downstream request URI and your changes in balancer_by_lua still
change the saved copy of the downstream request record, but it won't
trigger re-generation of the upstream request buffer, for obvious
reasons.
As a rule of thumb, one should do preparation (like cosocket accesses
and etc) in an earlier phase, like access_by_lua*, and store the data
in ngx.ctx for later references in balancer_by_lua*, for example.
> What about timers?
>
Timers should work inside balancer_by_lua*, if not, please file a
ticket on GitHub (or a pull request even) :)
> To come at it a different way,
> if in a
> balancer_by_lua_block {
> m.set_more_tries(0)
> }
> ...is there a way to pass control to another phase that could choose a
> different upstream without losing ngx.ctx?
Sorry, I don't follow your intention here.
>
> I'm pretty sure that using error_page and proxy_intercept_errors would work,
> but AFAIK that mechanism is using rewrite under the hood which clears
> ngx.ctx.
>
Correct. Internal redirects overwrite the magical ngx.ctx table.
Regards,
-agentzh